From 3ec88ca60b24418b2216de88fad1da4f269f6b8c Mon Sep 17 00:00:00 2001 From: Mitch Phillips <31459023+hctim@users.noreply.github.com> Date: Fri, 2 Jul 2021 10:54:20 -0700 Subject: [PATCH] Revert "[clang-repl] Allow passing in code as positional arguments." This reverts commit e386871e1d21cf206a1287356e88c5853563fc77. Reason: Broke the ASan buildbots (https://lab.llvm.org/buildbot/#/builders/5/builds/9291). See comments on https://reviews.llvm.org/D104898 for more information. --- clang/test/Interpreter/execute.cpp | 7 +------ clang/tools/clang-repl/ClangRepl.cpp | 22 ++++++---------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/clang/test/Interpreter/execute.cpp b/clang/test/Interpreter/execute.cpp index 730796b..108b79b 100644 --- a/clang/test/Interpreter/execute.cpp +++ b/clang/test/Interpreter/execute.cpp @@ -1,12 +1,7 @@ -// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \ -// RUN: 'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s +// RUN: cat %s | clang-repl | FileCheck %s // REQUIRES: host-supports-jit // UNSUPPORTED: system-aix -// CHECK-DRIVER: i = 10 - -// RUN: cat %s | clang-repl | FileCheck %s - extern "C" int printf(const char *, ...); int i = 42; auto r1 = printf("i = %d\n", i); diff --git a/clang/tools/clang-repl/ClangRepl.cpp b/clang/tools/clang-repl/ClangRepl.cpp index ba6bb11..b5b5bf6 100644 --- a/clang/tools/clang-repl/ClangRepl.cpp +++ b/clang/tools/clang-repl/ClangRepl.cpp @@ -28,9 +28,6 @@ static llvm::cl::list llvm::cl::CommaSeparated); static llvm::cl::opt OptHostSupportsJit("host-supports-jit", llvm::cl::Hidden); -static llvm::cl::list OptInputs(llvm::cl::Positional, - llvm::cl::ZeroOrMore, - llvm::cl::desc("[code to run]")); static void LLVMErrorHandler(void *UserData, const std::string &Message, bool GenCrashDiag) { @@ -81,22 +78,15 @@ int main(int argc, const char **argv) { static_cast(&CI->getDiagnostics())); auto Interp = ExitOnErr(clang::Interpreter::create(std::move(CI))); - for (const std::string &input : OptInputs) { - if (auto Err = Interp->ParseAndExecute(input)) + llvm::LineEditor LE("clang-repl"); + // FIXME: Add LE.setListCompleter + while (llvm::Optional Line = LE.readLine()) { + if (*Line == "quit") + break; + if (auto Err = Interp->ParseAndExecute(*Line)) llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: "); } - if (OptInputs.empty()) { - llvm::LineEditor LE("clang-repl"); - // FIXME: Add LE.setListCompleter - while (llvm::Optional Line = LE.readLine()) { - if (*Line == "quit") - break; - if (auto Err = Interp->ParseAndExecute(*Line)) - llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: "); - } - } - // Our error handler depends on the Diagnostics object, which we're // potentially about to delete. Uninstall the handler now so that any // later errors use the default handling behavior instead. -- 2.7.4