diff --git a/lib/Interpreter/Interpreter.cpp b/lib/Interpreter/Interpreter.cpp index 93e22a2d..fa08eea1 100644 --- a/lib/Interpreter/Interpreter.cpp +++ b/lib/Interpreter/Interpreter.cpp @@ -840,10 +840,18 @@ namespace cling { if (getSema().isModuleVisible(M)) return true; - Interpreter::PushTransactionRAII RAII(this); - if (declare("#pragma clang module import " + M->Name) == kSuccess) - return true; + Preprocessor& PP = getCI()->getPreprocessor(); + IdentifierInfo *II = PP.getIdentifierInfo(M->Name); + SourceLocation ValidLoc = M->DefinitionLoc; + Interpreter::PushTransactionRAII RAII(this); + bool success = !getCI()->getSema().ActOnModuleImport(ValidLoc, ValidLoc, + std::make_pair(II, ValidLoc)).isInvalid(); + if (success) { + // Also make the module visible in the preprocessor to export its macros. + PP.makeModuleVisible(M, ValidLoc); + return success; + } if (complain) { if (M->IsSystem) llvm::errs() << "Failed to load module " << M->Name << "\n";