aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/FileCheck/FileCheck.cpp
diff options
context:
space:
mode:
authorThomas Preud'homme <thomas.preudhomme@arm.com>2023-05-16 09:22:01 +0000
committerThomas Preud'homme <thomas.preudhomme@arm.com>2023-05-23 13:52:22 +0100
commit13eb298d5c3c31550fee0c889d3fd3a265450e3d (patch)
tree5b785f0006cee7f2434c625f5b60fcb15e0bf39d /llvm/lib/FileCheck/FileCheck.cpp
parentc37ced7d026e2629aa513f935f0ff46215f7d09e (diff)
downloadllvm-13eb298d5c3c31550fee0c889d3fd3a265450e3d.zip
llvm-13eb298d5c3c31550fee0c889d3fd3a265450e3d.tar.gz
llvm-13eb298d5c3c31550fee0c889d3fd3a265450e3d.tar.bz2
Turn unreachable error into assert
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. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D150797
Diffstat (limited to 'llvm/lib/FileCheck/FileCheck.cpp')
-rw-r--r--llvm/lib/FileCheck/FileCheck.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp
index ebebe05..f02e630 100644
--- a/llvm/lib/FileCheck/FileCheck.cpp
+++ b/llvm/lib/FileCheck/FileCheck.cpp
@@ -146,14 +146,11 @@ ExpressionFormat::valueFromStringRepr(StringRef StrVal,
bool Hex = Value == Kind::HexUpper || Value == Kind::HexLower;
uint64_t UnsignedValue;
bool MissingFormPrefix = AlternateForm && !StrVal.consume_front("0x");
+ (void)MissingFormPrefix;
+ assert(!MissingFormPrefix && "missing alternate form prefix");
if (StrVal.getAsInteger(Hex ? 16 : 10, UnsignedValue))
return ErrorDiagnostic::get(SM, StrVal, IntegerParseErrorStr);
- // Error out for a missing prefix only now that we know we have an otherwise
- // valid integer. For example, "-0x18" is reported above instead.
- if (MissingFormPrefix)
- return ErrorDiagnostic::get(SM, StrVal, "missing alternate form prefix");
-
return ExpressionValue(UnsignedValue);
}