[cfe-dev] Disable #error?

Olivier Goffart ogoffart at kde.org
Thu Jan 16 14:30:34 PST 2014


On Tuesday 14 January 2014 17:58:33 Alp Toker wrote:
> On 14/01/2014 17:45, Jacob Carlborg wrote:
> > Is it possible to disable #error directives? Either by a command line
> > flag or my some kind of option. This is for a tool built on libclang.
> 
> Hi Jacob,
> 
> This is an interesting idea. It's always a hard error right now.
> 
> We've seen similar requests to 'downgrade' a few other errors like the
> MS inline assembly missing-backend one and I suspect there's a pattern
> developing here.
> 
> Could you expand on your specific use-case a little?
> 
> We need to get a clear idea of the kinds of tools and interfaces
> (libclang, tooling, refactoring?) that would benefit from such a
> soft-errors mode, as well as an idea which other errors might qualify,
> to develop a plan of action.

Hi, 

I had an use case similar to Jacob in one of my project[1],  in which I try to 
parse headers which are not necessarily self contains and the tool should 
therefore not error out in case of error (I just wanted to transform them into 
warnings).

The best way i found to transform error into warnings is to re-implement 
DiagnosticConsumer::HandleDiagnostic and to call DiagnosticEngine::Reset from 
it:  http://code.woboq.org/mocng/src/main.cpp.html#101
But that messes up the error/warning count reported at the end.  I wish there 
was a better way.


[1] http://woboq.com/blog/moc-with-clang.html

-- 
Olivier



More information about the cfe-dev mailing list