aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/FileCheckTest.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-09-01Reland [FileCheck] Move FileCheck implementation out of LLVMSupport into its ↵Raphael Isemann1-1724/+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/+1724
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-1724/+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-31/+93
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-08[FileCheckTest] Supress new warningDávid Bolvanský1-4/+4
2020-07-28[FileCheck] Report captured variablesJoel E. Denny1-2/+44
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-17[llvm][NFC] Add missing 'override's in unittests/Logan Smith1-1/+1
2020-06-19Reland [FileCheck, unittest] Improve readability of ExpressionFormatThomas Preud'homme1-153/+156
This was originally cd2553de77f and reverted in a3adfb400ef. The ADT itostr bug this triggered was fixed in f3e8f961736.
2020-06-19Revert "[FileCheck, unittest] Improve readability of ExpressionFormat"Thomas Preud'homme1-156/+153
This reverts commit cd2553de77f2c3206deaa261a15cc7520ff2ff56.
2020-06-19[FileCheck, unittest] Improve readability of ExpressionFormatThomas Preud'homme1-153/+156
Summary: Factor out repetetitive code into helper function and split massive ExpressionFormat method test into separate test for each method, removing dead code in passing. Also add a MinInt64 and MaxInt64 checks when testing getMatchingString. Reviewers: jhenderson, jdenny, probinson, grimar, arichardson Reviewed By: jhenderson, grimar Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D82132
2020-06-17[FileCheck] Implement * and / operators for ExpressionValue.Paul Walker1-2/+75
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-4/+15
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-1/+95
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-06-04[FileCheck] Implement equality operators for ExpressionValue.Paul Walker1-0/+40
Subscribers: hiraditya, thopre, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D81094
2020-05-28FileCheck [10/12]: Add support for signed numeric valuesThomas Preud'homme1-44/+303
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/+86
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-04-20[FileCheck] - Refactor the code related to string arrays. NFCI.Georgii Rymar1-45/+22
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-15[FileCheck] Better diagnostic for format conflictThomas Preud'homme1-63/+139
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-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-8/+9
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-58/+380
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-23[FileCheck] Strengthen error checks in unit testsThomas Preud'homme1-159/+199
Summary: This commit adds error checking beyond UndefVarError and fix a number of Error/Expected related idioms: - use (EXPECT|ASSERT)_THAT_(ERROR|EXPECTED) instead of errorToBool or boolean operator - ASSERT when a further check require the check to be successful to give a correct result Reviewers: jhenderson, jdenny, probinson, grimar, arichardson, rnk Reviewed By: jhenderson Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72914
2020-01-20[FileCheck] Make Match unittest more flexibleThomas Preud'homme1-8/+11
Summary: FileCheck's Match unittest needs updating whenever some call to initNextPattern() is inserted before its final block of checks. This commit change usage of LineNumber inside the Tester object so that the line number of the current pattern can be queries, thereby making the Match test more solid. Reviewers: jhenderson, jdenny, probinson, grimar, arichardson, rnk Reviewed By: jhenderson Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72913
2020-01-20[FileCheck] Clean and improve unit testsThomas Preud'homme1-83/+119
Summary: Clean redundant unit test checks (codepath already tested elsewhere) and add a few missing checks for existing numeric substitution and match logic. Reviewers: jhenderson, jdenny, probinson, grimar, arichardson, rnk Reviewed By: jhenderson Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72912
2020-01-06[FileCheck] Remove FileCheck prefix in APIThomas Preud'homme1-73/+71
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-04[NFC] [FileCheck] Reapply fix init of objects in unit testsThomas Preud'homme1-20/+16
Summary: Fix initialization style of objects allocated on the stack and member objects in unit test to use the "Type Var(init list)" and "Type Member{init list}" convention. The latter fixes the buildbot breakage. Reviewers: jhenderson, probinson, arichardson, grimar, jdenny Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68425 llvm-svn: 373755
2019-10-04Revert "[NFC] [FileCheck] Fix init of stack objects in unit tests"Dmitri Gribenko1-16/+20
This reverts commit r373717. It broke the build: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/18721. llvm-svn: 373722
2019-10-04[NFC] [FileCheck] Fix init of stack objects in unit testsThomas Preud'homme1-20/+16
Summary: Fix initialization style of objects allocated on the stack in unit test to use the "Type Var(init list)" convention. Reviewers: jhenderson, probinson, arichardson, grimar, jdenny Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68425 llvm-svn: 373717
2019-10-01[FileCheck] Move private interface to its own headerThomas Preud'homme1-0/+2
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-02[FileCheck] Forbid using var defined on same lineThomas Preud'homme1-41/+8
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-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-07-24[FileCheck] Use ASSERT for fatal unit testsThomas Preud'homme1-43/+45
Summary: A number of EXPECT statements in FileCheck's unit tests are dependent from results of other values being tested. This commit changes those earlier test to use ASSERT instead of EXPECT to avoid cascade errors when they are all related to the same issue. 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/D64921 > llvm-svn: 366862 llvm-svn: 366899
2019-07-24FileCheck [8/12]: Define numeric var from exprThomas Preud'homme1-53/+113
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-113/+53
This reverts commit 1b05977538d9487aa845ee2f3bec8b89c63c4f29. llvm-svn: 366872
2019-07-24Revert "[FileCheck] Use ASSERT for fatal unit tests"Thomas Preud'homme1-45/+43
This reverts commit fb596735fe9c1ea22afb1727cbbba449bd6334c2. llvm-svn: 366870
2019-07-23[FileCheck] Use ASSERT for fatal unit testsThomas Preud'homme1-43/+45
Summary: A number of EXPECT statements in FileCheck's unit tests are dependent from results of other values being tested. This commit changes those earlier test to use ASSERT instead of EXPECT to avoid cascade errors when they are all related to the same issue. 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/D64921 llvm-svn: 366862
2019-07-23FileCheck [8/12]: Define numeric var from exprThomas Preud'homme1-53/+113
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-1/+2
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-5/+9
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-113/+160
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] Use bool operator to test ExpectedThomas Preud'homme1-24/+24
Use bool() consistently to get boolean value of Error, Optional and Expected types in EXPECT calls. While static_cast is used in all cases but one, bool provides more clarity and makes more sense as a new default. llvm-svn: 365644
2019-07-10[FileCheck] Simplify numeric variable interfaceThomas Preud'homme1-11/+6
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-0/+15
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-6/+11
This reverts commit 096600a4b073dd94a366cc8e57bff93c34ff6966. llvm-svn: 365251
2019-07-05[FileCheck] Simplify numeric variable interfaceThomas Preud'homme1-11/+6
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
2019-07-05[FileCheck] Share variable instance among usesThomas Preud'homme1-2/+3
Summary: This patch changes expression support to use one instance of FileCheckNumericVariable per numeric variable rather than one per variable and per definition. The current system was only necessary for the last patch of the numeric expression support patch series in order to handle a line using a variable defined earlier on the same line from the input text. However this can be dealt more efficiently. 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/D64229 llvm-svn: 365220
2019-07-05[FileCheck] Don't diagnose undef vars at parse timeThomas Preud'homme1-2/+7
Summary: Diagnosing use of undefined variables takes place in parseNumericVariableUse() and printSubstitutions() for numeric variables but only takes place in printSubstitutions() for string variables. The reason for the split location of diagnostics is that parsing is not aware of the clearing of variables due to --enable-var-scope and thus use of variables cleared in this way can only be catched by printSubstitutions(). Beyond the code level inconsistency, there is also a user facing inconsistency since diagnostics look different between the two functions. While the diagnostic in printSubstitutions is more verbose, doing the diagnostic there allows to diagnose all undefined variables rather than just the first one and error out. This patch create dummy variable definition when encountering a use of undefined variable so that parsing can proceed and be diagnosed by printSubstitutions() later. Tests that were testing whether parsing fails in such case are thus modified accordingly. 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/D64228 llvm-svn: 365219
2019-06-19[FileCheck] Stop qualifying expressions as numericThomas Preud'homme1-29/+29
Summary: Stop referring to "numeric expression", using simply the term "expression" instead. Likewise for numeric operation since operations are only used in numeric expressions. Reviewers: jhenderson, jdenny, probinson, arichardson Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63500 llvm-svn: 363901
2019-06-19FileCheck: Return parse error w/ Error & ExpectedThomas Preud'homme1-137/+120
Summary: Make use of Error and Expected to bubble up diagnostics and force checking of errors in the callers. Reviewers: jhenderson, jdenny, probinson, arichardson Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63125 llvm-svn: 363900
2019-06-06FileCheck [6/12]: Introduce numeric variable definitionThomas Preud'homme1-97/+197
Summary: This patch is part of a patch series to add support for FileCheck numeric expressions. This specific patch introduces support for defining numeric variable in a CHECK directive. This commit introduces support for defining numeric variable from a litteral value in the input text. Numeric expressions can then use the variable provided it is on a later line. 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/D60386 llvm-svn: 362705
2019-05-23[FileCheck] Introduce substitution subclassesThomas Preud'homme1-17/+18
Summary: With now a clear distinction between string and numeric substitutions, this patch introduces separate classes to represent them with a parent class implementing the common interface. Diagnostics in printSubstitutions() are also adapted to not require knowing which substitution is being looked at since it does not hinder clarity and makes the implementation simpler. Reviewers: jhenderson, jdenny, probinson, arichardson Subscribers: llvm-commits, probinson, arichardson, hiraditya Tags: #llvm Differential Revision: https://reviews.llvm.org/D62241 llvm-svn: 361446