diff options
author | Anna Zaks <ganna@apple.com> | 2011-12-15 02:28:16 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2011-12-15 02:28:16 +0000 |
commit | 2135ebb83179ee87910afdebc1bc091e17a7d1eb (patch) | |
tree | 33df03451f7e179e5fa30345167dfbb7491801c3 /lib/Frontend | |
parent | 62d829abaf61d70483a5a584059440a549a306bf (diff) |
Add support for matching one or more (aka regex +) diagnostic messages with -verify.
Ex:
// expected-warning + {{tainted}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146633 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r-- | lib/Frontend/VerifyDiagnosticConsumer.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Frontend/VerifyDiagnosticConsumer.cpp b/lib/Frontend/VerifyDiagnosticConsumer.cpp index 5eeb696582..ef5459c233 100644 --- a/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -82,6 +82,9 @@ public: static Directive* Create(bool RegexKind, const SourceLocation &Location, const std::string &Text, unsigned Count); public: + /// Constant representing one or more matches aka regex "+". + static const unsigned OneOrMoreCount = UINT_MAX; + SourceLocation Location; const std::string Text; unsigned Count; @@ -276,10 +279,14 @@ static void ParseDirective(const char *CommentStart, unsigned CommentLen, // skip optional whitespace PH.SkipWhitespace(); - // next optional token: positive integer + // next optional token: positive integer or a '+'. unsigned Count = 1; if (PH.Next(Count)) PH.Advance(); + else if (PH.Next("+")) { + Count = Directive::OneOrMoreCount; + PH.Advance(); + } // skip optional whitespace PH.SkipWhitespace(); @@ -420,6 +427,7 @@ static unsigned CheckLists(DiagnosticsEngine &Diags, SourceManager &SourceMgr, for (DirectiveList::iterator I = Left.begin(), E = Left.end(); I != E; ++I) { Directive& D = **I; unsigned LineNo1 = SourceMgr.getPresumedLineNumber(D.Location); + bool FoundOnce = false; for (unsigned i = 0; i < D.Count; ++i) { DiagList::iterator II, IE; @@ -433,11 +441,16 @@ static unsigned CheckLists(DiagnosticsEngine &Diags, SourceManager &SourceMgr, break; } if (II == IE) { + if (D.Count == D.OneOrMoreCount && FoundOnce) { + // We are only interested in at least one match and we found one. + break; + } // Not found. LeftOnly.push_back(*I); } else { // Found. The same cannot be found twice. Right.erase(II); + FoundOnce = true; } } } |