[llvm] [FileCheck] improve prefix validation (PR #92248)
Thomas Preud'homme via llvm-commits
llvm-commits at lists.llvm.org
Wed May 15 05:53:20 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:
AFAIK the FileCheck documentation does not forbid a prefix to start with a digit. It only contains restriction for variables. If you want to forbid leading digit you would need to update the documentation and I think it should go in a separate PR because that's a functional change.
https://github.com/llvm/llvm-project/pull/92248
More information about the llvm-commits
mailing list