aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/FileCheck
AgeCommit message (Collapse)AuthorFilesLines
2021-06-25[llvm] Rename StringRef _lower() method calls to _insensitive()Martin Storsjö1-1/+1
This is a mechanical change. This actually also renames the similarly named methods in the SmallString class, however these methods don't seem to be used outside of the llvm subproject, so this doesn't break building of the rest of the monorepo.
2021-04-20Fix PR46880: Fail CHECK-NOT with undefined variableThomas Preud'homme2-43/+28
Currently a CHECK-NOT directive succeeds whenever the corresponding match fails. However match can fail due to an error rather than a lack of match, for instance if a variable is undefined. This commit makes match error a failure for CHECK-NOT. Reviewed By: jdenny Differential Revision: https://reviews.llvm.org/D86222
2021-03-24[FileCheck] Fix PR49531: invalid use of string varThomas Preud'homme1-1/+8
FileCheck string substitution block parsing code only report an invalid variable name in a string variable use if it starts with a forbidden character. It does not report anything if there are unparsed characters after the variable name, i.e. [[X-Y]] is parsed as [[X]] and no error is returned. This commit fixes that. Reviewed By: jdenny, jhenderson Differential Revision: https://reviews.llvm.org/D98691
2021-03-17[FileCheck] Fix redundant diagnostics due to numeric errorsJoel E. Denny1-0/+2
Fixed substitution printing not to produce an empty diagnostic for errors handled elsewhere. Reviewed By: thopre Differential Revision: https://reviews.llvm.org/D98088
2021-03-17[FileCheck] Fix numeric error propagationJoel E. Denny2-142/+244
A more general name might be match-time error propagation. That is, it's conceivable we'll one day have non-numeric errors that require the handling fixed by this patch. Without this patch, FileCheck behaves as follows: ``` $ cat check CHECK-NOT: [[#0x8000000000000000+0x8000000000000000]] $ FileCheck -vv -dump-input=never check < input check:1:54: remark: implicit EOF: expected string found in input CHECK-NOT: [[#0x8000000000000000+0x8000000000000000]] ^ <stdin>:2:1: note: found here ^ check:1:15: error: unable to substitute variable or numeric expression: overflow error CHECK-NOT: [[#0x8000000000000000+0x8000000000000000]] ^ $ echo $? 0 ``` Notice that the exit status is 0 even though there's an error. Moreover, FileCheck doesn't print the error diagnostic unless both `-dump-input=never` and `-vv` are specified. The same problem occurs when `CHECK-NOT` does have a match but a capture fails due to overflow: exit status is 0, and no diagnostic is printed unless both `-dump-input=never` and `-vv` are specified. The usefulness of capturing from `CHECK-NOT` is questionable, but this case should certainly produce an error. With this patch, FileCheck always includes the error diagnostic and has non-zero exit status for the above examples. It's conceivable that this change will cause some existing tests to fail, but my assumption is that they should fail. Moreover, with nearly every project enabled, this patch didn't produce additional `check-all` failures for me. This patch also extends input dumps to include such numeric error diagnostics for both expected and excluded patterns. As noted in fixmes in some of the tests added by this patch, this patch worsens an existing issue with redundant diagnostics. I'll fix that bug in a subsequent patch. Reviewed By: thopre, jhenderson Differential Revision: https://reviews.llvm.org/D98086
2021-03-12[FileCheck] Add support for hex alternate form in FileCheckThomas Preud'homme2-12/+39
Add printf-style alternate form flag to prefix hex number with 0x when present. This works on both empty numeric expression (e.g. variable definition from input) and when matching a numeric expression. The syntax is as follows: [[#%#<precision specifier><format specifier>, ...] where <precision specifier> and <format specifier> are optional and ... can be a variable definition or not with an empty expression or not. This feature was requested in https://reviews.llvm.org/D81144#2075532 for llvm/test/MC/ELF/gen-dwarf64.s Reviewed By: jdenny Differential Revision: https://reviews.llvm.org/D97845
2021-03-11[FileCheck] Fix naming of OverflowErrorStr varThomas Preud'homme1-3/+8
As pointed out by Joel E. Denny in D97845, the OverflowErrorStr variable is misnamed because the error is raised for any parsing error. Note that in FileCheck proper this only happens in case of (under|over)flow because the regex will ensure a number in the correct format is matched. Reviewed By: jdenny Differential Revision: https://reviews.llvm.org/D98342
2021-03-03[FileCheck] Do not skip end of line in diagnosticsThomas Preud'homme1-3/+0
When commit da108b4ed4e6e7267701e76d5fd3b87609c9ab77 introduced the CHECK-NEXT directive, it added logic to skip to the next line when printing a diagnostic if the current matching position is at the end of a line. This was fine while FileCheck did not support regular expression but since it does now it can be confusing when the pattern to match starts with the expectation of a newline (e.g. CHECK-NEXT: {{\n}}foo). It is also inconsistent with the column information in the diagnostic which does point to the end of line. This commit removes this logic altogether, such that failure to match diagnostic for such cases would show the end of line and be consistent with the column information. The commit also adapts all existing testcases accordingly. Note to reviewers: An alternative approach would be to restrict the code to only skip to the next line if the first character of the pattern is known not to match a whitespace-like character. This would respect the original intent but keep the inconsistency in terms of column info and requires more code. I've only chosen this current approach by laziness and would be happy to restrict the logic instead. Reviewed By: jdenny, jhenderson Differential Revision: https://reviews.llvm.org/D93341
2021-01-17[llvm] Use llvm::sort (NFC)Kazu Hirata1-6/+5
2021-01-14[llvm] Remove redundant return and continue statements (NFC)Kazu Hirata1-1/+0
Identified with readability-redundant-control-flow.
2020-12-18[FileCheck] Add a literal check directive modifierJacques Pienaar1-36/+82
Introduce CHECK modifiers that change the behavior of the CHECK directive. Also add a LITERAL modifier for cases where matching could end requiring escaping strings interpreted as regex where only literal/fixed string matching is desired (making the CHECK's more difficult to write/fragile and difficult to interpret).
2020-12-16Use basic_string::find(char) instead of basic_string::find(const char *s, ↵Fangrui Song1-1/+1
size_type pos=0) Many (StringRef) cannot be detected by clang-tidy performance-faster-string-find.
2020-11-18Revert "[build] normalize components dependencies"serge-sans-paille1-3/+2
This reverts commit c6ef6e1690d517b3401ea06b1fe46871eb67434d. Basically, publicly linked libraries have a different semantic than components, which link libraries privately. Differential Revision: https://reviews.llvm.org/D91461
2020-11-17[build] normalize components dependenciesserge-sans-paille1-2/+3
Use LINK_COMPONENTS instead of explicit target_link_libraries for components. This avoids redundancy and potential inconsistencies. Differential Revision: https://reviews.llvm.org/D91461
2020-10-30[FileCheck] Report missing prefixes when more than one is provided.Mircea Trofin1-8/+16
If more than a prefix is provided - e.g. --check-prefixes=CHECK,FOO - we don't report if (say) FOO is never used. This may lead to a gap in our test coverage. This patch introduces a new option, --allow-unused-prefixes. It currently is set to true, keeping today's behavior. After we explicitly set it in tests where this behavior was actually intentional, we will switch it to false by default. Differential Revision: https://reviews.llvm.org/D90281
2020-09-01Reland [FileCheck] Move FileCheck implementation out of LLVMSupport into its ↵Raphael Isemann3-0/+3569
own library This relands e9a3d1a401b07cbf7b11695637f1b549782a26cd which was originally missing linking LLVMSupport into LLMVFileCheck which broke the SHARED_LIBS build. Original summary: The actual FileCheck logic seems to be implemented in LLVMSupport. I don't see a good reason for having FileCheck implemented there as it has a very specific use while LLVMSupport is a dependency of pretty much every LLVM tool there is. In fact, the only use of FileCheck I could find (outside the FileCheck tool and the FileCheck unit test) is a single call in GISelMITest.h. This moves the FileCheck logic to its own LLVMFileCheck library. This way only FileCheck and the GlobalISelTests now have a dependency on this code. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D86344
2020-08-31Revert "[FileCheck] Move FileCheck implementation out of LLVMSupport into ↵Raphael Isemann3-3567/+0
its own library" This reverts commit e9a3d1a401b07cbf7b11695637f1b549782a26cd. Seems the new FileCheck library doesn't link on some bots. Reverting for now.
2020-08-31[FileCheck] Move FileCheck implementation out of LLVMSupport into its own ↵Raphael Isemann3-0/+3567
library The actual FileCheck logic seems to be implemented in LLVMSupport. I don't see a good reason for having FileCheck implemented there as it has a very specific use while LLVMSupport is a dependency of pretty much every LLVM tool there is. In fact, the only use of FileCheck I could find (outside the FileCheck tool and the FileCheck unit test) is a single call in GISelMITest.h. This moves the FileCheck logic to its own LLVMFileCheck library. This way only FileCheck and the GlobalISelTests now have a dependency on this code. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D86344