[PATCH] D98342: [FileCheck] Fix naming of OverflowErrorStr var
Thomas Preud'homme via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 10 14:20:54 PST 2021
thopre updated this revision to Diff 329772.
thopre marked an inline comment as done.
thopre added a comment.
Add comment to explain why the error message does not mention underflow/overflow
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98342/new/
https://reviews.llvm.org/D98342
Files:
llvm/lib/FileCheck/FileCheck.cpp
Index: llvm/lib/FileCheck/FileCheck.cpp
===================================================================
--- llvm/lib/FileCheck/FileCheck.cpp
+++ llvm/lib/FileCheck/FileCheck.cpp
@@ -121,12 +121,17 @@
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 @@
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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98342.329772.patch
Type: text/x-patch
Size: 1516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210310/34f9eda6/attachment.bin>
More information about the llvm-commits
mailing list