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 | ebe5a9bcc51bff434f38d94748b08e9160609ed9 (patch) | |
tree | d22eb82a21ac3603c55f1a08d0e2f1c0df889677 /lib/AST/Decl.cpp | |
parent | 9e6f2a8d70c3027e99c354edd9d31a37c102f30a (diff) |
Devirtualize NamedDecl::getNameForDiagnostic().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125751 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 441444da9e..0b07d13cba 100644 --- a/lib/AST/Decl.cpp +++ b/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(); |