[llvm] [FileCheck] improve prefix validation (PR #92248)
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 20 03:18:37 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
+ static const Regex Validator("^[a-zA-Z0-9][a-zA-Z0-9_-]*$");
----------------
klensy wrote:
I expected for prefixes to be kind-of-ident (which can't start from digits and dashes, but digits actually used, bc no check for that was added, oh, well), and be similar to substitution blocks (which should be `"[a-zA-Z_][0-9a-zA-Z_]*"`, as per doc).
Less restrictions makes it harder to catch possible errors in directives; currently possible typos simply ignored.
https://github.com/llvm/llvm-project/pull/92248
More information about the llvm-commits
mailing list