@@ -136,11 +136,14 @@ class Interpreter {
136136private:
137137 std::unique_ptr<clang::Interpreter> inner;
138138
139+ Interpreter (std::unique_ptr<clang::Interpreter> CI) : inner(std::move(CI)) {}
140+
139141public:
140- Interpreter (int argc, const char * const * argv, const char * llvmdir = 0 ,
141- const std::vector<std::shared_ptr<clang::ModuleFileExtension>>&
142- moduleExtensions = {},
143- void * extraLibHandle = 0 , bool noRuntime = true ) {
142+ static std::unique_ptr<Interpreter>
143+ create (int argc, const char * const * argv, const char * llvmdir = nullptr ,
144+ const std::vector<std::shared_ptr<clang::ModuleFileExtension>>&
145+ moduleExtensions = {},
146+ void * extraLibHandle = nullptr , bool noRuntime = true ) {
144147 // Initialize all targets (required for device offloading)
145148 llvm::InitializeAllTargetInfos ();
146149 llvm::InitializeAllTargets ();
@@ -150,7 +153,13 @@ class Interpreter {
150153 std::vector<const char *> vargs (argv + 1 , argv + argc);
151154 vargs.push_back (" -include" );
152155 vargs.push_back (" new" );
153- inner = compat::createClangInterpreter (vargs);
156+ auto CI = compat::createClangInterpreter (vargs);
157+ if (!CI) {
158+ llvm::errs () << " Interpreter creation failed\n " ;
159+ return nullptr ;
160+ }
161+
162+ return std::unique_ptr<Interpreter>(new Interpreter (std::move (CI)));
154163 }
155164
156165 ~Interpreter () {}
0 commit comments