<div dir="ltr"><div>Hi all,<br></div><div><br></div><div>There have been a few cases recently where I've noticed two test cases in the same lit test that do the same thing except invert the CHECK, to show that something is NOT present. I'm talking about something like the following:</div><div><br></div><div># RUN: llvm-sometool --print-string | FileCheck %s --check-prefix=STRING</div><div># RUN: llvm-sometool --no-print-string | FileCheck %s --check-prefix=NO-STRING<br></div><div># STRING: This is the string</div><div># NO-STRING-NOT: This is the string</div><div><br></div><div>In such cases, as can be seen, the CHECK line effectively has to be duplicated (either in an explicit check like in the above example, or via --implicit-check-not). Duplication is generally bad, especially in this sort of case, as it only takes a typo in the NOT pattern, or a careless developer/reviewer pair changing the output to cause the NOT pattern to no longer be useful.</div><div><br></div><div>I'd like to propose a new FileCheck option (e.g. --check-not-prefix/--check-not-prefixes) which allows implicitly converting a check prefix to a -NOT version of the same prefix. That would allow writing the above example as:</div><div><br></div><div>
<div># RUN: llvm-sometool --print-string | FileCheck %s --check-prefix=STRING</div><div># RUN: llvm-sometool --no-print-string | FileCheck %s --check-not-prefix=STRING<br></div><div># STRING: This is the string</div><div><br></div><div>If there was a typo or somebody changed the string output, this mechanism would ensure there is no chance of the pattern rotting.</div><div><br></div><div>Caveat: I don't know what would be the appropriate way of handling non-trivial checks, i.e. existing CHECK-NOT/CHECK-NEXT/CHECK-SAME etc. I'd appreciate any ideas on this.<br></div><div><br></div><div>Thoughts?</div><div><br></div><div>James<br></div>

</div></div>