r177809 - Strip off local qualifiers when converting from RecordType to

Richard Trieu rtrieu at google.com
Fri Mar 22 18:38:36 PDT 2013


Author: rtrieu
Date: Fri Mar 22 20:38:36 2013
New Revision: 177809

URL: http://llvm.org/viewvc/llvm-project?rev=177809&view=rev
Log:
Strip off local qualifiers when converting from RecordType to
TemplateSpecializationType during template type diffing.  This allows the
correct printing of diffing qualifiers on templates.

Modified:
    cfe/trunk/lib/AST/ASTDiagnostic.cpp
    cfe/trunk/test/Misc/diag-template-diffing-cxx98.cpp
    cfe/trunk/test/Misc/diag-template-diffing.cpp

Modified: cfe/trunk/lib/AST/ASTDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDiagnostic.cpp?rev=177809&r1=177808&r2=177809&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Fri Mar 22 20:38:36 2013
@@ -811,7 +811,7 @@ class TemplateDiff {
              TemplateName(CTSD->getSpecializedTemplate()),
              CTSD->getTemplateArgs().data(),
              CTSD->getTemplateArgs().size(),
-             Ty.getCanonicalType());
+             Ty.getLocalUnqualifiedType().getCanonicalType());
 
     return Ty->getAs<TemplateSpecializationType>();
   }

Modified: cfe/trunk/test/Misc/diag-template-diffing-cxx98.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-template-diffing-cxx98.cpp?rev=177809&r1=177808&r2=177809&view=diff
==============================================================================
--- cfe/trunk/test/Misc/diag-template-diffing-cxx98.cpp (original)
+++ cfe/trunk/test/Misc/diag-template-diffing-cxx98.cpp Fri Mar 22 20:38:36 2013
@@ -31,3 +31,19 @@ namespace default_args {
   }
 
 }
+
+namespace qualifiers {
+  template <class T>
+  void foo(void (func(T*)), T*) {}
+
+  template <class T>
+  class vector{};
+
+  void bar(const vector<int>*) {}
+
+  void test(volatile vector<int>* V) {
+    foo(bar, V);
+  }
+
+  // CHECK: candidate template ignored: deduced conflicting types for parameter 'T' ('const vector<[...]>' vs. 'volatile vector<[...]>')
+}

Modified: cfe/trunk/test/Misc/diag-template-diffing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-template-diffing.cpp?rev=177809&r1=177808&r2=177809&view=diff
==============================================================================
--- cfe/trunk/test/Misc/diag-template-diffing.cpp (original)
+++ cfe/trunk/test/Misc/diag-template-diffing.cpp Fri Mar 22 20:38:36 2013
@@ -645,41 +645,41 @@ void Play1() {
 }
 
 // CHECK-ELIDE-NOTREE: no viable overloaded '='
-// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument
+// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<1>' to 'const Foo1<2>' for 1st argument
 // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument
 // CHECK-ELIDE-NOTREE: no viable overloaded '='
-// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument
+// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<2>' to 'const Foo1<1>' for 1st argument
 // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument
 // CHECK-NOELIDE-NOTREE: no viable overloaded '='
-// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument
+// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<1>' to 'const Foo1<2>' for 1st argument
 // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument
 // CHECK-NOELIDE-NOTREE: no viable overloaded '='
-// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument
+// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<2>' to 'const Foo1<1>' for 1st argument
 // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument
 // CHECK-ELIDE-TREE: no viable overloaded '='
 // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
-// CHECK-ELIDE-TREE:   Foo1<
+// CHECK-ELIDE-TREE:   [(no qualifiers) != const] Foo1<
 // CHECK-ELIDE-TREE:     [1 != 2]>
 // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
 // CHECK-ELIDE-TREE:   Foo1<
 // CHECK-ELIDE-TREE:     [1 != 2]>
 // CHECK-ELIDE-TREE: no viable overloaded '='
 // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
-// CHECK-ELIDE-TREE:   Foo1<
+// CHECK-ELIDE-TREE:   [(no qualifiers) != const] Foo1<
 // CHECK-ELIDE-TREE:     [2 != 1]>
 // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
 // CHECK-ELIDE-TREE:   Foo1<
 // CHECK-ELIDE-TREE:     [2 != 1]>
 // CHECK-NOELIDE-TREE: no viable overloaded '='
 // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
-// CHECK-NOELIDE-TREE:   Foo1<
+// CHECK-NOELIDE-TREE:   [(no qualifiers) != const] Foo1<
 // CHECK-NOELIDE-TREE:     [1 != 2]>
 // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
 // CHECK-NOELIDE-TREE:   Foo1<
 // CHECK-NOELIDE-TREE:     [1 != 2]>
 // CHECK-NOELIDE-TREE: no viable overloaded '='
 // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
-// CHECK-NOELIDE-TREE:   Foo1<
+// CHECK-NOELIDE-TREE:   [(no qualifiers) != const] Foo1<
 // CHECK-NOELIDE-TREE:     [2 != 1]>
 // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
 // CHECK-NOELIDE-TREE:   Foo1<
@@ -694,41 +694,41 @@ void Play2() {
   F3 = F2;
 }
 // CHECK-ELIDE-NOTREE: no viable overloaded '='
-// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument
+// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<1>' to 'const Foo2<2>' for 1st argument
 // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument
 // CHECK-ELIDE-NOTREE: no viable overloaded '='
-// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'Foo2<1>' for 1st argument
+// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'const Foo2<1>' for 1st argument
 // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'Foo2<1>' for 1st argument
 // CHECK-NOELIDE-NOTREE: no viable overloaded '='
-// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument
+// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<1>' to 'const Foo2<2>' for 1st argument
 // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument
 // CHECK-NOELIDE-NOTREE: no viable overloaded '='
-// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'Foo2<1>' for 1st argument
+// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'const Foo2<1>' for 1st argument
 // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'Foo2<1>' for 1st argument
 // CHECK-ELIDE-TREE: no viable overloaded '='
 // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
-// CHECK-ELIDE-TREE:   Foo2<
+// CHECK-ELIDE-TREE:   [(no qualifiers) != const] Foo2<
 // CHECK-ELIDE-TREE:     [1 != 2]>
 // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
 // CHECK-ELIDE-TREE:   Foo2<
 // CHECK-ELIDE-TREE:     [1 != 2]>
 // CHECK-ELIDE-TREE: no viable overloaded '='
 // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
-// CHECK-ELIDE-TREE:   Foo2<
+// CHECK-ELIDE-TREE:   [(no qualifiers) != const] Foo2<
 // CHECK-ELIDE-TREE:     [(default) 2 != 1]>
 // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
 // CHECK-ELIDE-TREE:   Foo2<
 // CHECK-ELIDE-TREE:     [(default) 2 != 1]>
 // CHECK-NOELIDE-TREE: no viable overloaded '='
 // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
-// CHECK-NOELIDE-TREE:   Foo2<
+// CHECK-NOELIDE-TREE:   [(no qualifiers) != const] Foo2<
 // CHECK-NOELIDE-TREE:     [1 != 2]>
 // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
 // CHECK-NOELIDE-TREE:   Foo2<
 // CHECK-NOELIDE-TREE:     [1 != 2]>
 // CHECK-NOELIDE-TREE: no viable overloaded '='
 // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
-// CHECK-NOELIDE-TREE:   Foo2<
+// CHECK-NOELIDE-TREE:   [(no qualifiers) != const] Foo2<
 // CHECK-NOELIDE-TREE:     [(default) 2 != 1]>
 // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
 // CHECK-NOELIDE-TREE:   Foo2<
@@ -743,20 +743,20 @@ void Play3() {
   F3 = F2;
 }
 // CHECK-ELIDE-NOTREE: no viable overloaded '='
-// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'Foo3<2, 1>' for 1st argument
+// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'const Foo3<2, 1>' for 1st argument
 // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'Foo3<2, 1>' for 1st argument
 // CHECK-ELIDE-NOTREE: no viable overloaded '='
-// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'Foo3<1, (no argument)>' for 1st argument
+// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'const Foo3<1, (no argument)>' for 1st argument
 // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'Foo3<1, (no argument)>' for 1st argument
 // CHECK-NOELIDE-NOTREE: no viable overloaded '='
-// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'Foo3<2, 1>' for 1st argument
+// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'const Foo3<2, 1>' for 1st argument
 // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'Foo3<2, 1>' for 1st argument
 // CHECK-NOELIDE-NOTREE: no viable overloaded '='
-// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'Foo3<1, (no argument)>' for 1st argument
+// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'const Foo3<1, (no argument)>' for 1st argument
 // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'Foo3<1, (no argument)>' for 1st argument
 // CHECK-ELIDE-TREE: no viable overloaded '='
 // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
-// CHECK-ELIDE-TREE:   Foo3<
+// CHECK-ELIDE-TREE:   [(no qualifiers) != const] Foo3<
 // CHECK-ELIDE-TREE:     [1 != 2], 
 // CHECK-ELIDE-TREE:     [(no argument) != 1]>
 // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
@@ -765,7 +765,7 @@ void Play3() {
 // CHECK-ELIDE-TREE:     [(no argument) != 1]>
 // CHECK-ELIDE-TREE: no viable overloaded '='
 // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
-// CHECK-ELIDE-TREE:   Foo3<
+// CHECK-ELIDE-TREE:   [(no qualifiers) != const] Foo3<
 // CHECK-ELIDE-TREE:     [2 != 1],
 // CHECK-ELIDE-TREE:     [1 != (no argument)]>
 // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
@@ -774,7 +774,7 @@ void Play3() {
 // CHECK-ELIDE-TREE:     [1 != (no argument)]>
 // CHECK-NOELIDE-TREE: no viable overloaded '='
 // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
-// CHECK-NOELIDE-TREE:   Foo3<
+// CHECK-NOELIDE-TREE:   [(no qualifiers) != const] Foo3<
 // CHECK-NOELIDE-TREE:     [1 != 2], 
 // CHECK-NOELIDE-TREE:     [(no argument) != 1]>
 // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
@@ -783,7 +783,7 @@ void Play3() {
 // CHECK-NOELIDE-TREE:     [(no argument) != 1]>
 // CHECK-NOELIDE-TREE: no viable overloaded '='
 // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
-// CHECK-NOELIDE-TREE:   Foo3<
+// CHECK-NOELIDE-TREE:   [(no qualifiers) != const] Foo3<
 // CHECK-NOELIDE-TREE:     [2 != 1], 
 // CHECK-NOELIDE-TREE:     [1 != (no argument)]>
 // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument





More information about the cfe-commits mailing list