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

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 06:22:55 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_-]*$");
----------------
jh7370 wrote:

Being able to have a prefix like "32" or "64" is quite useful for LLVM binutils tests where the thing that is different is whether the file format is 32-bit or 64-bit. There's no reason to forbid those patterns. If necessary, update the message and/or docs to match the current behaviour rather than changing the behaviour.

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


More information about the llvm-commits mailing list