[llvm] [FileCheck] improve prefix validation (PR #92248)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 05:55:56 PDT 2024


================
@@ -2468,13 +2468,16 @@ FileCheckString::CheckDag(const SourceMgr &SM, StringRef Buffer,
 
 static bool ValidatePrefixes(StringRef Kind, StringSet<> &UniquePrefixes,
                              ArrayRef<StringRef> SuppliedPrefixes) {
+  static const char *Directives[] = {"-NEXT",  "-SAME", "-EMPTY", "-NOT",
+                                     "-COUNT", "-DAG",  "-LABEL"};
+
   for (StringRef Prefix : SuppliedPrefixes) {
     if (Prefix.empty()) {
       errs() << "error: supplied " << Kind << " prefix must not be the empty "
              << "string\n";
       return false;
     }
-    static const Regex Validator("^[a-zA-Z0-9_-]*$");
+    static const Regex Validator("^[a-zA-Z][a-zA-Z0-9_-]*$");
----------------
klensy wrote:

Well, yes, but error message says "prefix must start with a letter" so this existed before that PR?

https://github.com/llvm/llvm-project/pull/92248


More information about the llvm-commits mailing list