[PATCH] D98342: [FileCheck] Fix naming of OverflowErrorStr var

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 11 02:31:00 PST 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc347619bc2ba: [FileCheck] Fix naming of OverflowErrorStr var (authored by thopre).

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.329893.patch
Type: text/x-patch
Size: 1516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210311/4ff15b0c/attachment.bin>


More information about the llvm-commits mailing list