From 95dcc5d2fd3e8965b789de600f7ce0bf179abb20 Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Tue, 22 Jul 2014 04:42:15 +0000 Subject: [PATCH] Fix '&' printing for template arguments in parentheses in template diffing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213613 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTDiagnostic.cpp | 9 ++++++--- test/Misc/diag-template-diffing.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/AST/ASTDiagnostic.cpp b/lib/AST/ASTDiagnostic.cpp index 20540f3ce1..5f78df2c47 100644 --- a/lib/AST/ASTDiagnostic.cpp +++ b/lib/AST/ASTDiagnostic.cpp @@ -994,7 +994,8 @@ class TemplateDiff { bool FromAddressOf = false; if (FromValueDecl) { if (FromExpr) { - if (UnaryOperator *UO = dyn_cast(FromExpr)) { + if (UnaryOperator *UO = + dyn_cast(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(ToExpr)) { + if (UnaryOperator *UO = + dyn_cast(ToExpr->IgnoreParens())) { if (UO->getOpcode() == UO_AddrOf) { ToAddressOf = true; } } } else { - if (!ArgumentType->isReferenceType()) + if (!ArgumentType->isReferenceType()) { ToAddressOf = true; + } } } Tree.SetNode(FromValueDecl, ToValueDecl, FromAddressOf, ToAddressOf); diff --git a/test/Misc/diag-template-diffing.cpp b/test/Misc/diag-template-diffing.cpp index 391915ee97..fcafb33256 100644 --- a/test/Misc/diag-template-diffing.cpp +++ b/test/Misc/diag-template-diffing.cpp @@ -1120,9 +1120,13 @@ Wrapper> W = MakeWrapper>(); // Don't print an extra '&' for 'ptr' // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper>' to 'Wrapper>' -Wrapper> W2 = MakeWrapper>(); // Handle parens correctly -// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper>' to 'Wrapper>' +Wrapper> W2 = MakeWrapper>(); +// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper>' to 'Wrapper>' +Wrapper> W3 = MakeWrapper>(); +// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper>' to 'Wrapper>' +Wrapper> W4 = MakeWrapper>(); +// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper>' to 'Wrapper>' } // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated. -- 2.40.0