Commit Graph

40 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
824c10ece2 Teach FileCheck to handle trailing CHECK-NOT patterns.
A CHECK-NOT pattern without a following CHECK pattern simply checks that the
pattern doesn't match before the end of the input file.

You can even have only CHECK-NOT patterns to check that strings appear nowhere
in the input file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116592 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-15 17:47:12 +00:00
Mikhail Glushenkov
7112c86fc2 Trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111656 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-20 17:38:38 +00:00
Chris Lattner
4c842dda39 stringref-ize the MemoryBuffer::get apis. This requires
a co-committed clang patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100485 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-05 22:42:30 +00:00
Daniel Dunbar
7a68e0df0d FileCheck: Don't print "possibly intended match" line if it would match the
"scanning from here" one.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98971 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 18:07:43 +00:00
Daniel Dunbar
0806f9ff58 FileCheck: When looking for "possible matches", only compare against the prefix
line. Turns out edit_distance can be slow if the string we are scanning for
happens to be quite large.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94860 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-30 00:24:06 +00:00
Dan Gohman
e3a1e50680 Minor code cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94848 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 21:57:46 +00:00
Dan Gohman
d8a5541a51 Skip whitespace when looking for a potential intended match.
Before:

<stdin>:94:1: note: possible intended match here
 movsd 4096(%rsi), %xmm0
^

After:
<stdin>:94:2: note: possible intended match here
 movsd 4096(%rsi), %xmm0
 ^


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94847 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 21:55:16 +00:00
Dan Gohman
e546343799 Fix the position of the caret in the FileCheck error message.
Before:

test/CodeGen/X86/lsr-reuse.ll:52:34: error: expected string not found in input
; CHECK: movsd -2048(%rsi), %xmm0
                                 ^

After:

test/CodeGen/X86/lsr-reuse.ll:52:10: error: expected string not found in input
; CHECK: movsd -2048(%rsi), %xmm0
         ^


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94846 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 21:53:18 +00:00
Daniel Dunbar
8cdf54c222 FileCheck: Switch "possible match" calculation to use StringRef::edit_distance.
- Thanks Doug, who is obviously less lazy than me!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94795 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 03:22:19 +00:00
Daniel Dunbar
a76a7883b5 Fix FileCheck crash when fuzzy scanning starting at the end of the file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90065 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-29 08:30:24 +00:00
Daniel Dunbar
ead2dacc9e FileCheck, PR5239: Try to find the intended match on failures, but looking for a
good nearby fuzzy match. Frequently the input is nearly correct, and just
showing the user the a nearby sensible match is enough to diagnose the problem.
 - The "fuzzyness" is pretty simple and arbitrary, but worked on my three test
   cases. If you encounter problems, or places you think FileCheck should have
   guessed but didn't, please add test cases to PR5239.

For example, previously FileCheck would report this:
--
t.cpp:21:55: error: expected string not found in input
// CHECK: define void @_Z2f25f2_s1([[i64_i64_ty]] %a0)
                                                      ^
<stdin>:19:30: note: scanning from here
define void @_Z2f15f1_s1(%1) nounwind {
                             ^
<stdin>:19:30: note: with variable "i64_i64_ty" equal to "%0"
--

and now it also reports this:
--
<stdin>:27:1: note: possible intended match here
define void @_Z2f25f2_s1(%0) nounwind {
^
--

which makes it clear that the CHECK just has an extra ' %a0' in it, without
having to check the input.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89631 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-22 22:59:26 +00:00
Daniel Dunbar
fafe93c8bc FileCheck: When a string using variable references fails to match, print
additional information about the current definitions of the variables used in
the string.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89628 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-22 22:08:06 +00:00
Daniel Dunbar
964ac01201 Allow '_' in FileCheck variable names, it is nice to have at least one
separate character.
 - Chris, OK?

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89626 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-22 22:07:50 +00:00
Chris Lattner
eec96958cd implement and document support for filecheck variables. This
allows matching and remembering a string and then matching and
verifying that the string occurs later in the file.

Change X86/xor.ll to use this in some cases where the test was
checking for an arbitrary register allocation decision.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82891 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-27 07:56:52 +00:00
Chris Lattner
81f46d9ce1 remove support for "NoSub" from regex. It seems like a minor optimization
and makes the API more annoying.  Add a Regex::getNumMatches() method.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82877 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-26 21:27:04 +00:00
Chris Lattner
94638f0081 reject attempts to use ()'s in patterns, these are reserved for filecheck.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82780 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 17:29:36 +00:00
Chris Lattner
5d6a05f4d4 reimplement the regex matching strategy by building a single
regex and matching it instead of trying to match chunks at a time.
Matching chunks at a time broke with check lines like 
  CHECK: foo {{.*}}bar
because the .* would eat the entire rest of the line and bar would
never match.

Now we just escape the fixed strings for the user, so that something
like:
  CHECK: a() {{.*}}???
is matched as:
  CHECK: {{a\(\) .*\?\?\?}}
transparently "under the covers".



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82779 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 17:23:43 +00:00
Chris Lattner
2702e6aa53 special case Patterns that are a single fixed string. This is a microscopic
perf win and is needed for future changes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82777 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 17:09:12 +00:00
Chris Lattner
d9485ddfdd filecheck should not match a \n with a .
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82758 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 06:47:09 +00:00
Chris Lattner
bfa2eed139 turn a std::pair into a real class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82754 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 06:32:47 +00:00
Chris Lattner
528700863a add and document regex support for FileCheck. You can now do stuff like:
; CHECK: movl {{%e[a-z][xi]}}, %eax

or whatever.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82717 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 21:47:32 +00:00
Chris Lattner
adea46ed61 Use CanonicalizeInputFile to canonicalize the entire buffer containing the
CHECK strings, instead of canonicalizing the patterns directly.  This allows
Pattern to just contain a StringRef instead of std::string.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82713 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 20:45:07 +00:00
Chris Lattner
a29703e842 change 'not' matching to use Pattern, move pattern parsing logic into
the Pattern class.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82712 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 20:39:13 +00:00
Chris Lattner
9fc6678bea refactor out the match string into its own Pattern class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82711 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 20:25:55 +00:00
Chris Lattner
8111576521 fix a FileCheck bug where:
; CHECK: foo
; CHECK-NOT: foo
; CHECK: bar

would always fail.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82424 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 02:30:42 +00:00
Chris Lattner
3711b7adcc rewrite CountNumNewlinesBetween to be in terms of StringRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82410 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 22:42:44 +00:00
Chris Lattner
f15380ba8a implement and document support for CHECK-NOT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82408 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 22:35:26 +00:00
Chris Lattner
96077036f0 rewrite FileCheck in terms of StringRef instead of manual pointer pairs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82407 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 22:11:44 +00:00
Douglas Gregor
05e9d99767 Don't install FileCheck or FileUpdate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79820 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-23 04:39:38 +00:00
Chris Lattner
0b2353f277 when emitting errors about CHECK-NEXT directives, show the line that the
CHECK-NEXT is on.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79164 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-16 02:22:31 +00:00
Chris Lattner
5dafafdeb4 implement support for CHECK-NEXT: in filecheck.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79123 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-15 18:32:21 +00:00
Chris Lattner
d7e250527c simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79121 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-15 18:00:42 +00:00
Chris Lattner
7bee3271e8 rewrite FindStringInBuffer to use an explicit loop instead of
trying to wrap strstr which is just too inconvenient.  Make it
use a StringRef to avoid ".c_str()" calls.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79120 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-15 17:53:12 +00:00
Chris Lattner
207e1bcf89 Instead of using an std::pair, use a custom struct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79119 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-15 17:41:04 +00:00
Daniel Dunbar
6f69aa3561 Fix an ENABLE_EXPENSIVE_CHECKS error.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77845 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-02 01:21:22 +00:00
Daniel Dunbar
e9e2733a04 Tweak comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75391 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 22:06:10 +00:00
Chris Lattner
d7073db1af improve filecheck's "scanning from here" caret position.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75371 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 19:21:09 +00:00
Chris Lattner
88a7e9ee8d make filecheck default to canonicalizing horizontal whitespace
away.  This way you can write a space and it matches arbitrary spaces and tabs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75370 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 18:58:15 +00:00
Chris Lattner
af9005ddda stop on the first file mismatch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75076 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-09 00:19:21 +00:00
Chris Lattner
81cb8caa3e Add a new little "FileCheck" utility for regression testing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75022 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-08 18:44:05 +00:00