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 | ||
---|---|---|
161 | [[maybe_unused]] for the variable instead of the void cast? | |
llvm/lib/FileCheck/FileCheckImpl.h | ||
122 | 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. | |
161 | 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 | ||
398 | 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 | ||
---|---|---|
122 | 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. | |
161 | 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 | ||
---|---|---|
246 | std::max? | |
252 | The API might be a bit nicer if evalbinop did the widening of apints? | |
263 | 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 | ||
---|---|---|
252 | 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 | ||
---|---|---|
252 | Ah yes of course. I don't really mind, so this should be fine. |
[[maybe_unused]] for the variable instead of the void cast?