diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-02-17 17:23:19 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-02-17 17:23:19 +0000 |
| commit | a991f3a4e9151c4dc24f3d0902a7686d8febcd31 (patch) | |
| tree | 4c956388f5c9762897470578c8ccf19f91f80f09 | |
| parent | 0215459c37cb0461cc85b8fc462fafb6ec7ae1dc (diff) | |
| download | bcm5719-llvm-a991f3a4e9151c4dc24f3d0902a7686d8febcd31.tar.gz bcm5719-llvm-a991f3a4e9151c4dc24f3d0902a7686d8febcd31.zip | |
Devirtualize NamedDecl::getNameForDiagnostic().
llvm-svn: 125751
| -rw-r--r-- | clang/include/clang/AST/Decl.h | 15 | ||||
| -rw-r--r-- | clang/include/clang/AST/DeclTemplate.h | 4 | ||||
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 37 | ||||
| -rw-r--r-- | clang/lib/AST/DeclTemplate.cpp | 13 |
4 files changed, 27 insertions, 42 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 68d20510ea9..ba7699e1a68 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -158,14 +158,9 @@ public: /// specializations are printed with their template arguments. /// /// TODO: use an API that doesn't require so many temporary strings - virtual void getNameForDiagnostic(std::string &S, - const PrintingPolicy &Policy, - bool Qualified) const { - if (Qualified) - S += getQualifiedNameAsString(Policy); - else - S += getNameAsString(); - } + void getNameForDiagnostic(std::string &S, + const PrintingPolicy &Policy, + bool Qualified) const; /// declarationReplaces - Determine whether this declaration, if /// known to be well-formed within its context, will replace the @@ -1349,10 +1344,6 @@ public: return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc); } - virtual void getNameForDiagnostic(std::string &S, - const PrintingPolicy &Policy, - bool Qualified) const; - SourceRange getSourceRange() const { return SourceRange(getOuterLocStart(), EndRangeLoc); } diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index b3277547e3d..28a40fbbb46 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -1318,10 +1318,6 @@ public: static ClassTemplateSpecializationDecl * Create(ASTContext &Context, EmptyShell Empty); - virtual void getNameForDiagnostic(std::string &S, - const PrintingPolicy &Policy, - bool Qualified) const; - ClassTemplateSpecializationDecl *getMostRecentDeclaration() { CXXRecordDecl *Recent = cast<CXXRecordDecl>(CXXRecordDecl::getMostRecentDeclaration()); diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 441444da9e5..0b07d13cba3 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -601,6 +601,30 @@ static void clearLinkageForClass(const CXXRecordDecl *record) { } } +void NamedDecl::getNameForDiagnostic(std::string &S, + const PrintingPolicy &Policy, + bool Qualified) const { + if (Qualified) + S += getQualifiedNameAsString(Policy); + else + S += getNameAsString(); + + const TemplateArgumentList *TemplateArgs = 0; + + if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(this)) + TemplateArgs = FD->getTemplateSpecializationArgs(); + else if (const ClassTemplateSpecializationDecl *Spec + = dyn_cast<ClassTemplateSpecializationDecl>(this)) + TemplateArgs = &Spec->getTemplateArgs(); + + + if (TemplateArgs) + S += TemplateSpecializationType::PrintTemplateArgumentList( + TemplateArgs->data(), + TemplateArgs->size(), + Policy); +} + void NamedDecl::ClearLinkageCache() { // Note that we can't skip clearing the linkage of children just // because the parent doesn't have cached linkage: we don't cache @@ -1283,19 +1307,6 @@ bool ParmVarDecl::isParameterPack() const { // FunctionDecl Implementation //===----------------------------------------------------------------------===// -void FunctionDecl::getNameForDiagnostic(std::string &S, - const PrintingPolicy &Policy, - bool Qualified) const { - NamedDecl::getNameForDiagnostic(S, Policy, Qualified); - const TemplateArgumentList *TemplateArgs = getTemplateSpecializationArgs(); - if (TemplateArgs) - S += TemplateSpecializationType::PrintTemplateArgumentList( - TemplateArgs->data(), - TemplateArgs->size(), - Policy); - -} - bool FunctionDecl::isVariadic() const { if (const FunctionProtoType *FT = getType()->getAs<FunctionProtoType>()) return FT->isVariadic(); diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index 2005ff62f64..2aa446bcd31 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -551,19 +551,6 @@ ClassTemplateSpecializationDecl::Create(ASTContext &Context, EmptyShell Empty) { new (Context)ClassTemplateSpecializationDecl(ClassTemplateSpecialization); } -void -ClassTemplateSpecializationDecl::getNameForDiagnostic(std::string &S, - const PrintingPolicy &Policy, - bool Qualified) const { - NamedDecl::getNameForDiagnostic(S, Policy, Qualified); - - const TemplateArgumentList &TemplateArgs = getTemplateArgs(); - S += TemplateSpecializationType::PrintTemplateArgumentList( - TemplateArgs.data(), - TemplateArgs.size(), - Policy); -} - ClassTemplateDecl * ClassTemplateSpecializationDecl::getSpecializedTemplate() const { if (SpecializedPartialSpecialization *PartialSpec |

