#line directive ignored

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

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.