瀏覽代碼

Removed std::exit() from RawExitingStream, as this functionality has been migrated to returning error codes (#1175)

pk19604014 4 年之前
父節點
當前提交
a28cbd29b5
共有 2 個文件被更改,包括 5 次插入19 次删除
  1. 4 4
      common/check.h
  2. 1 15
      common/check_internal.h

+ 4 - 4
common/check.h

@@ -23,7 +23,7 @@ namespace Carbon {
 //   CHECK(is_valid) << "Data is not valid!";
 #define CHECK(condition)                                                  \
   (condition) ? (void)0                                                   \
-              : RAW_EXITING_STREAM().TreatAsBug()                         \
+              : RAW_EXITING_STREAM()                                      \
                     << "CHECK failure at " << __FILE__ << ":" << __LINE__ \
                     << ": " #condition                                    \
                     << Carbon::Internal::ExitingStream::AddSeparator()
@@ -40,9 +40,9 @@ namespace Carbon {
 //
 // For example:
 //   FATAL() << "Unreachable!";
-#define FATAL()                     \
-  RAW_EXITING_STREAM().TreatAsBug() \
-      << "FATAL failure at " << __FILE__ << ":" << __LINE__ << ": "
+#define FATAL()                                                              \
+  RAW_EXITING_STREAM() << "FATAL failure at " << __FILE__ << ":" << __LINE__ \
+                       << ": "
 
 }  // namespace Carbon
 

+ 1 - 15
common/check_internal.h

@@ -30,13 +30,6 @@ class ExitingStream {
         "destruction!");
   }
 
-  // Indicates that the program is exiting due to a bug in the program, rather
-  // than, e.g., invalid input.
-  auto TreatAsBug() -> ExitingStream& {
-    treat_as_bug_ = true;
-    return *this;
-  }
-
   // If the bool cast occurs, it's because the condition is false. This supports
   // && short-circuiting the creation of ExitingStream.
   explicit operator bool() const { return true; }
@@ -63,19 +56,12 @@ class ExitingStream {
   [[noreturn]] friend auto operator|(Helper /*discarded*/, ExitingStream& rhs) {
     // Finish with a newline.
     llvm::errs() << "\n";
-    if (rhs.treat_as_bug_) {
-      std::abort();
-    } else {
-      std::exit(-1);
-    }
+    std::abort();
   }
 
  private:
   // Whether a separator should be printed if << is used again.
   bool separator_ = false;
-
-  // Whether the program is exiting due to a bug.
-  bool treat_as_bug_ = false;
 };
 
 }  // namespace Carbon::Internal