[clang] [clang-repl] Fix the process return code if diagnostics occurred. (PR #89879)

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 24 09:12:30 PDT 2024


================
@@ -241,18 +243,13 @@ int main(int argc, const char **argv) {
         break;
       }
       if (Input == R"(%undo)") {
-        if (auto Err = Interp->Undo()) {
+        if (auto Err = Interp->Undo())
           llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
-          HasError = true;
-        }
       } else if (Input.rfind("%lib ", 0) == 0) {
-        if (auto Err = Interp->LoadDynamicLibrary(Input.data() + 5)) {
+        if (auto Err = Interp->LoadDynamicLibrary(Input.data() + 5))
           llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
-          HasError = true;
----------------
vgvassilev wrote:

The idea is that when you use interactive mode and it recovers from errors properly to return success as exit code. However, for the when run it in non interactive mode people might use clang-repl as a calculator eg `clang-repl "printf(...)"` and can be put in scripts. There we want to get exit code 1 if it miscompiled something.

https://github.com/llvm/llvm-project/pull/89879


More information about the cfe-commits mailing list