[llvm] [FileCheck] forbid filecheck prefix to end with directive name (PR #92735)

Paul T Robinson via llvm-commits llvm-commits at lists.llvm.org
Tue May 21 08:20:45 PDT 2024


================
@@ -2486,6 +2489,13 @@ static bool ValidatePrefixes(StringRef Kind, StringSet<> &UniquePrefixes,
              << "check and comment prefixes: '" << Prefix << "'\n";
       return false;
     }
+    for (StringRef Suffix : Suffixes) {
+      if (Prefix.ends_with(Suffix)) {
+        errs() << "error: supplied " << Kind << " prefix must not end with "
+               << "directive: '" << Suffix << "', prefix: '" << Prefix << "'\n";
+        return false;
+      }
+    }
----------------
pogo59 wrote:

I think this is validating the arguments to `--check-prefixes` is that correct? Seems like a good thing to do. Please make sure the documentation mentions this new restriction.

However, this code also appears to be putting the same restriction on `--comment-prefixes` which we do _not_ want to do; the documentation explicitly says suffixes on comment prefixes are allowed (and cause the directive to be ignored). Probably this loop should be moved out to its own function so that FileCheck::ValidateCheckPrefixes can apply it only to the check prefixes and not the comment prefixes.

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


More information about the llvm-commits mailing list