From 8a803cc351583371297b9b02e617dd3636b8a092 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Tue, 30 Jun 2009 02:35:04 +0000 Subject: [PATCH] Remove the ASTContext parameter from the printing related methods of Decl. llvm-svn: 74503 --- clang/include/clang/AST/DeclBase.h | 10 ++++------ clang/lib/AST/DeclPrinter.cpp | 27 ++++++++++++-------------- clang/lib/AST/StmtPrinter.cpp | 5 ++--- clang/lib/Frontend/ASTConsumers.cpp | 6 +++--- clang/lib/Frontend/ResolveLocation.cpp | 2 +- 5 files changed, 22 insertions(+), 28 deletions(-) diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 31f35510a413..8c79a8426ffd 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -347,15 +347,13 @@ public: /// Destroy - Call destructors and release memory. virtual void Destroy(ASTContext& C); - void print(llvm::raw_ostream &Out, ASTContext &Context, + void print(llvm::raw_ostream &Out, unsigned Indentation = 0); + void print(llvm::raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation = 0); - void print(llvm::raw_ostream &Out, ASTContext &Context, - const PrintingPolicy &Policy, unsigned Indentation = 0); static void printGroup(Decl** Begin, unsigned NumDecls, - llvm::raw_ostream &Out, ASTContext &Context, - const PrintingPolicy &Policy, + llvm::raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation = 0); - void dump(ASTContext &Context); + void dump(); private: const Attr *getAttrsImpl() const; diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index 2b06e93295bc..d3268300c3ce 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -74,14 +74,13 @@ namespace { }; } -void Decl::print(llvm::raw_ostream &Out, ASTContext &Context, - unsigned Indentation) { - print(Out, Context, Context.PrintingPolicy, Indentation); +void Decl::print(llvm::raw_ostream &Out, unsigned Indentation) { + print(Out, getASTContext().PrintingPolicy, Indentation); } -void Decl::print(llvm::raw_ostream &Out, ASTContext &Context, - const PrintingPolicy &Policy, unsigned Indentation) { - DeclPrinter Printer(Out, Context, Policy, Indentation); +void Decl::print(llvm::raw_ostream &Out, const PrintingPolicy &Policy, + unsigned Indentation) { + DeclPrinter Printer(Out, getASTContext(), Policy, Indentation); Printer.Visit(this); } @@ -112,11 +111,10 @@ static QualType getDeclType(Decl* D) { } void Decl::printGroup(Decl** Begin, unsigned NumDecls, - llvm::raw_ostream &Out, ASTContext &Context, - const PrintingPolicy &Policy, + llvm::raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation) { if (NumDecls == 1) { - (*Begin)->print(Out, Context, Policy, Indentation); + (*Begin)->print(Out, Policy, Indentation); return; } @@ -127,7 +125,7 @@ void Decl::printGroup(Decl** Begin, unsigned NumDecls, PrintingPolicy SubPolicy(Policy); if (TD && TD->isDefinition()) { - TD->print(Out, Context, Policy, Indentation); + TD->print(Out, Policy, Indentation); Out << " "; SubPolicy.SuppressTag = true; } @@ -142,12 +140,12 @@ void Decl::printGroup(Decl** Begin, unsigned NumDecls, SubPolicy.SuppressSpecifiers = true; } - (*Begin)->print(Out, Context, SubPolicy, Indentation); + (*Begin)->print(Out, SubPolicy, Indentation); } } -void Decl::dump(ASTContext &Context) { - print(llvm::errs(), Context); +void Decl::dump() { + print(llvm::errs()); } llvm::raw_ostream& DeclPrinter::Indent() { @@ -158,8 +156,7 @@ llvm::raw_ostream& DeclPrinter::Indent() { void DeclPrinter::ProcessDeclGroup(llvm::SmallVectorImpl& Decls) { this->Indent(); - Decl::printGroup(Decls.data(), Decls.size(), Out, Context, - Policy, Indentation); + Decl::printGroup(Decls.data(), Decls.size(), Out, Policy, Indentation); Out << ";\n"; Decls.clear(); diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index 189400b29adc..825a873d06d6 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -114,7 +114,7 @@ void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) { } void StmtPrinter::PrintRawDecl(Decl *D) { - D->print(OS, Context, Policy, IndentLevel); + D->print(OS, Policy, IndentLevel); } void StmtPrinter::PrintRawDeclStmt(DeclStmt *S) { @@ -123,8 +123,7 @@ void StmtPrinter::PrintRawDeclStmt(DeclStmt *S) { for ( ; Begin != End; ++Begin) Decls.push_back(*Begin); - Decl::printGroup(Decls.data(), Decls.size(), OS, Context, Policy, - IndentLevel); + Decl::printGroup(Decls.data(), Decls.size(), OS, Policy, IndentLevel); } void StmtPrinter::VisitNullStmt(NullStmt *Node) { diff --git a/clang/lib/Frontend/ASTConsumers.cpp b/clang/lib/Frontend/ASTConsumers.cpp index 5844be826cf7..97d6d0e96d73 100644 --- a/clang/lib/Frontend/ASTConsumers.cpp +++ b/clang/lib/Frontend/ASTConsumers.cpp @@ -44,7 +44,7 @@ namespace { virtual void HandleTranslationUnit(ASTContext &Context) { PrintingPolicy Policy = Context.PrintingPolicy; Policy.Dump = Dump; - Context.getTranslationUnitDecl()->print(Out, Context, Policy); + Context.getTranslationUnitDecl()->print(Out, Policy); } }; } // end anonymous namespace @@ -114,7 +114,7 @@ namespace { void ASTViewer::HandleTopLevelSingleDecl(Decl *D) { if (FunctionDecl *FD = dyn_cast(D)) { - FD->print(llvm::errs(), *Context); + FD->print(llvm::errs()); if (FD->getBodyIfAvailable()) { llvm::cerr << '\n'; @@ -125,7 +125,7 @@ void ASTViewer::HandleTopLevelSingleDecl(Decl *D) { } if (ObjCMethodDecl *MD = dyn_cast(D)) { - MD->print(llvm::errs(), *Context); + MD->print(llvm::errs()); if (MD->getBody()) { llvm::cerr << '\n'; diff --git a/clang/lib/Frontend/ResolveLocation.cpp b/clang/lib/Frontend/ResolveLocation.cpp index 51827271f293..4bbb94d311ad 100644 --- a/clang/lib/Frontend/ResolveLocation.cpp +++ b/clang/lib/Frontend/ResolveLocation.cpp @@ -287,7 +287,7 @@ void LocResolverBase::FixRange(SourceRange &Range) { void LocResolverBase::print(Decl *D) { llvm::raw_ostream &OS = llvm::outs(); OS << "#### DECL ####\n"; - D->print(OS, Ctx); + D->print(OS); OS << " <"; D->getLocStart().print(OS, Ctx.getSourceManager()); OS << " > - <";