Using clang reporting for a clang-tool

Hi everybody,

I currently am developing a tool using clang front end which purpose is to verify the code source coding-style.

I would like to use clang reporting system, but when looking into the errors and warnings I found out the use of clang-tblgen.

I could not use it in order to create my own tool errors and warnings, I would like some help links/readings please

Many thanks in advance,

See DiagnosticIDs::getCustomDiagID().

-- Sean Silva

Thanks

I have another question.

I am currently using PPCallbacks in order to check coding-style in macros.
In order to do so, I'm using MacroDefined callback and I correctly get
the macro name, but I cannot figure out how to get the macro arguments
locations.

I get the macro argument string with
clang::MacroInfo::arg_begin()::getNameStart()

And then, I can figure out the offset with the getLength() method, but
it cannot help me to handle correctly the following example :

#define MAX(Arg, Arg)
#define MAX(Arg, Arg)

I have another question.

I am currently using PPCallbacks in order to check coding-style in macros.
In order to do so, I’m using MacroDefined callback and I correctly get
the macro name, but I cannot figure out how to get the macro arguments
locations.

I get the macro argument string with
clang::MacroInfo::arg_begin()::getNameStart()

And then, I can figure out the offset with the getLength() method, but
it cannot help me to handle correctly the following example :

#define MAX(Arg, Arg)
#define MAX(Arg, Arg)

We don’t keep track of the argument locations.

We could either:

  1. Store the argument source locations in MacroInfo
  2. Lazily re-lex and cache the argument locations of a MacroInfo when they are requested.

I personally am leaning towards 2) since the argument locations don’t have any use for the compiler currently.

Are you interested in working on a patch ?

I figured out that clang don't keep track of macro argument locations.

I first though of doing a patch, but I don't think I'm able to create
a correct patch without any pointers.