From 1f993631af69af219f347517e956cf4f06036bf2 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Wed, 11 Dec 2013 23:40:50 +0000 Subject: [PATCH] Change semantics of regex expectations in the diagnostic verifier Previously, a line like // expected-error-re {{foo}} treats the entirety of foo as a regex. This is inconvenient when matching type names containing regex characters. For example, to match "void *(class test8::A::*)(void)" inside such a regex, one would have to type "void \*\(class test8::A::\*\)\(void\)". This patch changes the semantics of expected-error-re to only treat the parts of the directive wrapped in double curly braces as regexes. This avoids the escaping problem and leads to nicer patterns for those cases; see e.g. the change to test/Sema/format-strings-scanf.c. (The balanced search for closing }} of a directive also makes us handle the full directive in test\SemaCXX\constexpr-printing.cpp:41 and :53.) Differential Revision: http://llvm-reviews.chandlerc.com/D2388 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197092 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../clang/Basic/DiagnosticFrontendKinds.td | 2 + .../clang/Frontend/VerifyDiagnosticConsumer.h | 13 +-- lib/Frontend/VerifyDiagnosticConsumer.cpp | 97 +++++++++++++++++-- test/Analysis/analyzer-stats.c | 2 +- .../CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp | 2 +- test/CXX/drs/dr14xx.cpp | 2 +- test/CXX/special/class.copy/implicit-move.cpp | 10 +- test/Lexer/hexfloat.cpp | 2 +- test/Misc/verify.c | 10 +- test/Parser/attributes.mm | 4 +- test/Sema/format-strings-scanf.c | 4 +- test/Sema/ms-wchar.c | 4 +- test/Sema/thread-specifier.c | 12 +-- test/SemaCXX/addr-of-overloaded-function.cpp | 4 +- test/SemaCXX/member-expr.cpp | 4 +- test/SemaCXX/nested-name-spec.cpp | 2 +- test/SemaCXX/operator-arrow-depth.cpp | 4 +- test/SemaCXX/pr13394-crash-on-invalid.cpp | 2 +- test/SemaCXX/qualified-id-lookup.cpp | 2 +- test/SemaCXX/typo-correction-pt2.cpp | 16 +-- test/SemaCXX/typo-correction.cpp | 2 +- test/SemaTemplate/dependent-names.cpp | 4 +- .../ms-lookup-template-base-classes.cpp | 2 +- test/SemaTemplate/typename-specifier.cpp | 4 +- 24 files changed, 149 insertions(+), 61 deletions(-) diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td index bcf3c41cdb..65a11cbc66 100644 --- a/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/include/clang/Basic/DiagnosticFrontendKinds.td @@ -77,6 +77,8 @@ def err_verify_missing_end : Error< "cannot find end ('}}') of expected %0">; def err_verify_invalid_content : Error< "invalid expected %0: %1">; +def err_verify_missing_regex : Error< + "cannot find start of regex ('{{') in %0">; def err_verify_inconsistent_diags : Error< "'%0' diagnostics %select{expected|seen}1 but not %select{seen|expected}1: " "%2">; diff --git a/include/clang/Frontend/VerifyDiagnosticConsumer.h b/include/clang/Frontend/VerifyDiagnosticConsumer.h index 33d692a402..517c7374f0 100644 --- a/include/clang/Frontend/VerifyDiagnosticConsumer.h +++ b/include/clang/Frontend/VerifyDiagnosticConsumer.h @@ -108,10 +108,11 @@ class FileEntry; /// /// In this example, the diagnostic may appear only once, if at all. /// -/// Regex matching mode may be selected by appending '-re' to type, such as: +/// Regex matching mode may be selected by appending '-re' to type and +/// including regexes wrapped in double curly braces in the directive, such as: /// /// \code -/// expected-error-re +/// expected-error-re {{format specifies type 'wchar_t **' (aka '{{.+}}')}} /// \endcode /// /// Examples matching error: "variable has incomplete type 'struct s'" @@ -120,10 +121,10 @@ class FileEntry; /// // expected-error {{variable has incomplete type 'struct s'}} /// // expected-error {{variable has incomplete type}} /// -/// // expected-error-re {{variable has has type 'struct .'}} -/// // expected-error-re {{variable has has type 'struct .*'}} -/// // expected-error-re {{variable has has type 'struct (.*)'}} -/// // expected-error-re {{variable has has type 'struct[[:space:]](.*)'}} +/// // expected-error-re {{variable has type 'struct {{.}}'}} +/// // expected-error-re {{variable has type 'struct {{.*}}'}} +/// // expected-error-re {{variable has type 'struct {{(.*)}}'}} +/// // expected-error-re {{variable has type 'struct{{[[:space:]](.*)}}'}} /// \endcode /// /// VerifyDiagnosticConsumer expects at least one expected-* directive to diff --git a/lib/Frontend/VerifyDiagnosticConsumer.cpp b/lib/Frontend/VerifyDiagnosticConsumer.cpp index 77901a73e1..b53fde257d 100644 --- a/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -181,8 +181,8 @@ public: class RegexDirective : public Directive { public: RegexDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc, - StringRef Text, unsigned Min, unsigned Max) - : Directive(DirectiveLoc, DiagnosticLoc, Text, Min, Max), Regex(Text) { } + StringRef Text, unsigned Min, unsigned Max, StringRef RegexStr) + : Directive(DirectiveLoc, DiagnosticLoc, Text, Min, Max), Regex(RegexStr) { } virtual bool isValid(std::string &Error) { if (Regex.isValid(Error)) @@ -249,6 +249,30 @@ public: return false; } + // Return true if a CloseBrace that closes the OpenBrace at the current nest + // level is found. When true, P marks begin-position of CloseBrace. + bool SearchClosingBrace(StringRef OpenBrace, StringRef CloseBrace) { + unsigned Depth = 1; + P = C; + while (P < End) { + StringRef S(P, End - P); + if (S.startswith(OpenBrace)) { + ++Depth; + P += OpenBrace.size(); + } else if (S.startswith(CloseBrace)) { + --Depth; + if (Depth == 0) { + PEnd = P + CloseBrace.size(); + return true; + } + P += CloseBrace.size(); + } else { + ++P; + } + } + return false; + } + // Advance 1-past previous next/search. // Behavior is undefined if previous next/search failed. bool Advance() { @@ -437,7 +461,7 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM, const char* const ContentBegin = PH.C; // mark content begin // Search for token: }} - if (!PH.Search("}}")) { + if (!PH.SearchClosingBrace("{{", "}}")) { Diags.Report(Pos.getLocWithOffset(PH.C-PH.Begin), diag::err_verify_missing_end) << KindStr; continue; @@ -459,6 +483,13 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM, if (Text.empty()) Text.assign(ContentBegin, ContentEnd); + // Check that regex directives contain at least one regex. + if (RegexKind && Text.find("{{") == StringRef::npos) { + Diags.Report(Pos.getLocWithOffset(ContentBegin-PH.Begin), + diag::err_verify_missing_regex) << Text; + return false; + } + // Construct new directive. Directive *D = Directive::create(RegexKind, Pos, ExpectedLoc, Text, Min, Max); @@ -820,10 +851,64 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { ED.Notes.clear(); } +// Add the characters from FixedStr to RegexStr, escaping as needed. This +// avoids the need for backslash-escaping in common patterns. +static void AddFixedStringToRegEx(StringRef FixedStr, std::string &RegexStr) { + // FIXME: Expose FileCheck.cpp's Pattern::AddFixedStringToRegEx as a utility + // method in RegEx. + + for (unsigned i = 0, e = FixedStr.size(); i != e; ++i) { + switch (FixedStr[i]) { + // These are the special characters matched in "p_ere_exp". + case '(': + case ')': + case '^': + case '$': + case '|': + case '*': + case '+': + case '?': + case '.': + case '[': + case '\\': + case '{': + RegexStr += '\\'; + // FALL THROUGH. + default: + RegexStr += FixedStr[i]; + break; + } + } +} + Directive *Directive::create(bool RegexKind, SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc, StringRef Text, unsigned Min, unsigned Max) { - if (RegexKind) - return new RegexDirective(DirectiveLoc, DiagnosticLoc, Text, Min, Max); - return new StandardDirective(DirectiveLoc, DiagnosticLoc, Text, Min, Max); + if (!RegexKind) + return new StandardDirective(DirectiveLoc, DiagnosticLoc, Text, Min, Max); + + // Parse the directive into a regular expression. + std::string RegexStr; + StringRef S = Text; + while (!S.empty()) { + if (S.startswith("{{")) { + S = S.drop_front(2); + size_t RegexMatchLength = S.find("}}"); + assert(RegexMatchLength != StringRef::npos); + // Append the regex, enclosed in parentheses. + RegexStr += "("; + RegexStr.append(S.data(), RegexMatchLength); + RegexStr += ")"; + S = S.drop_front(RegexMatchLength + 2); + } else { + size_t VerbatimMatchLength = S.find("{{"); + if (VerbatimMatchLength == StringRef::npos) + VerbatimMatchLength = S.size(); + // Escape and append the fixed string. + AddFixedStringToRegEx(S.substr(0, VerbatimMatchLength), RegexStr); + S = S.drop_front(VerbatimMatchLength); + } + } + + return new RegexDirective(DirectiveLoc, DiagnosticLoc, Text, Min, Max, RegexStr); } diff --git a/test/Analysis/analyzer-stats.c b/test/Analysis/analyzer-stats.c index 63073b7e40..a0a50cbc93 100644 --- a/test/Analysis/analyzer-stats.c +++ b/test/Analysis/analyzer-stats.c @@ -2,7 +2,7 @@ int foo(); -int test() { // expected-warning-re{{test -> Total CFGBlocks: [0-9]+ \| Unreachable CFGBlocks: 0 \| Exhausted Block: no \| Empty WorkList: yes}} +int test() { // expected-warning-re{{test -> Total CFGBlocks: {{[0-9]+}} | Unreachable CFGBlocks: 0 | Exhausted Block: no | Empty WorkList: yes}} int a = 1; a = 34 / 12; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp index cf422972a2..7aa3b2f8ac 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp @@ -27,7 +27,7 @@ void f2(constexpr int i) {} // expected-error {{function parameter cannot be con struct s2 { constexpr int mi1; // expected-error {{non-static data member cannot be constexpr; did you intend to make it const?}} static constexpr int mi2; // expected-error {{requires an initializer}} - mutable constexpr int mi3 = 3; // expected-error-re {{non-static data member cannot be constexpr$}} expected-error {{'mutable' and 'const' cannot be mixed}} + mutable constexpr int mi3 = 3; // expected-error-re {{non-static data member cannot be constexpr{{$}}}} expected-error {{'mutable' and 'const' cannot be mixed}} }; // typedef typedef constexpr int CI; // expected-error {{typedef cannot be constexpr}} diff --git a/test/CXX/drs/dr14xx.cpp b/test/CXX/drs/dr14xx.cpp index 48487b5235..8de1b8d623 100644 --- a/test/CXX/drs/dr14xx.cpp +++ b/test/CXX/drs/dr14xx.cpp @@ -84,7 +84,7 @@ namespace dr1460 { // dr1460: 3.5 #if __cplusplus > 201103L template constexpr bool check() { - T t; // expected-note-re 2{{non-constexpr constructor '[BE]'}} + T t; // expected-note-re 2{{non-constexpr constructor '{{[BE]}}'}} return true; } static_assert(check(), ""); diff --git a/test/CXX/special/class.copy/implicit-move.cpp b/test/CXX/special/class.copy/implicit-move.cpp index 23ecf2e7d9..a10d139fe3 100644 --- a/test/CXX/special/class.copy/implicit-move.cpp +++ b/test/CXX/special/class.copy/implicit-move.cpp @@ -258,8 +258,8 @@ namespace DR1402 { template struct F : - E, // expected-note-re 2{{'[BD]' is a virtual base class of base class 'E<}} - E {}; // expected-note-re 2{{'[BD]' is a virtual base class of base class 'E<}} + E, // expected-note-re 2{{'{{[BD]}}' is a virtual base class of base class 'E<}} + E {}; // expected-note-re 2{{'{{[BD]}}' is a virtual base class of base class 'E<}} template struct G : E, E {}; @@ -272,11 +272,11 @@ namespace DR1402 { template struct J : - E, // expected-note-re 2{{'[BD]' is a virtual base class of base class 'E<}} - virtual T {}; // expected-note-re 2{{virtual base class '[BD]' declared here}} + E, // expected-note-re 2{{'{{[BD]}}' is a virtual base class of base class 'E<}} + virtual T {}; // expected-note-re 2{{virtual base class '{{[BD]}}' declared here}} template void move(T t) { t = static_cast(t); } - // expected-warning-re@-1 4{{defaulted move assignment operator of .* will move assign virtual base class '[BD]' multiple times}} + // expected-warning-re@-1 4{{defaulted move assignment operator of {{.*}} will move assign virtual base class '{{[BD]}}' multiple times}} template void move(F); template void move(F); // expected-note {{in instantiation of}} template void move(F); diff --git a/test/Lexer/hexfloat.cpp b/test/Lexer/hexfloat.cpp index 9bd8f830f0..bd53d4a89e 100644 --- a/test/Lexer/hexfloat.cpp +++ b/test/Lexer/hexfloat.cpp @@ -12,4 +12,4 @@ double h = 0x1.p2; // expected-warning{{hexadecimal floating constants are a C99 double i = 0p+3; // expected-error{{invalid suffix 'p' on integer constant}} #define PREFIX(x) foo ## x double foo0p = 1, j = PREFIX(0p+3); // ok -double k = 0x42_amp+3; // expected-error-re{{invalid suffix '_amp' on integer constant|no matching literal operator for call to 'operator "" _amp'}} +double k = 0x42_amp+3; // expected-error-re{{{{invalid suffix '_amp' on integer constant|no matching literal operator for call to 'operator "" _amp'}}}} diff --git a/test/Misc/verify.c b/test/Misc/verify.c index 85b034e957..9fe83e122e 100644 --- a/test/Misc/verify.c +++ b/test/Misc/verify.c @@ -7,8 +7,8 @@ struct s s1; // expected-error {{tentative definition has type 'struct s' that i struct s s2; // expected-error {{tentative definition has type}} // regex matching -struct s r1; // expected-error-re {{tentative definition has type 'struct s' that is never completed}} -struct s r2; // expected-error-re {{tentative definition has type '.*[[:space:]]*.*' that is never completed}} -struct s r3; // expected-error-re {{tentative definition has type '(.*)[[:space:]]*(.*)' that is never completed}} -struct s r4; // expected-error-re {{^tentative}} -struct s r5; // expected-error-re {{completed$}} +struct s r1; // expected-error {{tentative definition has type 'struct s' that is never completed}} +struct s r2; // expected-error-re {{tentative definition has type '{{.*[[:space:]]*.*}}' that is never completed}} +struct s r3; // expected-error-re {{tentative definition has type '{{(.*)[[:space:]]*(.*)}}' that is never completed}} +struct s r4; // expected-error-re {{{{^}}tentative}} +struct s r5; // expected-error-re {{completed{{$}}}} diff --git a/test/Parser/attributes.mm b/test/Parser/attributes.mm index d92e3d35cf..024606bed3 100644 --- a/test/Parser/attributes.mm +++ b/test/Parser/attributes.mm @@ -14,11 +14,11 @@ EXP class C2 {}; // expected-warning {{attribute 'visibility' is ignored, place @interface EXP I @end // expected-error {{postfix attributes are not allowed on Objective-C directives, place them in front of '@interface'}} EXP @interface I2 @end -@implementation EXP I @end // expected-error-re {{postfix attributes are not allowed on Objective-C directives$}} +@implementation EXP I @end // expected-error-re {{postfix attributes are not allowed on Objective-C directives{{$}}}} // FIXME: Prefix attribute recovery skips until ';' EXP @implementation I2 @end; // expected-error {{prefix attribute must be followed by an interface or protocol}} -@class EXP OC; // expected-error-re {{postfix attributes are not allowed on Objective-C directives$}} +@class EXP OC; // expected-error-re {{postfix attributes are not allowed on Objective-C directives{{$}}}} EXP @class OC2; // expected-error {{prefix attribute must be followed by an interface or protocol}} @protocol EXP P @end // expected-error {{postfix attributes are not allowed on Objective-C directives, place them in front of '@protocol'}} diff --git a/test/Sema/format-strings-scanf.c b/test/Sema/format-strings-scanf.c index d66bed5ffb..381447c84a 100644 --- a/test/Sema/format-strings-scanf.c +++ b/test/Sema/format-strings-scanf.c @@ -107,9 +107,9 @@ void test_alloc_extension(char **sp, wchar_t **lsp, float *fp) { // Test argument type check for the 'm' length modifier. scanf("%ms", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}} - scanf("%mS", fp); // expected-warning-re{{format specifies type 'wchar_t \*\*' \(aka '[^']+'\) but the argument has type 'float \*'}} + scanf("%mS", fp); // expected-warning-re{{format specifies type 'wchar_t **' (aka '{{[^']+}}') but the argument has type 'float *'}} scanf("%mc", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}} - scanf("%mC", fp); // expected-warning-re{{format specifies type 'wchar_t \*\*' \(aka '[^']+'\) but the argument has type 'float \*'}} + scanf("%mC", fp); // expected-warning-re{{format specifies type 'wchar_t **' (aka '{{[^']+}}') but the argument has type 'float *'}} scanf("%m[abc]", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}} } diff --git a/test/Sema/ms-wchar.c b/test/Sema/ms-wchar.c index febaf283b3..ead3d974d3 100644 --- a/test/Sema/ms-wchar.c +++ b/test/Sema/ms-wchar.c @@ -12,7 +12,7 @@ __wchar_t g = L'a'; // expected-note {{previous}} unsigned short g; // expected-error {{redefinition of 'g' with a different type: 'unsigned short' vs '__wchar_t'}} // The type of a wide string literal is actually not __wchar_t. -__wchar_t s[] = L"Hello world!"; // expected-error-re {{array initializer must be an initializer list$}} +__wchar_t s[] = L"Hello world!"; // expected-error-re {{array initializer must be an initializer list{{$}}}} // Do not suggest initializing with a string here, because it would not work. -__wchar_t t[] = 1; // expected-error-re {{array initializer must be an initializer list$}} +__wchar_t t[] = 1; // expected-error-re {{array initializer must be an initializer list{{$}}}} diff --git a/test/Sema/thread-specifier.c b/test/Sema/thread-specifier.c index bf1ce9e26e..39243d1a76 100644 --- a/test/Sema/thread-specifier.c +++ b/test/Sema/thread-specifier.c @@ -21,7 +21,7 @@ __thread static int t3; __thread __private_extern__ int t4; struct t5 { __thread int x; }; #ifdef __cplusplus -// expected-error-re@-2 {{'(__thread|_Thread_local|thread_local)' is only allowed on variable declarations}} +// expected-error-re@-2 {{'{{__thread|_Thread_local|thread_local}}' is only allowed on variable declarations}} #else // FIXME: The 'is only allowed on variable declarations' diagnostic is better here. // expected-error@-5 {{type name does not allow storage class to be specified}} @@ -47,17 +47,17 @@ int f(__thread int t7) { // expected-error {{' is only allowed on variable decla static __thread int t10; __thread __private_extern__ int t11; #if __cplusplus < 201103L - __thread auto int t12a; // expected-error-re {{cannot combine with previous '(__thread|_Thread_local)' declaration specifier}} + __thread auto int t12a; // expected-error-re {{cannot combine with previous '{{__thread|_Thread_local}}' declaration specifier}} auto __thread int t12b; // expected-error {{cannot combine with previous 'auto' declaration specifier}} #elif !defined(CXX11) - __thread auto t12a = 0; // expected-error-re {{'_Thread_local' variables must have global storage}} - auto __thread t12b = 0; // expected-error-re {{'_Thread_local' variables must have global storage}} + __thread auto t12a = 0; // expected-error {{'_Thread_local' variables must have global storage}} + auto __thread t12b = 0; // expected-error {{'_Thread_local' variables must have global storage}} #endif - __thread register int t13a; // expected-error-re {{cannot combine with previous '(__thread|_Thread_local|thread_local)' declaration specifier}} + __thread register int t13a; // expected-error-re {{cannot combine with previous '{{__thread|_Thread_local|thread_local}}' declaration specifier}} register __thread int t13b; // expected-error {{cannot combine with previous 'register' declaration specifier}} } -__thread typedef int t14; // expected-error-re {{cannot combine with previous '(__thread|_Thread_local|thread_local)' declaration specifier}} +__thread typedef int t14; // expected-error-re {{cannot combine with previous '{{__thread|_Thread_local|thread_local}}' declaration specifier}} __thread int t15; // expected-note {{previous declaration is here}} extern int t15; // expected-error {{non-thread-local declaration of 't15' follows thread-local declaration}} extern int t16; // expected-note {{previous declaration is here}} diff --git a/test/SemaCXX/addr-of-overloaded-function.cpp b/test/SemaCXX/addr-of-overloaded-function.cpp index 230a1eb994..12cc4ed969 100644 --- a/test/SemaCXX/addr-of-overloaded-function.cpp +++ b/test/SemaCXX/addr-of-overloaded-function.cpp @@ -84,7 +84,7 @@ struct C { void h() { // Do not suggest '()' since an int argument is required - q1; // expected-error-re{{reference to non-static member function must be called$}} + q1; // expected-error-re{{reference to non-static member function must be called{{$}}}} // Suggest '()' since there's a default value for the only argument & the // type argument is already provided q2; // expected-error{{reference to non-static member function must be called; did you mean to call it with no arguments?}} @@ -92,7 +92,7 @@ struct C { // already provided q3; // expected-error{{reference to non-static member function must be called; did you mean to call it with no arguments?}} // Do not suggest '()' since another type argument is required - q4; // expected-error-re{{reference to non-static member function must be called$}} + q4; // expected-error-re{{reference to non-static member function must be called{{$}}}} // Suggest '()' since the type parameter has a default value q5; // expected-error{{reference to non-static member function must be called; did you mean to call it with no arguments?}} } diff --git a/test/SemaCXX/member-expr.cpp b/test/SemaCXX/member-expr.cpp index 239aecff81..e0955aeb9c 100644 --- a/test/SemaCXX/member-expr.cpp +++ b/test/SemaCXX/member-expr.cpp @@ -193,7 +193,7 @@ namespace PR15045 { }; template void call_func(T t) { - t->func(); // expected-error-re 2 {{member reference type 'PR15045::bar' is not a pointer$}} \ + t->func(); // expected-error-re 2 {{member reference type 'PR15045::bar' is not a pointer{{$}}}} \ // expected-note {{did you mean to use '.' instead?}} } @@ -207,7 +207,7 @@ namespace PR15045 { // Make sure a fixit isn't given in the case that the '->' isn't actually // the problem (the problem is with the return value of an operator->). - f->func(); // expected-error-re {{member reference type 'PR15045::bar' is not a pointer$}} + f->func(); // expected-error-re {{member reference type 'PR15045::bar' is not a pointer{{$}}}} call_func(e); // expected-note {{in instantiation of function template specialization 'PR15045::call_func' requested here}} diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp index f1f9bbb507..a0bac059a2 100644 --- a/test/SemaCXX/nested-name-spec.cpp +++ b/test/SemaCXX/nested-name-spec.cpp @@ -143,7 +143,7 @@ namespace A { void g(int&); // expected-note{{type of 1st parameter of member declaration does not match definition ('int &' vs 'const int &')}} } -void A::f() {} // expected-error-re{{out-of-line definition of 'f' does not match any declaration in namespace 'A'$}} +void A::f() {} // expected-error-re{{out-of-line definition of 'f' does not match any declaration in namespace 'A'{{$}}}} void A::g(const int&) { } // expected-error{{out-of-line definition of 'g' does not match any declaration in namespace 'A'}} diff --git a/test/SemaCXX/operator-arrow-depth.cpp b/test/SemaCXX/operator-arrow-depth.cpp index 3e2ba8e452..769dae0d24 100644 --- a/test/SemaCXX/operator-arrow-depth.cpp +++ b/test/SemaCXX/operator-arrow-depth.cpp @@ -9,7 +9,7 @@ template struct A { template struct B { A operator->(); // expected-note +{{'operator->' declared here produces an object of type 'A<}} #if MAX != 2 - // expected-note-re@-2 {{(skipping (120|2) 'operator->'s in backtrace)}} + // expected-note-re@-2 {{(skipping {{120|2}} 'operator->'s in backtrace)}} #endif }; @@ -22,5 +22,5 @@ A good; int n = good->n; B bad; -int m = bad->n; // expected-error-re {{use of 'operator->' on type 'B<(2|10|128) / 2 \+ 1>' would invoke a sequence of more than (2|10|128) 'operator->' calls}} +int m = bad->n; // expected-error-re {{use of 'operator->' on type 'B<{{2|10|128}} / 2 + 1>' would invoke a sequence of more than {{2|10|128}} 'operator->' calls}} // expected-note@-1 {{use -foperator-arrow-depth=N to increase 'operator->' limit}} diff --git a/test/SemaCXX/pr13394-crash-on-invalid.cpp b/test/SemaCXX/pr13394-crash-on-invalid.cpp index 841e3c2034..42b6508c71 100644 --- a/test/SemaCXX/pr13394-crash-on-invalid.cpp +++ b/test/SemaCXX/pr13394-crash-on-invalid.cpp @@ -13,7 +13,7 @@ namespace gatekeeper_v1 { }; } // FIXME: Typo correction should remove the 'gatekeeper_v1::' name specifier - gatekeeper_v1::closure_t *x; // expected-error-re {{no type named 'closure_t' in namespace 'gatekeeper_v1'$}} + gatekeeper_v1::closure_t *x; // expected-error-re {{no type named 'closure_t' in namespace 'gatekeeper_v1'{{$}}}} } namespace Foo { diff --git a/test/SemaCXX/qualified-id-lookup.cpp b/test/SemaCXX/qualified-id-lookup.cpp index 23164fa42f..8eef6f4182 100644 --- a/test/SemaCXX/qualified-id-lookup.cpp +++ b/test/SemaCXX/qualified-id-lookup.cpp @@ -94,7 +94,7 @@ namespace a { void test_a() { a::a::i = 3; // expected-error{{no member named 'i' in namespace 'a::a'; did you mean 'a::a::a::i'?}} a::a::a::i = 4; - a::a::j = 3; // expected-error-re{{no member named 'j' in namespace 'a::a'$}} + a::a::j = 3; // expected-error-re{{no member named 'j' in namespace 'a::a'{{$}}}} } struct Undef { // expected-note{{definition of 'Undef' is not complete until the closing '}'}} diff --git a/test/SemaCXX/typo-correction-pt2.cpp b/test/SemaCXX/typo-correction-pt2.cpp index 2da52b31f5..bb5e8f8c93 100644 --- a/test/SemaCXX/typo-correction-pt2.cpp +++ b/test/SemaCXX/typo-correction-pt2.cpp @@ -7,8 +7,8 @@ namespace bogus_keyword_suggestion { void test() { - status = "OK"; // expected-error-re {{use of undeclared identifier 'status'$}} - return status; // expected-error-re {{use of undeclared identifier 'status'$}} + status = "OK"; // expected-error-re {{use of undeclared identifier 'status'{{$}}}} + return status; // expected-error-re {{use of undeclared identifier 'status'{{$}}}} } } @@ -33,7 +33,7 @@ struct T { }; // should be void T::f(); void f() { - data_struct->foo(); // expected-error-re{{use of undeclared identifier 'data_struct'$}} + data_struct->foo(); // expected-error-re{{use of undeclared identifier 'data_struct'{{$}}}} } namespace PR12287 { @@ -116,9 +116,9 @@ public: void testAccess() { Figure obj; switch (obj.type()) { // expected-warning {{enumeration values 'SQUARE', 'TRIANGLE', and 'CIRCLE' not handled in switch}} - case SQUARE: // expected-error-re {{use of undeclared identifier 'SQUARE'$}} - case TRIANGLE: // expected-error-re {{use of undeclared identifier 'TRIANGLE'$}} - case CIRCE: // expected-error-re {{use of undeclared identifier 'CIRCE'$}} + case SQUARE: // expected-error-re {{use of undeclared identifier 'SQUARE'{{$}}}} + case TRIANGLE: // expected-error-re {{use of undeclared identifier 'TRIANGLE'{{$}}}} + case CIRCE: // expected-error-re {{use of undeclared identifier 'CIRCE'{{$}}}} break; } } @@ -126,13 +126,13 @@ void testAccess() { long readline(const char *, char *, unsigned long); void assign_to_unknown_var() { - deadline_ = 1; // expected-error-re {{use of undeclared identifier 'deadline_'$}} + deadline_ = 1; // expected-error-re {{use of undeclared identifier 'deadline_'{{$}}}} } namespace no_ns_before_dot { namespace re2 {} void test() { - req.set_check(false); // expected-error-re {{use of undeclared identifier 'req'$}} + req.set_check(false); // expected-error-re {{use of undeclared identifier 'req'{{$}}}} } } diff --git a/test/SemaCXX/typo-correction.cpp b/test/SemaCXX/typo-correction.cpp index 4047e6a18c..8dbedd2dc4 100644 --- a/test/SemaCXX/typo-correction.cpp +++ b/test/SemaCXX/typo-correction.cpp @@ -299,6 +299,6 @@ namespace CorrectTypo_has_reached_its_limit { int flibberdy(); // expected-note{{'flibberdy' declared here}} int no_correction() { return hibberdy() + // expected-error{{use of undeclared identifier 'hibberdy'; did you mean 'flibberdy'?}} - gibberdy(); // expected-error-re{{use of undeclared identifier 'gibberdy'$}} + gibberdy(); // expected-error-re{{use of undeclared identifier 'gibberdy'{{$}}}} }; } diff --git a/test/SemaTemplate/dependent-names.cpp b/test/SemaTemplate/dependent-names.cpp index 4d4aafa918..5a25030803 100644 --- a/test/SemaTemplate/dependent-names.cpp +++ b/test/SemaTemplate/dependent-names.cpp @@ -232,7 +232,7 @@ namespace PR10053 { struct Data {}; } - std::ostream &print(std::ostream &out, int); // expected-note-re {{should be declared prior to the call site$}} + std::ostream &print(std::ostream &out, int); // expected-note-re {{should be declared prior to the call site{{$}}}} std::ostream &print(std::ostream &out, ns::Data); // expected-note {{should be declared prior to the call site or in namespace 'PR10053::my_file2_a::ns'}} std::ostream &print(std::ostream &out, std::vector); // expected-note {{should be declared prior to the call site or in namespace 'PR10053::my_file2_a::ns2'}} std::ostream &print(std::ostream &out, std::pair); // expected-note {{should be declared prior to the call site or in an associated namespace of one of its arguments}} @@ -397,5 +397,5 @@ namespace OperatorNew { struct X {}; }; using size_t = decltype(sizeof(0)); -void *operator new(size_t, OperatorNew::X); // expected-note-re {{should be declared prior to the call site$}} +void *operator new(size_t, OperatorNew::X); // expected-note-re {{should be declared prior to the call site{{$}}}} template void OperatorNew::f(OperatorNew::X); // expected-note {{instantiation of}} diff --git a/test/SemaTemplate/ms-lookup-template-base-classes.cpp b/test/SemaTemplate/ms-lookup-template-base-classes.cpp index 5a56cb2ea3..e956cd11c5 100644 --- a/test/SemaTemplate/ms-lookup-template-base-classes.cpp +++ b/test/SemaTemplate/ms-lookup-template-base-classes.cpp @@ -222,7 +222,7 @@ template struct C : T { }; template struct B; -template struct C; // expected-note-re 1+ {{in instantiation of member function 'PR16014::C::.*' requested here}} +template struct C; // expected-note-re 1+ {{in instantiation of member function 'PR16014::C::{{.*}}' requested here}} template struct D : T { struct Inner { diff --git a/test/SemaTemplate/typename-specifier.cpp b/test/SemaTemplate/typename-specifier.cpp index 733dc7fa18..6bd567f6ae 100644 --- a/test/SemaTemplate/typename-specifier.cpp +++ b/test/SemaTemplate/typename-specifier.cpp @@ -137,8 +137,8 @@ class ExampleClass1 { void foo() { pair i; // expected-error {{template argument for template type parameter must be a type; did you forget 'typename'?}} - pairExampleItemSet::iterator, int> i; // expected-error-re {{template argument for template type parameter must be a type$}} - pair i; // expected-error-re {{template argument for template type parameter must be a type$}} + pairExampleItemSet::iterator, int> i; // expected-error-re {{template argument for template type parameter must be a type{{$}}}} + pair i; // expected-error-re {{template argument for template type parameter must be a type{{$}}}} } pair elt; // expected-error {{template argument for template type parameter must be a type; did you forget 'typename'?}} -- 2.40.0