diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp --- a/llvm/lib/FileCheck/FileCheck.cpp +++ b/llvm/lib/FileCheck/FileCheck.cpp @@ -146,14 +146,11 @@ 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); } diff --git a/llvm/unittests/FileCheck/FileCheckTest.cpp b/llvm/unittests/FileCheck/FileCheckTest.cpp --- a/llvm/unittests/FileCheck/FileCheckTest.cpp +++ b/llvm/unittests/FileCheck/FileCheckTest.cpp @@ -311,7 +311,6 @@ checkValueFromStringRepr("-5", -5); checkValueFromStringReprFailure(MaxUint64Str); } else { - checkValueFromStringReprFailure("-" + addBasePrefix("5")); checkValueFromStringRepr(addBasePrefix(MaxUint64Str), MaxUint64); } @@ -321,9 +320,6 @@ // Wrong casing is not tested because valueFromStringRepr() relies on // StringRef's getAsInteger() which does not allow to restrict casing. checkValueFromStringReprFailure(addBasePrefix("G")); - - if (AlternateForm) - checkValueFromStringReprFailure("9", "missing alternate form prefix"); } TEST_P(ExpressionFormatParameterisedFixture, FormatBoolOperator) {