[cfe-dev] #line directive ignored
Richard Smith via cfe-dev
cfe-dev at lists.llvm.org
Wed Feb 28 10:43:27 PST 2018
On 13 February 2018 at 08:53, Frank Redeker via cfe-dev <
cfe-dev at lists.llvm.org> wrote:
> Hello list,
>
> I'm using ClangTool.buildASTs() to create the ASTs for a given set of
> source files.
>
> I wonder why #line directives are ignored. (Or have I missed some option
> when setting up my ClangTool instance. Or must I fix the line numbers in
> my own DiagnosticsConsumer)
>
How are you setting your DiagnosticOptions? Generally we'd expect these to
be set by a call to CompilerInvocation::CreateFromArgs, which sets
DiagnosticOptions::ShowPresumedLoc to 'true' by default (giving the output
you see from Clang). Since you're using libTooling, ToolInvocation::run()
is the place I'd expect this to happen.
> When compiling the following source
>
> #line 123 "foo"
> void foo () {
> if (condition) {
> }
> }
>
> clang -c test.c gives the following output:
>
> foo:123:6: error: use of undeclared identifier 'condition'
> if (condition) {
> ^
> 1 error generated.
>
>
> But my program gives the following output:
>
> t:\test.c:3:6: error: use of undeclared identifier 'condition'
> if (condition) {
> ^
> IDB32++: Fatal - Analyze terminated with errors
>
>
> Frank
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180228/c5b8893c/attachment.html>
More information about the cfe-dev
mailing list