r213613 - Fix '&' printing for template arguments in parentheses in template diffing.

Richard Trieu rtrieu at google.com
Mon Jul 21 21:42:15 PDT 2014


Author: rtrieu
Date: Mon Jul 21 23:42:15 2014
New Revision: 213613

URL: http://llvm.org/viewvc/llvm-project?rev=213613&view=rev
Log:
Fix '&' printing for template arguments in parentheses in template diffing.

Modified:
    cfe/trunk/lib/AST/ASTDiagnostic.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=213613&r1=213612&r2=213613&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Mon Jul 21 23:42:15 2014
@@ -994,7 +994,8 @@ class TemplateDiff {
           bool FromAddressOf = false;
           if (FromValueDecl) {
             if (FromExpr) {
-              if (UnaryOperator *UO = dyn_cast<UnaryOperator>(FromExpr)) {
+              if (UnaryOperator *UO =
+                      dyn_cast<UnaryOperator>(FromExpr->IgnoreParens())) {
                 if (UO->getOpcode() == UO_AddrOf)
                   FromAddressOf = true;
               }
@@ -1007,14 +1008,16 @@ class TemplateDiff {
           bool ToAddressOf = false;
           if (ToValueDecl) {
             if (ToExpr) {
-              if (UnaryOperator *UO = dyn_cast<UnaryOperator>(ToExpr)) {
+              if (UnaryOperator *UO =
+                      dyn_cast<UnaryOperator>(ToExpr->IgnoreParens())) {
                 if (UO->getOpcode() == UO_AddrOf) {
                   ToAddressOf = true;
                 }
               }
             } else {
-              if (!ArgumentType->isReferenceType())
+              if (!ArgumentType->isReferenceType()) {
                 ToAddressOf = true;
+              }
             }
           }
           Tree.SetNode(FromValueDecl, ToValueDecl, FromAddressOf, ToAddressOf);

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=213613&r1=213612&r2=213613&view=diff
==============================================================================
--- cfe/trunk/test/Misc/diag-template-diffing.cpp (original)
+++ cfe/trunk/test/Misc/diag-template-diffing.cpp Mon Jul 21 23:42:15 2014
@@ -1120,9 +1120,13 @@ Wrapper<S<ptr>> W = MakeWrapper<S<&globa
 // Don't print an extra '&' for 'ptr'
 // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<ptr>>'
 
-Wrapper<S<(&global2)>> W2 = MakeWrapper<S<&global>>();
 // Handle parens correctly
-// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<global2>>'
+Wrapper<S<(&global2)>> W2 = MakeWrapper<S<&global>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<&global2>>'
+Wrapper<S<&global2>> W3 = MakeWrapper<S<(&global)>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<&global2>>'
+Wrapper<S<(&global2)>> W4 = MakeWrapper<S<(&global)>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<&global2>>'
 }
 
 // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.





More information about the cfe-commits mailing list