aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/FileCheck/FileCheck.cpp
diff options
context:
space:
mode:
authorThomas Preud'homme <thomasp@graphcore.ai>2021-03-10 13:43:20 +0000
committerThomas Preud'homme <thomasp@graphcore.ai>2021-03-11 10:31:04 +0000
commitc347619bc2baef2d0e494e8350bd21546a6c126f (patch)
tree7b01a20d9416942e5a160ac1263412ee4c4c78dd /llvm/lib/FileCheck/FileCheck.cpp
parente74d6269259e28225a494ce98bd1762cdac1fe89 (diff)
downloadllvm-c347619bc2baef2d0e494e8350bd21546a6c126f.zip
llvm-c347619bc2baef2d0e494e8350bd21546a6c126f.tar.gz
llvm-c347619bc2baef2d0e494e8350bd21546a6c126f.tar.bz2
[FileCheck] Fix naming of OverflowErrorStr var
As pointed out by Joel E. Denny in D97845, the OverflowErrorStr variable is misnamed because the error is raised for any parsing error. Note that in FileCheck proper this only happens in case of (under|over)flow because the regex will ensure a number in the correct format is matched. Reviewed By: jdenny Differential Revision: https://reviews.llvm.org/D98342
Diffstat (limited to 'llvm/lib/FileCheck/FileCheck.cpp')
-rw-r--r--llvm/lib/FileCheck/FileCheck.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp
index 712c6ed..9a4c866 100644
--- a/llvm/lib/FileCheck/FileCheck.cpp
+++ b/llvm/lib/FileCheck/FileCheck.cpp
@@ -121,12 +121,17 @@ Expected<ExpressionValue>
ExpressionFormat::valueFromStringRepr(StringRef StrVal,
const SourceMgr &SM) const {
bool ValueIsSigned = Value == Kind::Signed;
- StringRef OverflowErrorStr = "unable to represent numeric value";
+ // 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.
+ StringRef IntegerParseErrorStr = "unable to represent numeric value";
if (ValueIsSigned) {
int64_t SignedValue;
if (StrVal.getAsInteger(10, SignedValue))
- return ErrorDiagnostic::get(SM, StrVal, OverflowErrorStr);
+ return ErrorDiagnostic::get(SM, StrVal, IntegerParseErrorStr);
return ExpressionValue(SignedValue);
}
@@ -134,7 +139,7 @@ ExpressionFormat::valueFromStringRepr(StringRef StrVal,
bool Hex = Value == Kind::HexUpper || Value == Kind::HexLower;
uint64_t UnsignedValue;
if (StrVal.getAsInteger(Hex ? 16 : 10, UnsignedValue))
- return ErrorDiagnostic::get(SM, StrVal, OverflowErrorStr);
+ return ErrorDiagnostic::get(SM, StrVal, IntegerParseErrorStr);
return ExpressionValue(UnsignedValue);
}