I can parse the file without any errors, but the source locations don't seem to
reflect the line directives. When parsing a simple file "somefile.c" with a
similar directive
# 123 "dummy.c" 2
static int func()
{
return 0;
}
and iterating over the definitions, I get source location results like
whereas I would have hoped that the func definition had a source location at the
appropriate line in "dummy.c". Using a #line directive makes no difference.
Is there any way one can get clang to take # line directives into account? None
of the CXTranslationUnit_XXX flags seem to be applicable here.
I can parse the file without any errors, but the source locations don't seem to
reflect the line directives. When parsing a simple file "somefile.c" with a
similar directive
# 123 "dummy.c" 2
static int func()
{
return 0;
}
and iterating over the definitions, I get source location results like
whereas I would have hoped that the func definition had a source location at the
appropriate line in "dummy.c". Using a #line directive makes no difference.
Is there any way one can get clang to take # line directives into account? None
of the CXTranslationUnit_XXX flags seem to be applicable here.
There is not currently a way to expose that info from libclang. There should be a new function (like clang_getPresumedLocation) similar to clang_getExpansionLocation that will call SourceManager::getPresumedLoc internally.
Please file a bugzilla report so that we can track it.