[llvm-branch-commits] [cfe-branch] r214696 - Merging r214008:

Bill Wendling isanbard at gmail.com
Sun Aug 3 21:36:40 PDT 2014


Author: void
Date: Sun Aug  3 23:36:40 2014
New Revision: 214696

URL: http://llvm.org/viewvc/llvm-project?rev=214696&view=rev
Log:
Merging r214008:
------------------------------------------------------------------------
r214008 | rtrieu | 2014-07-25 19:10:52 -0700 (Fri, 25 Jul 2014) | 3 lines

If a template argument is non-evaluable expression, use the profile ID to see
if the two arguments are equal.

------------------------------------------------------------------------

Modified:
    cfe/branches/release_35/   (props changed)
    cfe/branches/release_35/lib/AST/ASTDiagnostic.cpp
    cfe/branches/release_35/test/Misc/diag-template-diffing.cpp

Propchange: cfe/branches/release_35/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Aug  3 23:36:40 2014
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:213609,213611,213613,213741,213840,213902,213912,213993,213998,214208
+/cfe/trunk:213609,213611,213613,213741,213840,213902,213912,213993,213998,214008,214208
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_35/lib/AST/ASTDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_35/lib/AST/ASTDiagnostic.cpp?rev=214696&r1=214695&r2=214696&view=diff
==============================================================================
--- cfe/branches/release_35/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/branches/release_35/lib/AST/ASTDiagnostic.cpp Sun Aug  3 23:36:40 2014
@@ -1291,11 +1291,8 @@ class TemplateDiff {
     if (!FromExpr || !ToExpr)
       return false;
 
-    FromExpr = FromExpr->IgnoreParens();
-    ToExpr = ToExpr->IgnoreParens();
-
-    DeclRefExpr *FromDRE = dyn_cast<DeclRefExpr>(FromExpr),
-                *ToDRE = dyn_cast<DeclRefExpr>(ToExpr);
+    DeclRefExpr *FromDRE = dyn_cast<DeclRefExpr>(FromExpr->IgnoreParens()),
+                *ToDRE = dyn_cast<DeclRefExpr>(ToExpr->IgnoreParens());
 
     if (FromDRE || ToDRE) {
       if (!FromDRE || !ToDRE)
@@ -1305,8 +1302,12 @@ class TemplateDiff {
 
     Expr::EvalResult FromResult, ToResult;
     if (!FromExpr->EvaluateAsRValue(FromResult, Context) ||
-        !ToExpr->EvaluateAsRValue(ToResult, Context))
-      return false;
+        !ToExpr->EvaluateAsRValue(ToResult, Context)) {
+      llvm::FoldingSetNodeID FromID, ToID;
+      FromExpr->Profile(FromID, Context, true);
+      ToExpr->Profile(ToID, Context, true);
+      return FromID == ToID;
+    }
 
     APValue &FromVal = FromResult.Val;
     APValue &ToVal = ToResult.Val;

Modified: cfe/branches/release_35/test/Misc/diag-template-diffing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_35/test/Misc/diag-template-diffing.cpp?rev=214696&r1=214695&r2=214696&view=diff
==============================================================================
--- cfe/branches/release_35/test/Misc/diag-template-diffing.cpp (original)
+++ cfe/branches/release_35/test/Misc/diag-template-diffing.cpp Sun Aug  3 23:36:40 2014
@@ -1212,6 +1212,41 @@ A<int> a2 = A<bool>();
 // CHECK-ELIDE-NOTREE: no viable conversion from 'A<bool>' to 'A<int>'
 }
 
+namespace TypeAlias {
+template <int, int = 0> class A {};
+
+template <class T> using a = A<T::num, 0>;
+template <class T> using a = A<T::num>;
+
+template <class T> using A1 = A<T::num>;
+template <class T> using A1 = A<T::num + 0>;
+// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<T::num + 0>' vs 'A<T::num>')
+
+template <class T> using A2 = A<1 + T::num>;
+template <class T> using A2 = A<T::num + 1>;
+// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<T::num + 1>' vs 'A<1 + T::num>')
+
+template <class T> using A3 = A<(T::num)>;
+template <class T> using A3 = A<T::num>;
+// CHECK-ELIDE-NOTREE: error: type alias template redefinition with different types ('A<T::num>' vs 'A<(T::num)>')
+
+          template <class T> using A4 = A<(T::num)>;
+template <class T> using A4 = A<((T::num))>;
+// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<((T::num))>' vs 'A<(T::num)>')
+
+template <class T> using A5 = A<T::num, 1>;
+template <class T> using A5 = A<T::num>;
+// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<[...], (default) 0>' vs 'A<[...], 1>')
+
+template <class T> using A6 = A<T::num + 5, 1>;
+template <class T> using A6 = A<T::num + 5>;
+// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<[...], (default) 0>' vs 'A<[...], 1>')
+
+template <class T> using A7 = A<T::num, 1>;
+template <class T> using A7 = A<(T::num)>;
+// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<(T::num), (default) 0>' vs 'A<T::num, 1>')
+}
+
 // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.
 // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated.
 // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.





More information about the llvm-branch-commits mailing list