aboutsummaryrefslogtreecommitdiff
path: root/Driver/clang.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-01-13 01:29:24 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-01-13 01:29:24 +0000
commit2d75d6f56c2937d67aecb6008793694f9eb51349 (patch)
tree453e024172eaf2478092c527b547c2993590395c /Driver/clang.cpp
parent8b4bf90eb6d3d08cf3bfb86705f0fdb20b9c5875 (diff)
Add an initial framework of a DeclContextPrinter. It can print DeclContext and
its Decls in indented format. An Example: $ cat t.cpp class A { int a; void f(); }; void A::f() { a = 3; } $ clang -print-decl-contexts t.cpp [translation unit] 0x9754d7c <typedef> __builtin_va_list [class] A 0x9753310 <class> A 0x975ce20 <field> a <c++ method> f <c++ ctor> A <c++ ctor> A <c++ method> operator= <c++ dtor> ~A [c++ method] f [[0x9753310]] Some comments: '<>' indicates a declaration, '[]' indicates a definition, '[[ ]]' displays the semantic DeclContext which is different from the lexical DeclContext. The symbols printed can definitely be changed in the future. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62136 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/clang.cpp')
-rw-r--r--Driver/clang.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index 51b1335f9c..5f3a554dbb 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -83,6 +83,7 @@ enum ProgActions {
ASTPrint, // Parse ASTs and print them.
ASTDump, // Parse ASTs and dump them.
ASTView, // Parse ASTs and view them in Graphviz.
+ PrintDeclContext, // Print DeclContext and their Decls.
TestSerialization, // Run experimental serialization code.
ParsePrintCallbacks, // Parse and print each callback.
ParseSyntaxOnly, // Parse and perform semantic analysis.
@@ -122,6 +123,8 @@ ProgAction(llvm::cl::desc("Choose output type:"), llvm::cl::ZeroOrMore,
"Build ASTs and then debug dump them"),
clEnumValN(ASTView, "ast-view",
"Build ASTs and view them with GraphViz"),
+ clEnumValN(PrintDeclContext, "print-decl-contexts",
+ "Print DeclContexts and their Decls."),
clEnumValN(TestSerialization, "test-pickling",
"Run prototype serialization code"),
clEnumValN(EmitAssembly, "S",
@@ -1245,6 +1248,9 @@ static ASTConsumer* CreateASTConsumer(const std::string& InFile,
case ASTView:
return CreateASTViewer();
+
+ case PrintDeclContext:
+ return CreateDeclContextPrinter();
case EmitHTML:
return CreateHTMLPrinter(OutputFile, Diag, PP, PPF);