[llvm-branch-commits] [cfe-branch] r214690 - Merging r213609:

Bill Wendling isanbard at gmail.com
Sun Aug 3 21:34:27 PDT 2014


Author: void
Date: Sun Aug  3 23:34:27 2014
New Revision: 214690

URL: http://llvm.org/viewvc/llvm-project?rev=214690&view=rev
Log:
Merging r213609:
------------------------------------------------------------------------
r213609 | rtrieu | 2014-07-21 20:33:01 -0700 (Mon, 21 Jul 2014) | 3 lines

Fix a template diffing problem were an '&' is unexpectedly printed in
a template argument.

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

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:34:27 2014
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:213741,213993,213998,214208
+/cfe/trunk:213609,213741,213993,213998,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=214690&r1=214689&r2=214690&view=diff
==============================================================================
--- cfe/branches/release_35/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/branches/release_35/lib/AST/ASTDiagnostic.cpp Sun Aug  3 23:34:27 2014
@@ -991,12 +991,32 @@ class TemplateDiff {
           if (!HasToValueDecl && ToExpr)
             ToValueDecl = GetValueDecl(ToIter, ToExpr);
           QualType ArgumentType = DefaultNTTPD->getType();
-          bool FromAddressOf = FromValueDecl &&
-                               !ArgumentType->isReferenceType() &&
-                               !FromValueDecl->getType()->isArrayType();
-          bool ToAddressOf = ToValueDecl &&
-                             !ArgumentType->isReferenceType() &&
-                             !ToValueDecl->getType()->isArrayType();
+          bool FromAddressOf = false;
+          if (FromValueDecl) {
+            if (FromExpr) {
+              if (UnaryOperator *UO = dyn_cast<UnaryOperator>(FromExpr)) {
+                if (UO->getOpcode() == UO_AddrOf)
+                  FromAddressOf = true;
+              }
+            } else {
+              if (!ArgumentType->isReferenceType()) {
+                FromAddressOf = true;
+              }
+            }
+          }
+          bool ToAddressOf = false;
+          if (ToValueDecl) {
+            if (ToExpr) {
+              if (UnaryOperator *UO = dyn_cast<UnaryOperator>(ToExpr)) {
+                if (UO->getOpcode() == UO_AddrOf) {
+                  ToAddressOf = true;
+                }
+              }
+            } else {
+              if (!ArgumentType->isReferenceType())
+                ToAddressOf = true;
+            }
+          }
           Tree.SetNode(FromValueDecl, ToValueDecl, FromAddressOf, ToAddressOf);
           Tree.SetSame(FromValueDecl && ToValueDecl &&
                        FromValueDecl->getCanonicalDecl() ==

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=214690&r1=214689&r2=214690&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:34:27 2014
@@ -1105,6 +1105,22 @@ using F = C<21 + 21>;
 }
 }
 
+namespace AddressOf {
+template <int*>
+struct S {};
+
+template <class T>
+struct Wrapper {};
+
+template <class T>
+Wrapper<T> MakeWrapper();
+int global;
+constexpr int * ptr = nullptr;
+Wrapper<S<ptr>> W = MakeWrapper<S<&global>>();
+// Don't print an extra '&' for 'ptr'
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<ptr>>'
+}
+
 // 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