[clang] Fix `pragma-comment.c` test failing on false match (PR #145455)

Dave Bartolomeo via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 24 09:39:33 PDT 2025


================
@@ -32,3 +32,6 @@
 // ELF: ![[space]] = !{!"with space"}
 // ELF-NOT: bar
 // ELF-NOT: foo
+// This following match prevents the clang version metadata from matching the forbidden 'foo' and 'bar' tokens.
+// This can happen if the clang version string contains a Git repo URL that includes one of those substrings.
+// ELF-LABEL: !"clang version
----------------
dbartol wrote:

I was considering the word boundary approach before I discovered `CHECK-LABEL:`. Using word boundaries would have fixed the problem for me, but not for someone whose GitHub handle was literally just either `foo` or `bar` (or any other use of those words in a URL or whatever else can wind up in the version string).

I also just considered using random strings instead of `foo` and `bar`, which would have made a match much less likely.

Ultimately, the behavior of `CHECK-LABEL:` works pretty well here. While we don't really care whether the Clang version is present or not, the additional behavior of ignoring the label line for any other matches is what we're looking for.


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


More information about the cfe-commits mailing list