#line directive ignored

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

#line directive ignored

Hans Wennborg via cfe-dev
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)


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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: #line directive ignored

Hans Wennborg via cfe-dev
On 13 February 2018 at 08:53, Frank Redeker via cfe-dev <[hidden email]> 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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev