[PATCH] Allow multiple check prefixes in FileCheck

Matt Arsenault Matthew.Arsenault at amd.com
Tue Sep 3 18:31:59 PDT 2013


On 09/02/2013 03:24 AM, Daniel Sanders wrote:
> Sorry for the slow response. I was out of the office on Friday.
>
> I've a patch that adds a pair of tests that demonstrate that FileCheck is skipping checks, the patch also adds the debugging messages I was using while writing this email. The tests only differ in the order that -check-prefix=A and -check-prefix=B are specified on the command line and contain a single B-DAG directive. check-a-b-has-b.txt fails with the message "error: no check strings found with prefixes 'A:', 'B:'" but check-b-a-has-b.txt passes. If FindFirstMatchingPrefix behaved as you describe, then both tests should behave in the same way.
>
> The problem is that FindFirstMatchingPrefix iterates over the prefixes and then short-circuits the rest of the loop when it finds a match. The match is the first occurrence of that particular prefix in the buffer but it is not necessarily the first occurrence of any of the prefixes. In the attached check-a-b-has-b.txt, there are four (I was expecting two, I'll explain below) calls to FindFirstMatchingPrefix. All of these matches match the A prefix. The first two match the A in the RUN line, the third and fourth matches match the A in 'B-DAG'. When the third call to FindFirstMatchingPrefix returns the 'A' in 'B-DAG', the caller (ReadCheckFile) substrs the buffer and permanently loses the missed B prefix.
>
> The unexpected calls to FindFirstMatchingPrefix appears to be the result of a seemingly harmless off-by-one error that was introduced in r188221. The 'Buffer.substr()' on line 762 is trying to remove the prefix from the buffer but fails to account for the extra character it was keeping to check for word boundaries. The one-character prefixes we have used in our tests then match a second time before being removed from the buffer.
>

I see what you mean now, and the matching part is mostly wrong. It also 
don't think it works correctly if one prefix is a substring of another. 
I'm working on fixing it




More information about the llvm-commits mailing list