From 9bde77309fd2f9f7a53446e374472c48c81f5182 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 31 Mar 2009 20:22:05 +0000 Subject: [PATCH] Some cleanup and renaming. No functionality change git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68140 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/NestedNameSpecifier.h | 4 ++-- include/clang/AST/TemplateName.h | 4 ++-- lib/AST/NestedNameSpecifier.cpp | 14 ++++---------- lib/AST/StmtPrinter.cpp | 4 ++-- lib/AST/TemplateName.cpp | 16 +++++----------- lib/AST/Type.cpp | 6 +++--- lib/Sema/SemaTemplateInstantiate.cpp | 5 ++--- 7 files changed, 20 insertions(+), 33 deletions(-) diff --git a/include/clang/AST/NestedNameSpecifier.h b/include/clang/AST/NestedNameSpecifier.h index 0eb6826919..864459b8ce 100644 --- a/include/clang/AST/NestedNameSpecifier.h +++ b/include/clang/AST/NestedNameSpecifier.h @@ -159,7 +159,7 @@ public: /// \brief Print this nested name specifier to the given output /// stream. - void Print(llvm::raw_ostream &OS) const; + void print(llvm::raw_ostream &OS) const; void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddPointer(Prefix); @@ -171,7 +171,7 @@ public: /// \brief Dump the nested name specifier to standard output to aid /// in debugging. - void Dump(); + void dump(); }; } diff --git a/include/clang/AST/TemplateName.h b/include/clang/AST/TemplateName.h index 09e81be091..86c443985d 100644 --- a/include/clang/AST/TemplateName.h +++ b/include/clang/AST/TemplateName.h @@ -97,11 +97,11 @@ public: bool isDependent() const; /// \brief Print the template name. - void Print(llvm::raw_ostream &OS) const; + void print(llvm::raw_ostream &OS) const; /// \brief Debugging aid that dumps the template name to standard /// error. - void Dump() const; + void dump() const; void Profile(llvm::FoldingSetNodeID &ID) { ID.AddPointer(Storage.getOpaqueValue()); diff --git a/lib/AST/NestedNameSpecifier.cpp b/lib/AST/NestedNameSpecifier.cpp index 40efe2a169..2db8c76343 100644 --- a/lib/AST/NestedNameSpecifier.cpp +++ b/lib/AST/NestedNameSpecifier.cpp @@ -17,7 +17,6 @@ #include "clang/AST/Type.h" #include "llvm/Support/raw_ostream.h" #include -#include using namespace clang; @@ -105,9 +104,9 @@ bool NestedNameSpecifier::isDependent() const { /// \brief Print this nested name specifier to the given output /// stream. -void NestedNameSpecifier::Print(llvm::raw_ostream &OS) const { +void NestedNameSpecifier::print(llvm::raw_ostream &OS) const { if (Prefix) - Prefix->Print(OS); + Prefix->print(OS); switch (getKind()) { case Identifier: @@ -152,11 +151,6 @@ void NestedNameSpecifier::Destroy(ASTContext &Context) { Context.Deallocate((void *)this); } -void NestedNameSpecifier::Dump() { - std::string Result; - { - llvm::raw_string_ostream OS(Result); - Print(OS); - } - fprintf(stderr, "%s", Result.c_str()); +void NestedNameSpecifier::dump() { + print(llvm::errs()); } diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index bd5e22491e..cd0e8822a8 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -533,12 +533,12 @@ void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) { void StmtPrinter::VisitQualifiedDeclRefExpr(QualifiedDeclRefExpr *Node) { NamedDecl *D = Node->getDecl(); - Node->getQualifier()->Print(OS); + Node->getQualifier()->print(OS); OS << D->getNameAsString(); } void StmtPrinter::VisitUnresolvedDeclRefExpr(UnresolvedDeclRefExpr *Node) { - Node->getQualifier()->Print(OS); + Node->getQualifier()->print(OS); OS << Node->getDeclName().getAsString(); } diff --git a/lib/AST/TemplateName.cpp b/lib/AST/TemplateName.cpp index 3659e2350d..659796d27b 100644 --- a/lib/AST/TemplateName.cpp +++ b/lib/AST/TemplateName.cpp @@ -14,7 +14,6 @@ #include "clang/AST/DeclTemplate.h" #include "clang/AST/NestedNameSpecifier.h" #include "llvm/Support/raw_ostream.h" -#include using namespace clang; @@ -39,26 +38,21 @@ bool TemplateName::isDependent() const { return true; } -void TemplateName::Print(llvm::raw_ostream &OS) const { +void TemplateName::print(llvm::raw_ostream &OS) const { if (TemplateDecl *Template = Storage.dyn_cast()) OS << Template->getIdentifier()->getName(); else if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName()) { - QTN->getQualifier()->Print(OS); + QTN->getQualifier()->print(OS); if (QTN->hasTemplateKeyword()) OS << "template "; OS << QTN->getTemplateDecl()->getIdentifier()->getName(); } else if (DependentTemplateName *DTN = getAsDependentTemplateName()) { - DTN->getQualifier()->Print(OS); + DTN->getQualifier()->print(OS); OS << "template "; OS << DTN->getName()->getName(); } } -void TemplateName::Dump() const { - std::string Result; - { - llvm::raw_string_ostream OS(Result); - Print(OS); - } - fprintf(stderr, "%s", Result.c_str()); +void TemplateName::dump() const { + print(llvm::errs()); } diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index a4117b2bdf..669eb7ce9c 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -1411,7 +1411,7 @@ getAsStringInternal(std::string &InnerString) const { { llvm::raw_string_ostream OS(SpecString); - Template.Print(OS); + Template.print(OS); } SpecString += PrintTemplateArgumentList(getArgs(), getNumArgs()); @@ -1426,7 +1426,7 @@ void QualifiedNameType::getAsStringInternal(std::string &InnerString) const { { llvm::raw_string_ostream OS(MyString); - NNS->Print(OS); + NNS->print(OS); } std::string TypeStr; @@ -1449,7 +1449,7 @@ void TypenameType::getAsStringInternal(std::string &InnerString) const { { llvm::raw_string_ostream OS(MyString); OS << "typename "; - NNS->Print(OS); + NNS->print(OS); OS << Name->getName(); } diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index c9f0d4fd79..2f12716b72 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -853,13 +853,12 @@ Sema::InstantiateTemplateName(TemplateName Name, SourceLocation Loc, assert(TTP->getDepth() == 0 && "Cannot reduce depth of a template template parameter"); assert(TTP->getPosition() < NumTemplateArgs && "Wrong # of template args"); - assert(dyn_cast_or_null( - TemplateArgs[TTP->getPosition()].getAsDecl()) && + assert(TemplateArgs[TTP->getPosition()].getAsDecl() && "Wrong kind of template template argument"); ClassTemplateDecl *ClassTemplate = dyn_cast( TemplateArgs[TTP->getPosition()].getAsDecl()); - + assert(ClassTemplate && "Expected a class template"); if (QualifiedTemplateName *QTN = Name.getAsQualifiedTemplateName()) { NestedNameSpecifier *NNS = InstantiateNestedNameSpecifier(QTN->getQualifier(), -- 2.40.0