Skip to content
Merged
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
16 changes: 15 additions & 1 deletion core/metacling/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,10 @@ static bool LoadModule(const std::string &ModuleName, cling::Interpreter &interp
cling::Interpreter::PushTransactionRAII RAII(&interp);
if (clang::Module *M = moduleMap.findModule(ModuleName)) {
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();
// Also make the module visible in the preprocessor to export its macros.
PP.makeModuleVisible(M, ValidLoc);
return Result;
}
return false;
}
Expand Down Expand Up @@ -1138,6 +1141,17 @@ static void LoadCoreModules(cling::Interpreter &interp)

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

// Check that the gROOT macro was exported by any core module.
assert(interp.getMacro("gROOT") && "Couldn't load gROOT macro?");

// C99 decided that it's a very good idea to name a macro `I` (the letter I).
// This seems to screw up nearly all the template code out there as `I` is
// common template parameter name and iterator variable name.
// Let's follow the GCC recommendation and undefine `I` in case any of the
// core modules have defined it:
// https://www.gnu.org/software/libc/manual/html_node/Complex-Numbers.html
interp.declare("#ifdef I\n #undef I\n #endif\n");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vgvassilev I reply here to your comment on the closed PR. I don't think we call recursively LoadCoreModule or recursively make TCling instances? And if we do, then we already made a good portion of declares before this code for all the other TCling things, so we would anyway be in deep trouble.

Copy link
Member

Choose a reason for hiding this comment

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

I think we ought to reduce all declares in TCling and that seems to be an easy-to-reduce one.

}

static bool FileExists(const char *file)
Expand Down