[clang] [PAC][clang][test] Fix incorrect usage of `-NOT` suffix for FileCheck (PR #212445)
Anatoly Trosinenko via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 29 08:41:11 PDT 2026
atrosinenko wrote:
Huh, my first thought was: "It won't work, `--implicit-check-not` simply inserts `...-NOT` directives between each pair of consecutive positive directives, so it would only operate on the lines of input not covered by the explicit positive directives". My idea was that, since you essentially perform the checks on the only interesting line of `clang`'s output, you have to use some clever mix of `...-SAME:` and `...-NOT:` directives. To confirm my understanding, I replaced `--implicit-check-not='"-fptrauth-'` with `--implicit-check-not='"-emit-obj'` (the latter substring was simply copied from the actual output)... and `FileCheck` successfully rejected its input!
After a bit more experiments, I realized that it looks like `FileCheck` tracks the current input position as the byte index (or maybe UTF-8 character, or something like this - this is not that important) and not the line number, as I thought before :)
For example, this input
```
line 1
line 2 some text
line 3
```
is accepted for
```
CHECK: line 2
CHECK: some
```
but not for
```
CHECK: some
CHECK: line 2
```
Furthermore, just as expected, the example input is accepted for
```
CHECK: line 2
CHECK-SAME: some text
```
and rejected for
```
CHECK: line 1
CHECK-SAME: some text
```
but it is also rejected for
```
CHECK: some text
CHECK-SAME: line 2
```
That is, the [`-SAME:`](https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-same-directive) directive merely rejects the match if there are any newlines between the previous and the current matches - nothing more. This seems to be the **formal** meaning of `...-SAME:` and not "matches happen on the same line as the previous match".
https://github.com/llvm/llvm-project/pull/212445
More information about the cfe-commits
mailing list