[PATCH] D105292: [NFC] Mark Expected<T>::assertIsChecked() as const

xndcn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 1 09:03:43 PDT 2021


xndcn created this revision.
xndcn added reviewers: chandlerc, lhames, labath.
Herald added a subscriber: dexonsmith.
xndcn requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Some const methods of Expected<T> invoke assertIsChecked(), so we should mark it as const too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105292

Files:
  llvm/include/llvm/Support/Error.h
  llvm/unittests/Support/ErrorTest.cpp


Index: llvm/unittests/Support/ErrorTest.cpp
===================================================================
--- llvm/unittests/Support/ErrorTest.cpp
+++ llvm/unittests/Support/ErrorTest.cpp
@@ -565,7 +565,7 @@
 // Test runs in debug mode only.
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
 TEST(Error, UncheckedExpectedInSuccessModeAccess) {
-  EXPECT_DEATH({ Expected<int> A = 7; *A; },
+  EXPECT_DEATH({ const Expected<int> A = 7; *A; },
                "Expected<T> must be checked before access or destruction.")
     << "Unchecekd Expected<T> success value did not cause an abort().";
 }
Index: llvm/include/llvm/Support/Error.h
===================================================================
--- llvm/include/llvm/Support/Error.h
+++ llvm/include/llvm/Support/Error.h
@@ -670,7 +670,7 @@
   }
 #endif
 
-  void assertIsChecked() {
+  void assertIsChecked() const {
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
     if (LLVM_UNLIKELY(Unchecked))
       fatalUncheckedExpected();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105292.355902.patch
Type: text/x-patch
Size: 976 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210701/76b06c06/attachment.bin>


More information about the llvm-commits mailing list