aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/FileCheck.cpp
diff options
context:
space:
mode:
authorJoel E. Denny <jdenny.ornl@gmail.com>2020-05-11 19:40:15 -0400
committerJoel E. Denny <jdenny.ornl@gmail.com>2020-05-11 19:41:22 -0400
commite1ed4d9eb506a38772bfa659dcc09052eaff2e5d (patch)
tree26369a207c592875b0f9989496d89fd6eaff5e15 /llvm/lib/Support/FileCheck.cpp
parentd0e7fd6b624b1943f3780a69883690017d2efad2 (diff)
downloadllvm-e1ed4d9eb506a38772bfa659dcc09052eaff2e5d.zip
llvm-e1ed4d9eb506a38772bfa659dcc09052eaff2e5d.tar.gz
llvm-e1ed4d9eb506a38772bfa659dcc09052eaff2e5d.tar.bz2
Revert "[FileCheck] Make invalid prefix diagnostics more precise"
This reverts commit a78e13745d4ee4a42e41ebbe698159f651515fc5 to try to fix a bot: http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/23489
Diffstat (limited to 'llvm/lib/Support/FileCheck.cpp')
-rw-r--r--llvm/lib/Support/FileCheck.cpp40
1 files changed, 18 insertions, 22 deletions
diff --git a/llvm/lib/Support/FileCheck.cpp b/llvm/lib/Support/FileCheck.cpp
index 369b6df..b89cdfe 100644
--- a/llvm/lib/Support/FileCheck.cpp
+++ b/llvm/lib/Support/FileCheck.cpp
@@ -1874,37 +1874,33 @@ size_t FileCheckString::CheckDag(const SourceMgr &SM, StringRef Buffer,
return StartPos;
}
-static bool ValidatePrefixes(StringSet<> &UniquePrefixes,
- ArrayRef<StringRef> SuppliedPrefixes) {
- for (StringRef Prefix : SuppliedPrefixes) {
- if (Prefix.empty()) {
- errs() << "error: supplied check prefix must not be the empty string\n";
+// A check prefix must contain only alphanumeric, hyphens and underscores.
+static bool ValidateCheckPrefix(StringRef CheckPrefix) {
+ static const Regex Validator("^[a-zA-Z0-9_-]*$");
+ return Validator.match(CheckPrefix);
+}
+
+bool FileCheck::ValidateCheckPrefixes() {
+ StringSet<> PrefixSet;
+
+ for (StringRef Prefix : Req.CheckPrefixes) {
+ // Reject empty prefixes.
+ if (Prefix.empty())
return false;
- }
- static const Regex Validator("^[a-zA-Z0-9_-]*$");
- if (!Validator.match(Prefix)) {
- errs() << "error: supplied check prefix must start with a letter and "
- << "contain only alphanumeric characters, hyphens, and "
- << "underscores: '" << Prefix << "'\n";
+
+ if (!PrefixSet.insert(Prefix).second)
return false;
- }
- if (!UniquePrefixes.insert(Prefix).second) {
- errs() << "error: supplied check prefix must be unique among check "
- << "prefixes: '" << Prefix << "'\n";
+
+ if (!ValidateCheckPrefix(Prefix))
return false;
- }
}
- return true;
-}
-bool FileCheck::ValidateCheckPrefixes() {
- StringSet<> UniquePrefixes;
- if (!ValidatePrefixes(UniquePrefixes, Req.CheckPrefixes))
- return false;
return true;
}
Regex FileCheck::buildCheckPrefixRegex() {
+ // I don't think there's a way to specify an initial value for cl::list,
+ // so if nothing was specified, add the default
if (Req.CheckPrefixes.empty()) {
Req.CheckPrefixes.push_back("CHECK");
Req.IsDefaultCheckPrefix = true;