]> granicus.if.org Git - clang/commitdiff
When comparing two template template arguments in the template differ, consider
authorRichard Trieu <rtrieu@google.com>
Thu, 31 Jan 2013 02:47:46 +0000 (02:47 +0000)
committerRichard Trieu <rtrieu@google.com>
Thu, 31 Jan 2013 02:47:46 +0000 (02:47 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174029 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTDiagnostic.cpp
test/Misc/diag-template-diffing.cpp

index fb3544f03aa642f7789c4b5645e48feb22c5cd7a..4f165132a6f5f3f7b23ddfe6e495274f26e43cb1 100644 (file)
@@ -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 << ']';
     }
index 7e9998c828107d8f818555ca50eb4ae8797daf9b..c6fc32d1b34959eba92637e41f5fc02967c100cc 100644 (file)
@@ -859,6 +859,14 @@ namespace rdar12931988 {
     // CHECK-ELIDE-NOTREE: no known conversion from 'B::X<int>' to 'const rdar12931988::A::X<int>'
     ax = bx;
   }
+
+  template<template<typename> class> class Y {};
+
+  void bar(Y<A::X> ya, Y<B::X> yb) {
+    // CHECK-ELIDE-NOTREE: no viable overloaded '='
+    // CHECK-ELIDE-NOTREE: no known conversion from 'Y<template rdar12931988::B::X>' to 'Y<template rdar12931988::A::X>'
+    ya = yb;
+  }
 }
 
 // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.