Skip to content
Closed
Changes from 1 commit
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
Next Next commit
[cxxmodules] Fixed macro loading in LoadModule
In clang there are two records of what modules are visible: One
VisibleModuleSet is in the preprocessor, one is in the sema. In
the current code we only make every core module visible in sema,
but no in the preprocessor. This causes that we can load decls
from the core modules with that, but we can't load macros from
them as they are still invisible in the preprocessor.

This patch just also makes the module visible in the preprocessor.
  • Loading branch information
Teemperor committed Nov 28, 2017
commit d735b5d0db922835e5752d49008bc73ae9d47b5e
8 changes: 7 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,9 @@ static void LoadCoreModules(cling::Interpreter &interp)

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

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

static bool FileExists(const char *file)
Expand Down