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

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Mon May 20 00:35:36 PDT 2024


================
@@ -2468,24 +2468,36 @@ FileCheckString::CheckDag(const SourceMgr &SM, StringRef Buffer,
 
 static bool ValidatePrefixes(StringRef Kind, StringSet<> &UniquePrefixes,
                              ArrayRef<StringRef> SuppliedPrefixes) {
+  static const char *Suffixes[] = {"-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_-]*$");
+    // TODO: restrict prefixes to start with only letter eventually
----------------
jh7370 wrote:

Please delete this TODO. We DO NOT want to restrict this: there is no benefit to doing so. 

Please move adjusting the error message to match the actual behaviour into a separate PR, as it is not related to "improving prefix validation".

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


More information about the llvm-commits mailing list