Skip to content

Commit 75bb29e

Browse files
authored
Forward declare input to process so it's registered in JIT (#238)
1 parent 6ee85f6 commit 75bb29e

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

lib/Interpreter/CppInterOpInterpreter.h

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,7 @@ class Interpreter {
253253

254254
CompilationResult declare(const std::string& input,
255255
clang::PartialTranslationUnit** PTU = nullptr) {
256-
auto PTUOrErr = Parse(input);
257-
if (!PTUOrErr) {
258-
llvm::logAllUnhandledErrors(PTUOrErr.takeError(), llvm::errs(),
259-
"Failed to parse via ::process:");
260-
return Interpreter::kFailure;
261-
}
262-
if (PTU)
263-
*PTU = &*PTUOrErr;
264-
return Interpreter::kSuccess;
256+
return process(input, /*Value=*/nullptr, PTU);
265257
}
266258

267259
///\brief Maybe transform the input line to implement cint command line
@@ -270,14 +262,17 @@ class Interpreter {
270262
CompilationResult process(const std::string& input, clang::Value* V = 0,
271263
clang::PartialTranslationUnit** PTU = nullptr,
272264
bool disableValuePrinting = false) {
273-
clang::PartialTranslationUnit* ParsePTU = nullptr;
274-
if (declare(input, &ParsePTU))
265+
auto PTUOrErr = Parse(input);
266+
if (!PTUOrErr) {
267+
llvm::logAllUnhandledErrors(PTUOrErr.takeError(), llvm::errs(),
268+
"Failed to parse via ::process:");
275269
return Interpreter::kFailure;
270+
}
276271

277272
if (PTU)
278-
*PTU = ParsePTU;
273+
*PTU = &*PTUOrErr;
279274

280-
if (auto Err = Execute(*ParsePTU)) {
275+
if (auto Err = Execute(*PTUOrErr)) {
281276
llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(),
282277
"Failed to execute via ::process:");
283278
return Interpreter::kFailure;

0 commit comments

Comments
 (0)