[PATCH] D150797: Turn unreachable error into assert

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 23 05:52:29 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG13eb298d5c3c: Turn unreachable error into assert (authored by thopre).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150797/new/

https://reviews.llvm.org/D150797

Files:
  llvm/lib/FileCheck/FileCheck.cpp
  llvm/unittests/FileCheck/FileCheckTest.cpp


Index: llvm/unittests/FileCheck/FileCheckTest.cpp
===================================================================
--- llvm/unittests/FileCheck/FileCheckTest.cpp
+++ 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) {
Index: llvm/lib/FileCheck/FileCheck.cpp
===================================================================
--- llvm/lib/FileCheck/FileCheck.cpp
+++ 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);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150797.524668.patch
Type: text/x-patch
Size: 1772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230523/8b8f99a5/attachment.bin>


More information about the llvm-commits mailing list