ASTConsumers.cpp (194613) | ASTConsumers.cpp (195341) |
---|---|
1//===--- ASTConsumers.cpp - ASTConsumer implementations -------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 30 unchanged lines hidden (view full) --- 39 40 public: 41 ASTPrinter(llvm::raw_ostream* o = NULL, bool Dump = false) 42 : Out(o? *o : llvm::errs()), Dump(Dump) { } 43 44 virtual void HandleTranslationUnit(ASTContext &Context) { 45 PrintingPolicy Policy = Context.PrintingPolicy; 46 Policy.Dump = Dump; | 1//===--- ASTConsumers.cpp - ASTConsumer implementations -------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 30 unchanged lines hidden (view full) --- 39 40 public: 41 ASTPrinter(llvm::raw_ostream* o = NULL, bool Dump = false) 42 : Out(o? *o : llvm::errs()), Dump(Dump) { } 43 44 virtual void HandleTranslationUnit(ASTContext &Context) { 45 PrintingPolicy Policy = Context.PrintingPolicy; 46 Policy.Dump = Dump; |
47 Context.getTranslationUnitDecl()->print(Out, Context, Policy); | 47 Context.getTranslationUnitDecl()->print(Out, Policy); |
48 } 49 }; 50} // end anonymous namespace 51 52ASTConsumer *clang::CreateASTPrinter(llvm::raw_ostream* out) { 53 return new ASTPrinter(out); 54} 55 --- 9 unchanged lines hidden (view full) --- 65 66 void Initialize(ASTContext &Context) { 67 Doc.initialize(Context); 68 } 69 70 virtual void HandleTranslationUnit(ASTContext &Ctx) { 71 Doc.addSubNode("TranslationUnit"); 72 for (DeclContext::decl_iterator | 48 } 49 }; 50} // end anonymous namespace 51 52ASTConsumer *clang::CreateASTPrinter(llvm::raw_ostream* out) { 53 return new ASTPrinter(out); 54} 55 --- 9 unchanged lines hidden (view full) --- 65 66 void Initialize(ASTContext &Context) { 67 Doc.initialize(Context); 68 } 69 70 virtual void HandleTranslationUnit(ASTContext &Ctx) { 71 Doc.addSubNode("TranslationUnit"); 72 for (DeclContext::decl_iterator |
73 D = Ctx.getTranslationUnitDecl()->decls_begin(Ctx), 74 DEnd = Ctx.getTranslationUnitDecl()->decls_end(Ctx); | 73 D = Ctx.getTranslationUnitDecl()->decls_begin(), 74 DEnd = Ctx.getTranslationUnitDecl()->decls_end(); |
75 D != DEnd; 76 ++D) 77 { 78 Doc.PrintDecl(*D); 79 } 80 Doc.toParent(); 81 Doc.finalize(); 82 } --- 26 unchanged lines hidden (view full) --- 109 } 110 111 void HandleTopLevelSingleDecl(Decl *D); 112 }; 113} 114 115void ASTViewer::HandleTopLevelSingleDecl(Decl *D) { 116 if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { | 75 D != DEnd; 76 ++D) 77 { 78 Doc.PrintDecl(*D); 79 } 80 Doc.toParent(); 81 Doc.finalize(); 82 } --- 26 unchanged lines hidden (view full) --- 109 } 110 111 void HandleTopLevelSingleDecl(Decl *D); 112 }; 113} 114 115void ASTViewer::HandleTopLevelSingleDecl(Decl *D) { 116 if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |
117 FD->print(llvm::errs(), *Context); | 117 FD->print(llvm::errs()); |
118 119 if (FD->getBodyIfAvailable()) { 120 llvm::cerr << '\n'; 121 FD->getBodyIfAvailable()->viewAST(); 122 llvm::cerr << '\n'; 123 } 124 return; 125 } 126 127 if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) { | 118 119 if (FD->getBodyIfAvailable()) { 120 llvm::cerr << '\n'; 121 FD->getBodyIfAvailable()->viewAST(); 122 llvm::cerr << '\n'; 123 } 124 return; 125 } 126 127 if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) { |
128 MD->print(llvm::errs(), *Context); | 128 MD->print(llvm::errs()); |
129 130 if (MD->getBody()) { 131 llvm::cerr << '\n'; 132 MD->getBody()->viewAST(); 133 llvm::cerr << '\n'; 134 } 135 } 136} --- 198 unchanged lines hidden (view full) --- 335 336 default: 337 assert(0 && "a decl that inherits DeclContext isn't handled"); 338 } 339 340 Out << "\n"; 341 342 // Print decls in the DeclContext. | 129 130 if (MD->getBody()) { 131 llvm::cerr << '\n'; 132 MD->getBody()->viewAST(); 133 llvm::cerr << '\n'; 134 } 135 } 136} --- 198 unchanged lines hidden (view full) --- 335 336 default: 337 assert(0 && "a decl that inherits DeclContext isn't handled"); 338 } 339 340 Out << "\n"; 341 342 // Print decls in the DeclContext. |
343 // FIXME: Should not use a NULL DeclContext! 344 ASTContext *Context = 0; 345 for (DeclContext::decl_iterator I = DC->decls_begin(*Context), 346 E = DC->decls_end(*Context); | 343 for (DeclContext::decl_iterator I = DC->decls_begin(), E = DC->decls_end(); |
347 I != E; ++I) { 348 for (unsigned i = 0; i < Indentation; ++i) 349 Out << " "; 350 351 Decl::Kind DK = I->getKind(); 352 switch (DK) { 353 case Decl::Namespace: 354 case Decl::Enum: --- 97 unchanged lines hidden --- | 344 I != E; ++I) { 345 for (unsigned i = 0; i < Indentation; ++i) 346 Out << " "; 347 348 Decl::Kind DK = I->getKind(); 349 switch (DK) { 350 case Decl::Namespace: 351 case Decl::Enum: --- 97 unchanged lines hidden --- |