Skip to content

Commit 3ec88ca

Browse files
committed
Revert "[clang-repl] Allow passing in code as positional arguments."
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.
1 parent 4525d52 commit 3ec88ca

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

clang/test/Interpreter/execute.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
2-
// RUN: 'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
1+
// RUN: cat %s | clang-repl | FileCheck %s
32
// REQUIRES: host-supports-jit
43
// UNSUPPORTED: system-aix
54

6-
// CHECK-DRIVER: i = 10
7-
8-
// RUN: cat %s | clang-repl | FileCheck %s
9-
105
extern "C" int printf(const char *, ...);
116
int i = 42;
127
auto r1 = printf("i = %d\n", i);

clang/tools/clang-repl/ClangRepl.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ static llvm::cl::list<std::string>
2828
llvm::cl::CommaSeparated);
2929
static llvm::cl::opt<bool> OptHostSupportsJit("host-supports-jit",
3030
llvm::cl::Hidden);
31-
static llvm::cl::list<std::string> OptInputs(llvm::cl::Positional,
32-
llvm::cl::ZeroOrMore,
33-
llvm::cl::desc("[code to run]"));
3431

3532
static void LLVMErrorHandler(void *UserData, const std::string &Message,
3633
bool GenCrashDiag) {
@@ -81,22 +78,15 @@ int main(int argc, const char **argv) {
8178
static_cast<void *>(&CI->getDiagnostics()));
8279

8380
auto Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
84-
for (const std::string &input : OptInputs) {
85-
if (auto Err = Interp->ParseAndExecute(input))
81+
llvm::LineEditor LE("clang-repl");
82+
// FIXME: Add LE.setListCompleter
83+
while (llvm::Optional<std::string> Line = LE.readLine()) {
84+
if (*Line == "quit")
85+
break;
86+
if (auto Err = Interp->ParseAndExecute(*Line))
8687
llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
8788
}
8889

89-
if (OptInputs.empty()) {
90-
llvm::LineEditor LE("clang-repl");
91-
// FIXME: Add LE.setListCompleter
92-
while (llvm::Optional<std::string> Line = LE.readLine()) {
93-
if (*Line == "quit")
94-
break;
95-
if (auto Err = Interp->ParseAndExecute(*Line))
96-
llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
97-
}
98-
}
99-
10090
// Our error handler depends on the Diagnostics object, which we're
10191
// potentially about to delete. Uninstall the handler now so that any
10292
// later errors use the default handling behavior instead.

0 commit comments

Comments
 (0)