Skip to content
Merged
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 fd1da545933cab269b2922f2caf4a6c65d26ae91
9 changes: 8 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,10 @@ 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?");
>>>>>>> [cxxmodules] Fixed macro loading in LoadModule
}

static bool FileExists(const char *file)
Expand Down