From 12074509d707d99c767e0d987cfd14c9cdf1963f Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Tue, 2 Feb 2016 00:36:59 +0000 Subject: [PATCH] Template Type Diffing change When all the arguments of a template are elided, print "A<...>" instead of "A<[2 * ...]>". Also remove comment fragment that means nothing. llvm-svn: 259445 --- clang/lib/AST/ASTDiagnostic.cpp | 12 ++++++-- clang/test/Misc/diag-template-diffing-color.cpp | 20 ++++++------- clang/test/Misc/diag-template-diffing-cxx98.cpp | 2 +- clang/test/Misc/diag-template-diffing.cpp | 38 +++++++++++-------------- 4 files changed, 34 insertions(+), 38 deletions(-) diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index 2ab5a32..62fbfdd 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -497,7 +497,7 @@ class TemplateDiff { enum DiffKind { /// Incomplete or invalid node. Invalid, - /// Another level of templates, requires that + /// Another level of templates Template, /// Type difference, all type differences except those falling under /// the Template difference. @@ -1523,12 +1523,14 @@ class TemplateDiff { OS << FromTD->getNameAsString() << '<'; Tree.MoveToChild(); unsigned NumElideArgs = 0; + bool AllArgsElided = true; do { if (ElideType) { if (Tree.NodeIsSame()) { ++NumElideArgs; continue; } + AllArgsElided = false; if (NumElideArgs > 0) { PrintElideArgs(NumElideArgs, Indent); NumElideArgs = 0; @@ -1539,8 +1541,12 @@ class TemplateDiff { if (Tree.HasNextSibling()) OS << ", "; } while (Tree.AdvanceSibling()); - if (NumElideArgs > 0) - PrintElideArgs(NumElideArgs, Indent); + if (NumElideArgs > 0) { + if (AllArgsElided) + OS << "..."; + else + PrintElideArgs(NumElideArgs, Indent); + } Tree.Parent(); OS << ">"; diff --git a/clang/test/Misc/diag-template-diffing-color.cpp b/clang/test/Misc/diag-template-diffing-color.cpp index bf20315..2010344 100644 --- a/clang/test/Misc/diag-template-diffing-color.cpp +++ b/clang/test/Misc/diag-template-diffing-color.cpp @@ -34,42 +34,38 @@ void set16(vector >) {} void test16() { set16(vector >()); } -// CHECK: {{.*}}candidate function not viable: no known conversion from 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' to 'vector>' for 1st argument +// CHECK: {{.*}}candidate function not viable: no known conversion from 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<...>>' to 'vector>' for 1st argument // TREE: {{.*}}candidate function not viable: no known conversion from argument type to parameter type for 1st argument // TREE: vector< -// TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= [[CYAN]](no qualifiers){{ ?}}[[RESET]]]{{ ?}}vector< -// TREE: [...]>> +// TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= [[CYAN]](no qualifiers){{ ?}}[[RESET]]]{{ ?}}vector<...>> void set17(vector >) {} void test17() { set17(vector >()); } -// CHECK: candidate function not viable: no known conversion from 'vector>' to 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' for 1st argument +// CHECK: candidate function not viable: no known conversion from 'vector>' to 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<...>>' for 1st argument // TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // TREE: vector< -// TREE: {{\[}}[[CYAN]](no qualifiers){{ ?}}[[RESET]]{{ ?}}!= [[CYAN]]const[[RESET]]] vector< -// TREE: [...]>> +// TREE: {{\[}}[[CYAN]](no qualifiers){{ ?}}[[RESET]]{{ ?}}!= [[CYAN]]const[[RESET]]] vector<...>> void set18(vector >) {} void test18() { set18(vector >()); } -// CHECK: candidate function not viable: no known conversion from 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' to 'vector<[[CYAN]]volatile{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' for 1st argument +// CHECK: candidate function not viable: no known conversion from 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<...>>' to 'vector<[[CYAN]]volatile{{ ?}}[[RESET]]{{ ?}}vector<...>>' for 1st argument // TREE: no matching function for call to 'set18' // TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // TREE: vector< -// TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= [[CYAN]]volatile[[RESET]]] vector< -// TREE: [...]>> +// TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= [[CYAN]]volatile[[RESET]]] vector<...>> void set19(vector >) {} void test19() { set19(vector >()); } -// CHECK: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument +// CHECK: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument // TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // TREE: vector< -// TREE: [const != const [[CYAN]]volatile[[RESET]]] vector< -// TREE: [...]>> +// TREE: [const != const [[CYAN]]volatile[[RESET]]] vector<...>> namespace default_args { template diff --git a/clang/test/Misc/diag-template-diffing-cxx98.cpp b/clang/test/Misc/diag-template-diffing-cxx98.cpp index 9fa4612..7b1a08c 100644 --- a/clang/test/Misc/diag-template-diffing-cxx98.cpp +++ b/clang/test/Misc/diag-template-diffing-cxx98.cpp @@ -45,5 +45,5 @@ namespace qualifiers { foo(bar, V); } - // CHECK: candidate template ignored: deduced conflicting types for parameter 'T' ('const vector<[...]>' vs. 'volatile vector<[...]>') + // CHECK: candidate template ignored: deduced conflicting types for parameter 'T' ('const vector<...>' vs. 'volatile vector<...>') } diff --git a/clang/test/Misc/diag-template-diffing.cpp b/clang/test/Misc/diag-template-diffing.cpp index 70d5e7c..5e1caa5c 100644 --- a/clang/test/Misc/diag-template-diffing.cpp +++ b/clang/test/Misc/diag-template-diffing.cpp @@ -479,14 +479,13 @@ void test17() { set17(vector>()); } // CHECK-ELIDE-NOTREE: no matching function for call to 'set17' -// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument // CHECK-NOELIDE-NOTREE: no matching function for call to 'set17' // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument // CHECK-ELIDE-TREE: no matching function for call to 'set17' // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: vector< -// CHECK-ELIDE-TREE: [const != (no qualifiers)] vector< -// CHECK-ELIDE-TREE: [...]>> +// CHECK-ELIDE-TREE: [const != (no qualifiers)] vector<...>> // CHECK-NOELIDE-TREE: no matching function for call to 'set17' // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: vector< @@ -498,14 +497,13 @@ void test18() { set18(vector>()); } // CHECK-ELIDE-NOTREE: no matching function for call to 'set18' -// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument // CHECK-NOELIDE-NOTREE: no matching function for call to 'set18' // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument // CHECK-ELIDE-TREE: no matching function for call to 'set18' // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: vector< -// CHECK-ELIDE-TREE: [(no qualifiers) != const] vector< -// CHECK-ELIDE-TREE: [...]>> +// CHECK-ELIDE-TREE: [(no qualifiers) != const] vector<...>> // CHECK-NOELIDE-TREE: no matching function for call to 'set18' // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: vector< @@ -517,14 +515,13 @@ void test19() { set19(vector>()); } // CHECK-ELIDE-NOTREE: no matching function for call to 'set19' -// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument // CHECK-NOELIDE-NOTREE: no matching function for call to 'set19' // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument // CHECK-ELIDE-TREE: no matching function for call to 'set19' // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: vector< -// CHECK-ELIDE-TREE: [const != volatile] vector< -// CHECK-ELIDE-TREE: [...]>> +// CHECK-ELIDE-TREE: [const != volatile] vector<...>> // CHECK-NOELIDE-TREE: no matching function for call to 'set19' // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: vector< @@ -536,14 +533,13 @@ void test20() { set20(vector>()); } // CHECK-ELIDE-NOTREE: no matching function for call to 'set20' -// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument // CHECK-NOELIDE-NOTREE: no matching function for call to 'set20' // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument // CHECK-ELIDE-TREE: no matching function for call to 'set20' // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: vector< -// CHECK-ELIDE-TREE: [const != const volatile] vector< -// CHECK-ELIDE-TREE: [...]>> +// CHECK-ELIDE-TREE: [const != const volatile] vector<...>> // CHECK-NOELIDE-TREE: no matching function for call to 'set20' // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: vector< @@ -557,14 +553,13 @@ template using U21 = volatile S21; int f21(vector>); int k21 = f21(vector>()); // CHECK-ELIDE-NOTREE: no matching function for call to 'f21' -// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument // CHECK-NOELIDE-NOTREE: no matching function for call to 'f21' // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument // CHECK-ELIDE-TREE: no matching function for call to 'f21' // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: vector< -// CHECK-ELIDE-TREE: [(no qualifiers) != const] U21< -// CHECK-ELIDE-TREE: [...]>> +// CHECK-ELIDE-TREE: [(no qualifiers) != const] U21<...>> // CHECK-NOELIDE-TREE: no matching function for call to 'f21' // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: vector< @@ -577,14 +572,13 @@ template using U22 = volatile S22; int f22(vector>); int k22 = f22(vector>()); // CHECK-ELIDE-NOTREE: no matching function for call to 'f22' -// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument // CHECK-NOELIDE-NOTREE: no matching function for call to 'f22' // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector>' to 'vector>' for 1st argument // CHECK-ELIDE-TREE: no matching function for call to 'f22' // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: vector< -// CHECK-ELIDE-TREE: [(no qualifiers) != const] U22< -// CHECK-ELIDE-TREE: [...]>> +// CHECK-ELIDE-TREE: [(no qualifiers) != const] U22<...>> // CHECK-NOELIDE-TREE: no matching function for call to 'f22' // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: vector< @@ -1258,7 +1252,7 @@ using T = condition<(is_const())>; void foo(const T &t) { T &t2 = t; } -// CHECK-ELIDE-NOTREE: binding value of type 'const condition<[...]>' to reference to type 'condition<[...]>' drops 'const' qualifier +// CHECK-ELIDE-NOTREE: binding value of type 'const condition<...>' to reference to type 'condition<...>' drops 'const' qualifier } namespace BoolArgumentBitExtended { @@ -1390,7 +1384,7 @@ namespace DefaultNonTypeArgWithDependentType { template struct A {}; template > R bar(); A<> &foo() { return bar(); } -// CHECK-ELIDE-NOTREE: error: non-const lvalue reference to type 'A<[2 * ...]>' cannot bind to a temporary of type 'A<[2 * ...]>' +// CHECK-ELIDE-NOTREE: error: non-const lvalue reference to type 'A<...>' cannot bind to a temporary of type 'A<...>' // CHECK-NOELIDE-NOTREE: error: non-const lvalue reference to type 'A' cannot bind to a temporary of type 'A' } @@ -1423,8 +1417,8 @@ B> b4 = B<>(); // CHECK-ELIDE-NOTREE: error: no viable conversion from 'A<1>' to 'A<(default) 0>' // CHECK-ELIDE-NOTREE: error: no viable conversion from 'B' to 'B<(default) ZeroArgs::A<0>>' // CHECK-ELIDE-NOTREE: error: no viable conversion from 'B<(default) ZeroArgs::A<0>>' to 'B' -// CHECK-ELIDE-NOTREE: error: no viable conversion from 'B>' to 'B>' -// CHECK-ELIDE-NOTREE: error: no viable conversion from 'B>' to 'B>' +// CHECK-ELIDE-NOTREE: error: no viable conversion from 'B>' to 'B>' +// CHECK-ELIDE-NOTREE: error: no viable conversion from 'B>' to 'B>' } // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated. -- 2.7.4