aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/Decl.h15
-rw-r--r--include/clang/AST/DeclTemplate.h4
-rw-r--r--lib/AST/Decl.cpp37
-rw-r--r--lib/AST/DeclTemplate.cpp13
4 files changed, 27 insertions, 42 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index 68d20510ea..ba7699e1a6 100644
--- a/include/clang/AST/Decl.h
+++ b/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/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h
index b3277547e3..28a40fbbb4 100644
--- a/include/clang/AST/DeclTemplate.h
+++ b/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/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();
diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp
index 2005ff62f6..2aa446bcd3 100644
--- a/lib/AST/DeclTemplate.cpp
+++ b/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