[cfe-dev] How to get the AST of a single cpp file with clang?
ruben
rdealba at codicesoftware.com
Wed Nov 13 09:56:35 PST 2013
I know that it will never be fully accurate without the headers because C++
isn't context free.
Using the classic example of 'A B(C);', it means that it can be recognized
as a function declaration or an object definition. Either is fine for me. I
just need the file totally parsed.
I am not interested in the semantic analysis of the code, just in the
syntactic one and AFAIK the grammar of clang is one of the best.
The problem is that in some scenarios clang is avoiding some declarations
when it doesn't know the types although I guess it can correctly parse it.
See the following case. Content of class.cpp:
/ A::A() { }
A::~A() { }
void A::B() { }
A::C() { }/
Executing the clang command line application:
/ $ clang -Xclang -ast-dump -fsyntax-only class.cpp/
it's just recognizing as AST nodes the constructor and the last method.
/ typedef char *__builtin_va_list;
int A() (CompoundStmt 0x9a6a570 <class.cpp:3:8, col:10>)
int C() (CompoundStmt 0x9a6a600 <class.cpp:9:8, col:10>)/
Is there any way to get the complete AST tree?
Thanks!
--
View this message in context: http://clang-developers.42468.n3.nabble.com/How-to-get-the-AST-of-a-single-cpp-file-with-clang-tp4036017.html
Sent from the Clang Developers mailing list archive at Nabble.com.
More information about the cfe-dev
mailing list