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

Thomas Preud'homme via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 05:58:38 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_-]*$");
----------------
RoboTux wrote:

Good point. Would you mind updating the documentation at least? Perhaps make a general section about identifiers and in the prefix and variable sections mention that those must be valid identifiers.

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


More information about the llvm-commits mailing list