aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/FileCheck.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-09-01Reland [FileCheck] Move FileCheck implementation out of LLVMSupport into its ↵Raphael Isemann1-2702/+0
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 Isemann1-0/+2702
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 Isemann1-2702/+0
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
2020-08-30[FileCheck] Add precision to format specifierThomas Preud'homme1-41/+91
Add printf-style precision specifier to pad numbers to a given number of digits when matching them if the value is smaller than the given precision. 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><format specifier>, ...] where <format specifier> is optional and ... can be a variable definition or not with an empty expression or not. In the absence of a precision specifier, a variable definition will accept leading zeros. Reviewed By: jhenderson, grimar Differential Revision: https://reviews.llvm.org/D81667
2020-08-24Test all CHECK-NOT in a block even if one failsThomas Preud'homme1-3/+4
This commit makes FileCheck print all CHECK-NOT directive failure in a CHECK-NOT block even if one fails. Prior to that, it would stop trying to match CHECK-NOT directive as soon as one in the block fails. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D86315
2020-08-01Use llvm::is_contained where appropriate (NFC)Kazu Hirata1-3/+2
Use llvm::is_contained where appropriate (NFC) Reviewed By: kazu Differential Revision: https://reviews.llvm.org/D85083
2020-07-28[FileCheck] Report captured variablesJoel E. Denny1-2/+56
Report captured variables in input dumps and traces. For example: ``` $ cat check CHECK: hello [[WHAT:[a-z]+]] CHECK: goodbye [[WHAT]] $ FileCheck -dump-input=always -vv check < input |& tail -8 <<<<<< 1: hello world check:1'0 ^~~~~~~~~~~ check:1'1 ^~~~~ captured var "WHAT" 2: goodbye world check:2'0 ^~~~~~~~~~~~~ check:2'1 with "WHAT" equal to "world" >>>>>> $ FileCheck -dump-input=never -vv check < input check2:1:8: remark: CHECK: expected string found in input CHECK: hello [[WHAT:[a-z]+]] ^ <stdin>:1:1: note: found here hello world ^~~~~~~~~~~ <stdin>:1:7: note: captured var "WHAT" hello world ^~~~~ check2:2:8: remark: CHECK: expected string found in input CHECK: goodbye [[WHAT]] ^ <stdin>:2:1: note: found here goodbye world ^~~~~~~~~~~~~ <stdin>:2:1: note: with "WHAT" equal to "world" goodbye world ^ ``` Reviewed By: thopre Differential Revision: https://reviews.llvm.org/D83651
2020-07-28[FileCheck] Extend -dump-input with substitutionsJoel E. Denny1-24/+42
Substitutions are already reported in the diagnostics appearing before the input dump in the case of failed directives, and they're reported in traces (produced by `-vv -dump-input=never`) in the case of successful directives. However, those reports are not always convenient to view while investigating the input dump, so this patch adds the substitution report to the input dump too. For example: ``` $ cat check CHECK: hello [[WHAT:[a-z]+]] CHECK: [[VERB]] [[WHAT]] $ FileCheck -vv -DVERB=goodbye check < input |& tail -8 <<<<<< 1: hello world check:1 ^~~~~~~~~~~ 2: goodbye word check:2'0 X~~~~~~~~~~~ error: no match found check:2'1 with "VERB" equal to "goodbye" check:2'2 with "WHAT" equal to "world" >>>>>> ``` Without this patch, the location reported for a substitution for a directive match is the directive's full match range. This location is misleading as it implies the substitution itself matches that range. This patch changes the reported location to just the match range start to suggest the substitution is known at the start of the match. (As in the above example, input dumps don't mark any range for substitutions. The location info in that case simply identifies the right line for the annotation.) Reviewed By: mehdi_amini, thopre Differential Revision: https://reviews.llvm.org/D83650
2020-06-17[FileCheck] Implement * and / operators for ExpressionValue.Paul Walker1-0/+54
Subscribers: arichardson, hiraditya, thopre, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D80915
2020-06-10FileCheck [11/12]: Add matching constraint specificationThomas Preud'homme1-12/+29
This patch is part of a patch series to add support for FileCheck numeric expressions. This specific patch adds support for specifying the matching constraint for a numeric expression, ie. how the value being matched should relate to the numeric expression. This commit only adds the equality constraint where the numeric value matched must be equal to the numeric expression. It is the default matching constraint used when not specified. It is added to provision other matching constraint (e.g. inequality relations). Copyright: - Linaro (changes up to diff 183612 of revision D55940) - GraphCore (changes in later versions of revision D55940 and in new revision created off D55940) Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D60391
2020-06-10[FileCheck] Add function call support to numerical expressions.Paul Walker1-10/+121
This patch extends numerical expressions to allow calls to predefined functions. These calls can be combined with the existing numerical operators, which includes nesting calls. The call syntax is: <func>(<args>) Where <func> is a predefined string literal, currently limited to one of add, max, min and sub. <arg> is a comma seperated list of numerical expressions. Subscribers: arichardson, hiraditya, thopre, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D79936
2020-05-28Fix MSVC signed/unsigned comparison warnings. NFC.Simon Pilgrim1-2/+2
2020-05-28FileCheck [10/12]: Add support for signed numeric valuesThomas Preud'homme1-48/+214
Summary: This patch is part of a patch series to add support for FileCheck numeric expressions. This specific patch adds support signed numeric values, thus allowing negative numeric values. As such, the patch adds a new class to represent a signed or unsigned value and add the logic for type promotion and type conversion in numeric expression mixing signed and unsigned values. It also adds the %d format specifier to represent signed value. Finally, it also adds underflow and overflow detection when performing a binary operation. Copyright: - Linaro (changes up to diff 183612 of revision D55940) - GraphCore (changes in later versions of revision D55940 and in new revision created off D55940) Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson Reviewed By: jhenderson, arichardson Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield Tags: #llvm Differential Revision: https://reviews.llvm.org/D60390
2020-05-27[FileCheck] Allow parenthesized expressionsAlex Richardson1-0/+39
With this change it is be possible to write FileCheck expressions such as [[#(VAR+1)-2]]. Currently, the only supported arithmetic operators are plus and minus, so this is not particularly useful yet. However, it our CHERI fork we have tests that benefit from having multiplication in FileCheck expressions. Allowing parenthesized expressions is the simplest way for us to work around the current lack of operator precedence in FileCheck expressions. Reviewed By: thopre, jhenderson Differential Revision: https://reviews.llvm.org/D77383
2020-05-14[FileCheck] Fix isalpha/isalnum callsJoel E. Denny1-3/+3
D79276 caused the following builder to fail: http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/23489 Specifically, FileCheck dumped stack in the following tests: LLVM :: MC/Mips/micromips-jump-pc-region.s LLVM :: MC/Mips/mips-jump-pc-region.s Those tests contained characters encoded as 160 but that render (at least for me in vim) like a single space (32). Those characters appeared between the `#` and `RUN:` on several lines, and D79276 caused FileCheck to process those lines differently: `RUN:` is a comment directive. As a result, D79276 caused FileCheck to start calling is `isalnum` on those characters. The problem is that FileCheck calls `isalnum` on type `char` without casting to `unsigned char` first, so it sign-extends 160 beyond what `unsigned char` or `EOF` can represent. C says that has undefined behavior. This problem is general to FileCheck's prefix parsing and so exists independently of D79276. 524457edbc3d fixed the above tests. This patch changes FileCheck to use LLVM's replacements for `ctype.h` functions, and it adds tests for cases that are representative with or without D79276. Reviewed By: jhenderson, thopre, efriedma Differential Revision: https://reviews.llvm.org/D79810
2020-05-13[FileCheck] Support comment directivesJoel E. Denny1-21/+68
Sometimes you want to disable a FileCheck directive without removing it entirely, or you want to write comments that mention a directive by name. The `COM:` directive makes it easy to do this. For example, you might have: ``` ; X32: pinsrd_1: ; X32: pinsrd $1, 4(%esp), %xmm0 ; COM: FIXME: X64 isn't working correctly yet for this part of codegen, but ; COM: X64 will have something similar to X32: ; COM: ; COM: X64: pinsrd_1: ; COM: X64: pinsrd $1, %edi, %xmm0 ``` Without this patch, you need to use some combination of rewording and directive syntax mangling to prevent FileCheck from recognizing the commented occurrences of `X32:` and `X64:` above as directives. Moreover, FileCheck diagnostics have been proposed that might complain about the occurrences of `X64` that don't have the trailing `:` because they look like directive typos: <http://lists.llvm.org/pipermail/llvm-dev/2020-April/140610.html> I think dodging all these problems can prove tedious for test authors, and directive syntax mangling already makes the purpose of existing test code unclear. `COM:` can avoid all these problems. This patch also updates the small set of existing tests that define `COM` as a check prefix: - clang/test/CodeGen/default-address-space.c - clang/test/CodeGenOpenCL/addr-space-struct-arg.cl - clang/test/Driver/hip-device-libs.hip - llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll I think lit should support `COM:` as well. Perhaps `clang -verify` should too. Reviewed By: jhenderson, thopre Differential Revision: https://reviews.llvm.org/D79276
2020-05-11[FileCheck] Make invalid prefix diagnostics more preciseJoel E. Denny1-18/+22
This will prove especially helpful after D79276, which introduces comment prefixes. Specifically, identifying whether there's a uniqueness violation will be helpful as prefixes will be required to be unique across both check prefixes and comment prefixes. Also, remove a related comment about `cl::list` that no longer seems relevant now that FileCheck is also a library. Reviewed By: jhenderson, thopre Differential Revision: https://reviews.llvm.org/D79375
2020-05-11Revert "[FileCheck] Make invalid prefix diagnostics more precise"Joel E. Denny1-22/+18
This reverts commit a78e13745d4ee4a42e41ebbe698159f651515fc5 to try to fix a bot: http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/23489
2020-05-11Revert "[FileCheck] Support comment directives"Joel E. Denny1-68/+21
This reverts commit 9a9a5f9893c8db05cebc8818eb8485bff61f7c74 to try to fix a bot: http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/23489
2020-05-11[FileCheck] Support comment directivesJoel E. Denny1-21/+68
Sometimes you want to disable a FileCheck directive without removing it entirely, or you want to write comments that mention a directive by name. The `COM:` directive makes it easy to do this. For example, you might have: ``` ; X32: pinsrd_1: ; X32: pinsrd $1, 4(%esp), %xmm0 ; COM: FIXME: X64 isn't working correctly yet for this part of codegen, but ; COM: X64 will have something similar to X32: ; COM: ; COM: X64: pinsrd_1: ; COM: X64: pinsrd $1, %edi, %xmm0 ``` Without this patch, you need to use some combination of rewording and directive syntax mangling to prevent FileCheck from recognizing the commented occurrences of `X32:` and `X64:` above as directives. Moreover, FileCheck diagnostics have been proposed that might complain about the occurrences of `X64` that don't have the trailing `:` because they look like directive typos: <http://lists.llvm.org/pipermail/llvm-dev/2020-April/140610.html> I think dodging all these problems can prove tedious for test authors, and directive syntax mangling already makes the purpose of existing test code unclear. `COM:` can avoid all these problems. This patch also updates the small set of existing tests that define `COM` as a check prefix: - clang/test/CodeGen/default-address-space.c - clang/test/CodeGenOpenCL/addr-space-struct-arg.cl - clang/test/Driver/hip-device-libs.hip - llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll I think lit should support `COM:` as well. Perhaps `clang -verify` should too. Reviewed By: jhenderson, thopre Differential Revision: https://reviews.llvm.org/D79276
2020-05-11[FileCheck] Make invalid prefix diagnostics more preciseJoel E. Denny1-18/+22
This will prove especially helpful after D79276, which introduces comment prefixes. Specifically, identifying whether there's a uniqueness violation will be helpful as prefixes will be required to be unique across both check prefixes and comment prefixes. Also, remove a related comment about `cl::list` that no longer seems relevant now that FileCheck is also a library. Reviewed By: jhenderson, thopre Differential Revision: https://reviews.llvm.org/D79375
2020-04-20[FileCheck] - Refactor the code related to string arrays. NFCI.Georgii Rymar1-16/+11
There are few `std::vector<std::string>` members in `FileCheckRequest`. This patch changes these arrays to `std::vector<StringRef>` and refactors the code related to cleanup/improve/simplify it. Differential revision: https://reviews.llvm.org/D78202
2020-04-16[FileCheck] Fix --dump-input implicit pattern locationJoel E. Denny1-7/+18
Currently, `--dump-input` implies that all `--implicit-check-not` patterns appear on line 1 by printing annotations like: ``` 1: foo bar baz not:1 !~~ error: no match expected ``` This patch changes that to: ``` 1: foo bar baz not:imp1 !~~ error: no match expected ``` `imp1` indicates the first `--implicit-check-not` pattern. Reviewed By: thopre Differential Revision: https://reviews.llvm.org/D77605
2020-04-16[FileCheck] - Fix the false positive when -implicit-check-not is used with ↵Georgii Rymar1-11/+19
an unknown -check-prefix. Imagine we have the following invocation: `FileCheck -check-prefix=UNKNOWN-PREFIX -implicit-check-not=something` When the check prefix does not exist it does not fail. This patch fixes the issue. Differential revision: https://reviews.llvm.org/D78024
2020-04-15[FileCheck] - Refine the comment. NFC.Georgii Rymar1-2/+2
It did not mention the `--implicit-check-not` before, though it should (https://reviews.llvm.org/D78024#inline-715166).
2020-04-15[FileCheck] Better diagnostic for format conflictThomas Preud'homme1-40/+71
Summary: Improve error message in case of conflict between several implicit format to mention the operand that conflict. Reviewers: jhenderson, jdenny, probinson, grimar, arichardson, rnk Reviewed By: jdenny Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77741
2020-02-10Revert "Remove redundant "std::move"s in return statements"Bill Wendling1-3/+3
The build failed with error: call to deleted constructor of 'llvm::Error' errors. This reverts commit 1c2241a7936bf85aa68aef94bd40c3ba77d8ddf2.
2020-02-10Remove redundant "std::move"s in return statementsBill Wendling1-3/+3
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-2/+2
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-24FileCheck [9/12]: Add support for matching formatsThomas Preud'homme1-37/+160
Summary: This patch is part of a patch series to add support for FileCheck numeric expressions. This specific patch adds support for selecting a matching format to match a numeric value against (ie. decimal, hex lower case letters or hex upper case letters). This commit allows to select what format a numeric value should be matched against. The following formats are supported: decimal value, lower case hex value and upper case hex value. Matching formats impact both the format of numeric value to be matched as well as the format of accepted numbers in a definition with empty numeric expression constraint. Default for absence of format is decimal value unless the numeric expression constraint is non null and use a variable in which case the format is the one used to define that variable. Conclict of format in case of several variable being used is diagnosed and forces the user to select a matching format explicitely. This commit also enables immediates in numeric expressions to be in any radix known to StringRef's GetAsInteger method, except for legacy numeric expressions (ie [[@LINE+<offset>]] which only support decimal immediates. Copyright: - Linaro (changes up to diff 183612 of revision D55940) - GraphCore (changes in later versions of revision D55940 and in new revision created off D55940) Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson Reviewed By: jhenderson, arichardson Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield Tags: #llvm Differential Revision: https://reviews.llvm.org/D60389
2020-01-06[FileCheck] Remove FileCheck prefix in APIThomas Preud'homme1-144/+128
Summary: When FileCheck was made a library, types in the public API were renamed to add a FileCheck prefix, such as Pattern to FileCheckPattern. Many types were moved into a private interface and thus don't need this prefix anymore. This commit removes those unneeded prefixes. Reviewers: jhenderson, jdenny, probinson, grimar, arichardson, rnk Reviewed By: jhenderson Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72186
2019-10-11[FileCheck] Implement --ignore-case option.Kai Nacke1-2/+7
The FileCheck utility is enhanced to support a `--ignore-case` option. This is useful in cases where the output of Unix tools differs in case (e.g. case not specified by Posix). Reviewers: Bigcheese, jakehehrlich, rupprecht, espindola, alexshap, jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D68146 llvm-svn: 374538
2019-10-10Revert "[FileCheck] Implement --ignore-case option."Dmitri Gribenko1-1990/+1985
This reverts commit r374339. It broke tests: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/19066 llvm-svn: 374359
2019-10-10[FileCheck] Implement --ignore-case option.Kai Nacke1-1985/+1990
The FileCheck utility is enhanced to support a `--ignore-case` option. This is useful in cases where the output of Unix tools differs in case (e.g. case not specified by Posix). Reviewers: Bigcheese, jakehehrlich, rupprecht, espindola, alexshap, jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D68146 llvm-svn: 374339
2019-10-01[FileCheck] Move private interface to its own headerThomas Preud'homme1-0/+1
Summary: Most of the class definition in llvm/include/llvm/Support/FileCheck.h are actually implementation details that should not be relied upon. This commit moves all of it in a new header file under llvm/lib/Support/FileCheck. It also takes advantage of the code movement to put the code into a new llvm::filecheck namespace. Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield Tags: #llvm Differential Revision: https://reviews.llvm.org/D67649 llvm-svn: 373395
2019-09-30[FileCheck] Remove implementation types from APIThomas Preud'homme1-19/+24
Summary: Remove use of FileCheckPatternContext and FileCheckString concrete types from FileCheck API to allow moving it and the other implementation only only declarations into a private header file. Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68186 llvm-svn: 373211
2019-09-24Regex: Make "match" and "sub" const member functionsThomas Preud'homme1-1/+1
Summary: The Regex "match" and "sub" member functions were previously not "const" because they wrote to the "error" member variable. This commit removes those assignments, and instead assumes that the validity of the regex is already known after the initial compilation of the regular expression. As a result, these member functions were possible to make "const". This makes it easier to do things like pre-compile Regexes up-front, and makes "match" and "sub" thread-safe. The error status is now returned as an optional output, which also makes the API of "match" and "sub" more consistent with each other. Also, some uses of Regex that could be refactored to be const were made const. Patch by Nicolas Guillemot Reviewers: jankratochvil, thopre Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67241 llvm-svn: 372764
2019-09-02[FileCheck] Forbid using var defined on same lineThomas Preud'homme1-36/+6
Summary: Commit r366897 introduced the possibility to set a variable from an expression, such as [[#VAR2:VAR1+3]]. While introducing this feature, it introduced extra logic to allow using such a variable on the same line later on. Unfortunately that extra logic is flawed as it relies on a mapping from variable to expression defining it when the mapping is from variable definition to expression. This flaw causes among other issues PR42896. This commit avoids the problem by forbidding all use of a variable defined on the same line, and removes the now useless logic. Redesign will be done in a later commit because it will require some amount of refactoring first for the solution to be clean. One example is the need for some sort of transaction mechanism to set a variable temporarily and from an expression and rollback if the CHECK pattern does not match so that diagnostics show the right variable values. Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk Subscribers: JonChesterfield, rogfer01, hfinkel, kristina, rnk, tra, arichardson, grimar, dblaikie, probinson, llvm-commits, hiraditya Tags: #llvm Differential Revision: https://reviews.llvm.org/D66141 llvm-svn: 370663
2019-08-23Do a sweep of symbol internalization. NFC.Benjamin Kramer1-1/+1
llvm-svn: 369803
2019-08-15[llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-6/+6
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
2019-08-08[FileCheck] Add missing includes in headerThomas Preud'homme1-1/+1
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65778 llvm-svn: 368297
2019-07-24FileCheck [8/12]: Define numeric var from exprThomas Preud'homme1-118/+191
Summary: This patch is part of a patch series to add support for FileCheck numeric expressions. This specific patch lift the restriction for a numeric expression to either be a variable definition or a numeric expression to try to match. This commit allows a numeric variable to be set to the result of the evaluation of a numeric expression after it has been matched successfully. When it happens, the variable is allowed to be used on the same line since its value is known at match time. It also makes use of this possibility to reuse the parsing code to parse a command-line definition by crafting a mirror string of the -D option with the equal sign replaced by a colon sign, e.g. for option '-D#NUMVAL=10' it creates the string '-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression is parsed to define NUMVAL. This result in a few tests needing updating for the location diagnostics on top of the tests for the new feature. It also enables empty numeric expression which match any number without defining a variable. This is done here rather than in commit #5 of the patch series because it requires to dissociate automatic regex insertion in RegExStr from variable definition which would make commit #5 even bigger than it already is. Copyright: - Linaro (changes up to diff 183612 of revision D55940) - GraphCore (changes in later versions of revision D55940 and in new revision created off D55940) Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield Tags: #llvm Differential Revision: https://reviews.llvm.org/D60388 > llvm-svn: 366860 llvm-svn: 366897
2019-07-24Revert "FileCheck [8/12]: Define numeric var from expr"Thomas Preud'homme1-191/+118
This reverts commit 1b05977538d9487aa845ee2f3bec8b89c63c4f29. llvm-svn: 366872
2019-07-23FileCheck [8/12]: Define numeric var from exprThomas Preud'homme1-118/+191
Summary: This patch is part of a patch series to add support for FileCheck numeric expressions. This specific patch lift the restriction for a numeric expression to either be a variable definition or a numeric expression to try to match. This commit allows a numeric variable to be set to the result of the evaluation of a numeric expression after it has been matched successfully. When it happens, the variable is allowed to be used on the same line since its value is known at match time. It also makes use of this possibility to reuse the parsing code to parse a command-line definition by crafting a mirror string of the -D option with the equal sign replaced by a colon sign, e.g. for option '-D#NUMVAL=10' it creates the string '-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression is parsed to define NUMVAL. This result in a few tests needing updating for the location diagnostics on top of the tests for the new feature. It also enables empty numeric expression which match any number without defining a variable. This is done here rather than in commit #5 of the patch series because it requires to dissociate automatic regex insertion in RegExStr from variable definition which would make commit #5 even bigger than it already is. Copyright: - Linaro (changes up to diff 183612 of revision D55940) - GraphCore (changes in later versions of revision D55940 and in new revision created off D55940) Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield Tags: #llvm Differential Revision: https://reviews.llvm.org/D60388 llvm-svn: 366860
2019-07-18[FileCheck] Fix numeric variable redefinitionThomas Preud'homme1-15/+1
Summary: Commit r365249 changed usage of FileCheckNumericVariable to have one instance of that class per variable as opposed to one instance per definition of a given variable as was done before. However, it retained the safety check in setValue that it should only be called with the variable unset, even after r365625. However this causes assert failure when a non-pseudo variable is being redefined. And while redefinition of @LINE at each CHECK line work in the general case, it caused problem when a substitution failed (fixed in r365624) and still causes problem when a CHECK line does not match since @LINE's value is cleared after substitutions in match() happened but printSubstitutions also attempts a substitution. This commit solves the root of the problem by changing setValue to set a new value regardless of whether a value was set or not, thus fixing all the aforementioned issues. Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield Tags: #llvm Differential Revision: https://reviews.llvm.org/D64882 llvm-svn: 366434
2019-07-15[FileCheck] Store line numbers as optional valuesThomas Preud'homme1-10/+12
Summary: Processing of command-line definition of variable and logic around implicit not directives both reuse parsing code that expects a line number to be defined. So far, a special line number of 0 was used for those users of the parsing code where a line number does not make sense. This commit instead represents line numbers as Optional values so that they can be None for those cases. Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk Subscribers: JonChesterfield, rogfer01, hfinkel, kristina, rnk, tra, arichardson, grimar, dblaikie, probinson, llvm-commits, hiraditya Tags: #llvm Differential Revision: https://reviews.llvm.org/D64639 llvm-svn: 366109
2019-07-13FileCheck [7/12]: Arbitrary long numeric expressionsThomas Preud'homme1-84/+124
Summary: This patch is part of a patch series to add support for FileCheck numeric expressions. This specific patch extend numeric expression to support an arbitrary number of operands, either variable or literals. Copyright: - Linaro (changes up to diff 183612 of revision D55940) - GraphCore (changes in later versions of revision D55940 and in new revision created off D55940) Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield Tags: #llvm Differential Revision: https://reviews.llvm.org/D60387 llvm-svn: 366001
2019-07-10[FileCheck] Simplify numeric variable interfaceThomas Preud'homme1-9/+5
Summary: This patch simplifies 2 aspects in the FileCheckNumericVariable code. First, setValue() method is turned into a void function since being called only on undefined variable is an invariant and is now asserted rather than returned. This remove the assert from the callers. Second, clearValue() method is also turned into a void function since the only caller does not check its return value since it may be trying to clear the value of variable that is already cleared without this being noteworthy. Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk Subscribers: JonChesterfield, rogfer01, hfinkel, kristina, rnk, tra, arichardson, grimar, dblaikie, probinson, llvm-commits, hiraditya Tags: #llvm Differential Revision: https://reviews.llvm.org/D64231 > llvm-svn: 365249 llvm-svn: 365625
2019-07-10[FileCheck] Fix @LINE value after match failureThomas Preud'homme1-1/+3
Summary: The value of the FileCheckNumericVariable class instance representing the @LINE numeric variable is set and cleared respectively before and after substitutions are made, if any. However, when a substitution fails, the value is not cleared. This causes the next substitution of @LINE later on to give the wrong value since setValue is a nop if the value is already set. This is what caused failures after commit r365249. Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield Tags: #llvm Differential Revision: https://reviews.llvm.org/D64449 llvm-svn: 365624
2019-07-05Revert "[FileCheck] Simplify numeric variable interface"Michael Liao1-5/+9
This reverts commit 096600a4b073dd94a366cc8e57bff93c34ff6966. llvm-svn: 365251