Skip to content

Commit 4afd5c5

Browse files
Teemperorvgvassilev
authored andcommitted
[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.
1 parent 2d6ece7 commit 4afd5c5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

core/metacling/src/TCling.cxx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,10 @@ static bool LoadModule(const std::string &ModuleName, cling::Interpreter &interp
11051105
cling::Interpreter::PushTransactionRAII RAII(&interp);
11061106
if (clang::Module *M = moduleMap.findModule(ModuleName)) {
11071107
clang::IdentifierInfo *II = PP.getIdentifierInfo(M->Name);
1108-
return !CI.getSema().ActOnModuleImport(ValidLoc, ValidLoc, std::make_pair(II, ValidLoc)).isInvalid();
1108+
bool Result = !CI.getSema().ActOnModuleImport(ValidLoc, ValidLoc, std::make_pair(II, ValidLoc)).isInvalid();
1109+
// Also make the module visible in the preprocessor to export its macros.
1110+
PP.makeModuleVisible(M, ValidLoc);
1111+
return Result;
11091112
}
11101113
return false;
11111114
}
@@ -1138,6 +1141,10 @@ static void LoadCoreModules(cling::Interpreter &interp)
11381141

11391142
if (!LoadModule(moduleMap.findModule("RIO")->Name, interp))
11401143
Error("TCling::LoadCoreModules", "Cannot load module RIO");
1144+
1145+
// Check that the gROOT macro was exported by any core module.
1146+
assert(interp.getMacro("gROOT") && "Couldn't load gROOT macro?");
1147+
>>>>>>> [cxxmodules] Fixed macro loading in LoadModule
11411148
}
11421149

11431150
static bool FileExists(const char *file)

0 commit comments

Comments
 (0)