summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2013-01-31 02:47:46 +0000
committerRichard Trieu <rtrieu@google.com>2013-01-31 02:47:46 +0000
commite673d71a07a85face6c3b7b60c1357f7dfe45255 (patch)
treed1f1fae75e3c05e30ffd1006dae897b113231b1d /clang/lib/AST
parent36fa8398f5a6d8857f8a51c41337008f288cb333 (diff)
downloadbcm5719-llvm-e673d71a07a85face6c3b7b60c1357f7dfe45255.tar.gz
bcm5719-llvm-e673d71a07a85face6c3b7b60c1357f7dfe45255.zip
When comparing two template template arguments in the template differ, consider
them the same if they are actually the same; having the same name isn't enough. Similar to r174013, template template arguments were also mistakenly considered the same when they had the same name but were in different namespaces. In addition, when printing template template arguments, use the qualified name if the regular name is the same. llvm-svn: 174029
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ASTDiagnostic.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index fb3544f03aa..4f165132a6f 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -894,8 +894,9 @@ class TemplateDiff {
GetTemplateDecl(FromIter, DefaultTTPD, FromDecl);
GetTemplateDecl(ToIter, DefaultTTPD, ToDecl);
Tree.SetNode(FromDecl, ToDecl);
- Tree.SetSame(FromDecl && ToDecl &&
- FromDecl->getIdentifier() == ToDecl->getIdentifier());
+ Tree.SetSame(
+ FromDecl && ToDecl &&
+ FromDecl->getCanonicalDecl() == ToDecl->getCanonicalDecl());
}
if (!FromIter.isEnd()) ++FromIter;
@@ -1278,21 +1279,29 @@ class TemplateDiff {
void PrintTemplateTemplate(TemplateDecl *FromTD, TemplateDecl *ToTD,
bool FromDefault, bool ToDefault, bool Same) {
assert((FromTD || ToTD) && "Only one template argument may be missing.");
+
+ std::string FromName = FromTD ? FromTD->getName() : "(no argument)";
+ std::string ToName = ToTD ? ToTD->getName() : "(no argument)";
+ if (FromTD && ToTD && FromName == ToName) {
+ FromName = FromTD->getQualifiedNameAsString();
+ ToName = ToTD->getQualifiedNameAsString();
+ }
+
if (Same) {
OS << "template " << FromTD->getNameAsString();
} else if (!PrintTree) {
OS << (FromDefault ? "(default) template " : "template ");
Bold();
- OS << (FromTD ? FromTD->getNameAsString() : "(no argument)");
+ OS << FromName;
Unbold();
} else {
OS << (FromDefault ? "[(default) template " : "[template ");
Bold();
- OS << (FromTD ? FromTD->getNameAsString() : "(no argument)");
+ OS << FromName;
Unbold();
OS << " != " << (ToDefault ? "(default) template " : "template ");
Bold();
- OS << (ToTD ? ToTD->getNameAsString() : "(no argument)");
+ OS << ToName;
Unbold();
OS << ']';
}
OpenPOWER on IntegriCloud