diff options
author | Chris Lattner <sabre@nondot.org> | 2007-08-08 22:51:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-08-08 22:51:59 +0000 |
commit | 6000dace22f110d8768476989313e9d981d690d0 (patch) | |
tree | 9b21e327366209ef05097521b7a4cf2381313511 /Driver/clang.cpp | |
parent | 13b7c5ff42d6077a8d59e2c9ec9e7fedd0150ae6 (diff) |
add a new AST dumper interface (E->dump()). This dumps out
the AST in a structural, non-pretty, form useful for understanding
the AST. It isn't quite done yet, but is already somewhat useful.
For this example:
int test(short X, long long Y) {
return X < ((100));
}
we get (with -parse-ast-dump):
int test(short X, long long Y)
(CompoundStmt 0x2905ce0
(ReturnStmt 0x2905cd0
(BinaryOperator 0x2905cb0 '<'
(ImplicitCastExpr 0x2905ca0
(DeclRefExpr 0x2905c20 Decl='X' 0x2905bb0))
(ParenExpr 0x2905c80
(ParenExpr 0x2905c60
(IntegerLiteral 0x2905c40 100))))))
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40954 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/clang.cpp')
-rw-r--r-- | Driver/clang.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Driver/clang.cpp b/Driver/clang.cpp index 7d8a4590f1..2ee8a93a30 100644 --- a/Driver/clang.cpp +++ b/Driver/clang.cpp @@ -49,6 +49,7 @@ Stats("stats", llvm::cl::desc("Print performance metrics and statistics")); enum ProgActions { EmitLLVM, // Emit a .ll file. ParseASTPrint, // Parse ASTs and print them. + ParseASTDump, // Parse ASTs and dump them. ParseASTCheck, // Parse ASTs and check diagnostics. ParseAST, // Parse ASTs. ParsePrintCallbacks, // Parse and print each callback. @@ -79,6 +80,8 @@ ProgAction(llvm::cl::desc("Choose output type:"), llvm::cl::ZeroOrMore, "Run parser and build ASTs"), clEnumValN(ParseASTPrint, "parse-ast-print", "Run parser, build ASTs, then print ASTs"), + clEnumValN(ParseASTDump, "parse-ast-dump", + "Run parser, build ASTs, then dump them"), clEnumValN(ParseASTCheck, "parse-ast-check", "Run parser, build ASTs, then check diagnostics"), clEnumValN(EmitLLVM, "emit-llvm", @@ -819,6 +822,9 @@ static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID, case ParseASTPrint: PrintASTs(PP, MainFileID, Stats); break; + case ParseASTDump: + DumpASTs(PP, MainFileID, Stats); + break; case EmitLLVM: EmitLLVMFromASTs(PP, MainFileID, Stats); break; |