[cfe-dev] libclang and handling of # directives
Vinay Sajip
vinay_sajip at yahoo.co.uk
Mon Sep 5 14:13:25 PDT 2011
I'm using libclang to parse some Objective-C code which has been produced using
gcc -E, and so the input file has #line directives of the form
# 45 "/System/Library/Frameworks/WebKit.framework/Headers/WebUIDelegate.h" 3
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
Typedef, __builtin_va_list, NULL, 99, 15
FunctionNoProto, func, somefile.c, 3, 12
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.
Thanks,
Vinay Sajip
More information about the cfe-dev
mailing list