Writing a fix-it for errors already found by clang

Hi Stuart,

Hi Jonas,

Thanks for this.

  • As far as I can tell clang does not emit a fix-it hint for this error. There is no hint on the command line and running clang-tidy with -fix-errors results in no change in the source.
  • Dumping the AST shows the VarDecl in question but it is marked “invalid”. Also when I try to write a matcher it doesn’t seem to be able to find the initializer so I think you are right that the node has been removed.

I’m not sure how exactly I would go about adding this to the frontend – do you have any suggestions for how to begin?

Cheers,

Stuart

Hi Stuart,

I am not too active in the frontend, but in lib/Parse/* is the code for parsing and it does emit FixitHints. You can grep around with

git grep "FixItHint::CreateInsertion"

Documentation for FixIt:

Documentation for CFE Internals:

Someone else might give you more specific advice, but reading the code and some doc might give you a good start :slight_smile:

Best Jonas