Function valueFromStringRepr() throws an error on missing 0x prefix when
parsing a number string into a value. However, getWildcardRegex() already
ensures that only text with the 0x prefix will match and be parsed,
making that error throwing code dead code. This commit turn the code
into an assert and remove the unit tests exercising that test
accordingly.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Given that there are unit tests, this code is in the library's public-facing API. Does removing the error check cause problems if users happen to be leveraging the FileCheck library in some manner?
It is in the library but not exposed in the FileCheck library header. The unit tests use the FileCheck internal header. The library interface is much higher level than that: it is essentially composed of the readCheckFile and checkInput functions. Everything else is internal.
llvm/lib/FileCheck/FileCheck.cpp | ||
---|---|---|
148–151 | I'd get rid of the unnecessary temporary and just do the calculation inline. Also, is this the right place for the assert? Previously the error was later in the code. |
llvm/lib/FileCheck/FileCheck.cpp | ||
---|---|---|
148–151 | Will the consume_front() happen if it's inside the assert though? Because under normal circumstances (i.e. assert does not trip) the consume_front() *must* happen for the function to do the right thing. |
LGTM, with one nit.
llvm/lib/FileCheck/FileCheck.cpp | ||
---|---|---|
148–151 | Bleh, I missed that consume_front has side effects beyond getting the return value. Okay, I can't think of any real improvements (other than I think static_cast is preferred generally to C-style casts). |
llvm/lib/FileCheck/FileCheck.cpp | ||
---|---|---|
148–151 | I agree in the general case but there is not a single use of static_cast<void> to indicate a function return value being ignored in the llvm/ subtree. There is however plenty of (void) C-style cast example. Ok to land as is? |
Go ahead with landing. I'm going to start a discussion on Discourse about coding style for casts as I don't see it discussed anywhere in the coding standards.
I'd get rid of the unnecessary temporary and just do the calculation inline.
Also, is this the right place for the assert? Previously the error was later in the code.