Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions core/metacling/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1098,14 +1098,13 @@ static bool LoadModule(const std::string &ModuleName, cling::Interpreter &interp
clang::HeaderSearch &headerSearch = PP.getHeaderSearchInfo();
clang::ModuleMap &moduleMap = headerSearch.getModuleMap();

cling::Transaction* T = nullptr;
interp.declare("/*This is decl is to get a valid sloc...*/;", &T);
SourceLocation ValidLoc = T->decls_begin()->m_DGR.getSingleDecl()->getLocStart();
// CreateImplicitModuleImportNoInit creates decls.
cling::Interpreter::PushTransactionRAII RAII(&interp);
if (clang::Module *M = moduleMap.findModule(ModuleName)) {
cling::Interpreter::PushTransactionRAII RAII(&interp);
SourceLocation ValidLoc = M->DefinitionLoc;
clang::IdentifierInfo *II = PP.getIdentifierInfo(M->Name);
return !CI.getSema().ActOnModuleImport(ValidLoc, ValidLoc, std::make_pair(II, ValidLoc)).isInvalid();
bool Result = !CI.getSema().ActOnModuleImport(ValidLoc, ValidLoc, std::make_pair(II, ValidLoc)).isInvalid();
PP.makeModuleVisible(M, ValidLoc);
return Result;
}
return false;
}
Expand Down Expand Up @@ -1138,6 +1137,10 @@ static void LoadCoreModules(cling::Interpreter &interp)

if (!LoadModule(moduleMap.findModule("RIO")->Name, interp))
Error("TCling::LoadCodeModule", "Cannot load module RIO");

assert(interp.getMacro("gROOT") && "Couldn't load gROOT macro?");
interp.declare("#include <cassert>\n");
interp.declare("#ifdef I\n #undef I\n #endif\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move that in the else part of case LIBM? Probably we can use a PP API to undefine I and avoid recursive parsing.

}

static bool FileExists(const char *file)
Expand Down Expand Up @@ -1925,7 +1928,11 @@ void TCling::RegisterModule(const char* modulename,
#endif
#endif

if (!hasHeaderParsingOnDemand){
llvm::StringRef CxxModule = StringRef(modulename);
bool b = CxxModule.consume_front("lib");
(void)b;
if (LoadModule(CxxModule, *fInterpreter)) {
} else if (!hasHeaderParsingOnDemand){
SuspendAutoParsing autoParseRaii(this);

const cling::Transaction* watermark = fInterpreter->getLastTransaction();
Expand Down