diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/FileCheck/FileCheck.cpp | 26 | ||||
-rw-r--r-- | llvm/lib/FileCheck/FileCheckImpl.h | 7 |
2 files changed, 12 insertions, 21 deletions
diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp index 60a0d59..49fda8f 100644 --- a/llvm/lib/FileCheck/FileCheck.cpp +++ b/llvm/lib/FileCheck/FileCheck.cpp @@ -134,15 +134,9 @@ static APInt toSigned(APInt AbsVal, bool Negative) { return Result; } -Expected<APInt> -ExpressionFormat::valueFromStringRepr(StringRef StrVal, - const SourceMgr &SM) const { +APInt ExpressionFormat::valueFromStringRepr(StringRef StrVal, + const SourceMgr &SM) const { bool ValueIsSigned = Value == Kind::Signed; - // Both the FileCheck utility and library only call this method with a valid - // value in StrVal. This is guaranteed by the regex returned by - // getWildcardRegex() above. Only underflow and overflow errors can thus - // occur. However new uses of this method could be added in the future so - // the error message does not make assumptions about StrVal. bool Negative = StrVal.consume_front("-"); bool Hex = Value == Kind::HexUpper || Value == Kind::HexLower; bool MissingFormPrefix = @@ -150,10 +144,12 @@ ExpressionFormat::valueFromStringRepr(StringRef StrVal, (void)MissingFormPrefix; assert(!MissingFormPrefix && "missing alternate form prefix"); APInt ResultValue; - bool ParseFailure = StrVal.getAsInteger(Hex ? 16 : 10, ResultValue); - if (ParseFailure) - return ErrorDiagnostic::get(SM, StrVal, - "unable to represent numeric value"); + [[maybe_unused]] bool ParseFailure = + StrVal.getAsInteger(Hex ? 16 : 10, ResultValue); + // Both the FileCheck utility and library only call this method with a valid + // value in StrVal. This is guaranteed by the regex returned by + // getWildcardRegex() above. + assert(!ParseFailure && "unable to represent numeric value"); return toSigned(ResultValue, Negative); } @@ -1176,10 +1172,8 @@ Pattern::MatchResult Pattern::match(StringRef Buffer, StringRef MatchedValue = MatchInfo[CaptureParenGroup]; ExpressionFormat Format = DefinedNumericVariable->getImplicitFormat(); - Expected<APInt> Value = Format.valueFromStringRepr(MatchedValue, SM); - if (!Value) - return MatchResult(TheMatch, Value.takeError()); - DefinedNumericVariable->setValue(*Value, MatchedValue); + APInt Value = Format.valueFromStringRepr(MatchedValue, SM); + DefinedNumericVariable->setValue(Value, MatchedValue); } return MatchResult(TheMatch, Error::success()); diff --git a/llvm/lib/FileCheck/FileCheckImpl.h b/llvm/lib/FileCheck/FileCheckImpl.h index f5f8ea2..c154616 100644 --- a/llvm/lib/FileCheck/FileCheckImpl.h +++ b/llvm/lib/FileCheck/FileCheckImpl.h @@ -96,11 +96,8 @@ public: Expected<std::string> getMatchingString(APInt Value) const; /// \returns the value corresponding to string representation \p StrVal - /// according to the matching format represented by this instance or an error - /// with diagnostic against \p SM if \p StrVal does not correspond to a valid - /// and representable value. - Expected<APInt> valueFromStringRepr(StringRef StrVal, - const SourceMgr &SM) const; + /// according to the matching format represented by this instance. + APInt valueFromStringRepr(StringRef StrVal, const SourceMgr &SM) const; }; /// Class to represent an overflow error that might result when manipulating a |