summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2013-12-14 01:07:05 +0000
committerAlp Toker <alp@nuanti.com>2013-12-14 01:07:05 +0000
commit6ed7251683571ce079f34610da986254821f43e1 (patch)
treeac743d7a63f476a47ce260ef1526f2a53881d7e4 /clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
parent8a0dde75f1123537b0e9e2706c4902841a9712cd (diff)
downloadbcm5719-llvm-6ed7251683571ce079f34610da986254821f43e1.tar.gz
bcm5719-llvm-6ed7251683571ce079f34610da986254821f43e1.zip
Revert "Don't require -re suffix on -verify directives with regexes."
This patch was submitted to the list for review and didn't receive a LGTM. (In fact one explicit objection and one query were raised.) This reverts commit r197295. llvm-svn: 197299
Diffstat (limited to 'clang/lib/Frontend/VerifyDiagnosticConsumer.cpp')
-rw-r--r--clang/lib/Frontend/VerifyDiagnosticConsumer.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index ec45e36c713..40992fec3f6 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -356,8 +356,16 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM,
return true;
// Default directive kind.
+ bool RegexKind = false;
const char* KindStr = "string";
+ // Next optional token: -
+ if (PH.Next("-re")) {
+ PH.Advance();
+ RegexKind = true;
+ KindStr = "regex";
+ }
+
// Next optional token: @
SourceLocation ExpectedLoc;
if (!PH.Next("@")) {
@@ -475,8 +483,16 @@ 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(Pos, ExpectedLoc, Text, Min, Max);
+ Directive *D = Directive::create(RegexKind, Pos, ExpectedLoc, Text,
+ Min, Max);
std::string Error;
if (D->isValid(Error)) {
DL->push_back(D);
@@ -835,10 +851,10 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() {
ED.Notes.clear();
}
-Directive *Directive::create(SourceLocation DirectiveLoc,
+Directive *Directive::create(bool RegexKind, SourceLocation DirectiveLoc,
SourceLocation DiagnosticLoc, StringRef Text,
unsigned Min, unsigned Max) {
- if (Text.find("}}") == StringRef::npos)
+ if (!RegexKind)
return new StandardDirective(DirectiveLoc, DiagnosticLoc, Text, Min, Max);
// Parse the directive into a regular expression.
OpenPOWER on IntegriCloud