Use APInt to represent numeric variables and expressions, therefore
removing overflow concerns. Only remains underflow when the format of an
expression is unsigned (incl. hex values) but the result is negative.
Note that this can only happen when substituting an expression, not when
capturing since the regex used to capture unsigned value will not include
minus sign, hence all the code removal for match propagation testing.
This is what this patch implement.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Overall LGTM but as this is a rather large diff I may have missed something.
llvm/lib/FileCheck/FileCheck.cpp | ||
---|---|---|
153 | [[maybe_unused]] for the variable instead of the void cast? | |
llvm/lib/FileCheck/FileCheckImpl.h | ||
121 | To reduce the size of the diff we could have this class wrap a single apint but since you've made the changes to remove it already I think we may as well remove it. | |
155 | Hmm maybe we should add using ExpressionValue = APInt to avoid all these changes. | |
llvm/test/FileCheck/match-time-error-propagation/matched-excluded-pattern.txt | ||
4 | It seems like some of this test is still useful, we just have to create a different error? | |
llvm/unittests/FileCheck/FileCheckTest.cpp | ||
384 | The test previously used 64 bit values, do we need 128 bit here? |
Sorry @thopre, I have too many other reviews on my plate to ever realistically be able to get around to this.
I'll try your suggestion to see if we can have 2 smaller diffs instead. Do you have any opinion on the question in the second paragraph of the description?
llvm/lib/FileCheck/FileCheckImpl.h | ||
---|---|---|
121 | That's a good idea, I'll explore this to see if I can create 2 patches instead of 1. I don't mind a bit more work if it makes for an easier review. | |
155 | They have different interface but I could use APInt inside ExpressionValue instead of int64_t as suggested above. |
- Split APInt change into separate patches and only keep changes to support arbitrary precision
- use [[maybe_unused]] instead of (void)
llvm/test/FileCheck/match-time-error-propagation/matched-excluded-pattern.txt | ||
---|---|---|
4 | This patch removes the one case where the error path tested by these tests can happen. After this patch the parsing of integer in valueFromStringRepr() would need to fail for the path to be triggered by the regex used to match numeric values ensures that integer are valid. See https://reviews.llvm.org/D154431 for more details. |
llvm/lib/FileCheck/FileCheck.cpp | ||
---|---|---|
223 | std::max? | |
229 | The API might be a bit nicer if evalbinop did the widening of apints? | |
240 | This should be unnecessary. | |
llvm/test/FileCheck/match-time-error-propagation/matched-excluded-pattern.txt | ||
4 | Ah fair enough that makes sense. Is the error handling still tested after removing this test? If not, could keep coverage by changing the error to be a divide by zero? |
llvm/lib/FileCheck/FileCheck.cpp | ||
---|---|---|
229 | EvalBinop is a function pointer to one of the expr* functions above. That would mean adding that logic in all those functions. This code here is in a single place instead. I could split it out into a separate function if you prefer? | |
llvm/test/FileCheck/match-time-error-propagation/matched-excluded-pattern.txt | ||
4 | TL;DR: the code tested by this is dead code, it cannot be exercise. Long answer: |
Looks good to me. Sorry for the delay.
llvm/lib/FileCheck/FileCheck.cpp | ||
---|---|---|
229 | Ah yes of course. I don't really mind, so this should be fine. |
[[maybe_unused]] for the variable instead of the void cast?