@@ -136,11 +136,14 @@ class Interpreter {
136
136
private:
137
137
std::unique_ptr<clang::Interpreter> inner;
138
138
139
+ Interpreter (std::unique_ptr<clang::Interpreter> CI) : inner(std::move(CI)) {}
140
+
139
141
public:
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 ) {
144
147
// Initialize all targets (required for device offloading)
145
148
llvm::InitializeAllTargetInfos ();
146
149
llvm::InitializeAllTargets ();
@@ -150,7 +153,13 @@ class Interpreter {
150
153
std::vector<const char *> vargs (argv + 1 , argv + argc);
151
154
vargs.push_back (" -include" );
152
155
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)));
154
163
}
155
164
156
165
~Interpreter () {}
0 commit comments