Skip to content

Commit

Permalink
Revert "[clang-repl] Allow passing in code as positional arguments."
Browse files Browse the repository at this point in the history
This reverts commit e386871.

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.
  • Loading branch information
hctim committed Jul 2, 2021
1 parent 4525d52 commit 3ec88ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
7 changes: 1 addition & 6 deletions clang/test/Interpreter/execute.cpp
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
22 changes: 6 additions & 16 deletions clang/tools/clang-repl/ClangRepl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ static llvm::cl::list<std::string>
llvm::cl::CommaSeparated);
static llvm::cl::opt<bool> OptHostSupportsJit("host-supports-jit",
llvm::cl::Hidden);
static llvm::cl::list<std::string> OptInputs(llvm::cl::Positional,
llvm::cl::ZeroOrMore,
llvm::cl::desc("[code to run]"));

static void LLVMErrorHandler(void *UserData, const std::string &Message,
bool GenCrashDiag) {
Expand Down Expand Up @@ -81,22 +78,15 @@ int main(int argc, const char **argv) {
static_cast<void *>(&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<std::string> 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<std::string> 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.
Expand Down

0 comments on commit 3ec88ca

Please sign in to comment.