-
Notifications
You must be signed in to change notification settings - Fork 39
Closed
Labels
Description
CppInterOp/lib/Interpreter/CppInterOp.cpp
Lines 58 to 73 in ecbffaf
| static std::unique_ptr<compat::Interpreter> sInterpreter; | |
| // Valgrind complains about __cxa_pure_virtual called when deleting | |
| // llvm::SectionMemoryManager::~SectionMemoryManager as part of the dtor chain | |
| // of the Interpreter. | |
| // This might fix the issue https://reviews.llvm.org/D107087 | |
| // FIXME: For now we just leak the Interpreter. | |
| struct InterpDeleter { | |
| ~InterpDeleter() { sInterpreter.release(); } | |
| } Deleter; | |
| static compat::Interpreter& getInterp() { | |
| assert(sInterpreter.get() && "Must be set before calling this!"); | |
| return *sInterpreter.get(); | |
| } | |
| static clang::Sema& getSema() { return getInterp().getCI()->getSema(); } | |
| static clang::ASTContext& getASTContext() { return getSema().getASTContext(); } |
The interpreter is global and unique at the moment. However, clients do not always agree on the same compiler configuration. I think we need to add more APIs that take compat::Interpreter as argument. For example,
const char* GetResourceDirFromInterpreter(const compat::Interpreter* interp) {
return interp->getCI()->getHeaderSearchOpts().ResourceDir.c_str();
}