File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ 
12#include  " Utils.h" 
23
34#include  " clang/Interpreter/CppInterOp.h" 
5+ 
6+ #ifdef  USE_CLING
7+ #include  " cling/Interpreter/Interpreter.h" 
8+ #endif  //  USE_CLING
9+ 
10+ #ifdef  USE_REPL
11+ #include  " clang/Interpreter/Interpreter.h" 
12+ #endif  //  USE_REPL
13+ 
414#include  " clang/Basic/Version.h" 
515
616#include  " llvm/ADT/SmallString.h" 
@@ -162,3 +172,31 @@ TEST(InterpreterTest, CodeCompletion) {
162172  GTEST_SKIP ();
163173#endif 
164174}
175+ 
176+ TEST (InterpreterTest, ExternalInterpreterTest) {
177+ 
178+ #ifdef  USE_REPL
179+   llvm::ExitOnError ExitOnErr;
180+   clang::IncrementalCompilerBuilder CB;
181+   CB.SetCompilerArgs ({" -std=c++20" //  pass `-xc` for a C REPL.
182+ 
183+   //  Create the incremental compiler instance.
184+   std::unique_ptr<clang::CompilerInstance> CI;
185+   CI = ExitOnErr (CB.CreateCpp ());
186+ 
187+   //  Create the interpreter instance.
188+   std::unique_ptr<clang::Interpreter> I =
189+       ExitOnErr (clang::Interpreter::create (std::move (CI)));
190+ 
191+   auto  ExtInterp = I.get ();
192+ #endif 
193+ 
194+ #ifdef  USE_CLING
195+   cling::Interpreter interp (" /usr/local/" 
196+   compat::Interpreter ExtInterp = &interp;
197+ #endif 
198+ 
199+   EXPECT_NE (ExtInterp, nullptr );
200+   Cpp::UseExternalInterpreter (ExtInterp);
201+   EXPECT_FALSE (Cpp::OwnsInterpreter ());
202+ }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments