Plugin argument parsing

Hello!

Is there a way to access Clang's Diagnostic from inside the ParseArgs
function of a plugin? I tried to grab it via the CompilerInstance but at
that time getCompilerInstance fails since the instance isn't set yet.

It would be good to get errors/warnings during the argument parsing out
through Clang's Diagnostic so they count in the total.

Another issue: How do I terminate Clang once a fatal error occurs during
the parsing, e.g. some essential information is missing. Returning
'false' doesn't do the trick. In fact the return value is just dropped
by Clang. So I just do an 'exit(1)' which works fine. Are there any
problems this can cause, like inconsistent state somewhere?

Regards, Jan.

Hi Jan,

I changed the API to pass in the CompilerInstance to ParseArgs, you
can use that to report diagnostics. If you want to abort execution,
you can return false from the ParseArgs function. See
http://llvm.org/viewvc/llvm-project?view=rev&revision=110039, which
includes an update to the PrintFunctionNames example.

Cheers,
- Daniel

Daniel Dunbar meinte am 02.08.2010 17:32:

I changed the API to pass in the CompilerInstance to ParseArgs, you
can use that to report diagnostics. If you want to abort execution,
you can return false from the ParseArgs function.

Absolutely perfect. Thanks a lot for the quick update!

A reference to CompilerInstance is even better since it can also be used
to change some language options according to plugin's needs :slight_smile:

Regards, Jan.

Jan 'Ingrid' Bierbaum meinte am 02.08.2010 22:54:

A reference to CompilerInstance is even better since it can also be used
to change some language options according to plugin's needs :slight_smile:

OK, strike that one out. I missed the 'const' at first sight...