Ignore import decls to delay the running module inits.
If we preload modules using cling::Interpreter::loadModule the deserializations of the module initializers (such as global variables). We want the behavior of clang::Sema::ActOnModuleImport, however, it requires valid source locations. This patch ignores the ImportDecls which presumably came from loadModule.
This commit is contained in:
parent
2c92b57062
commit
1a1a84dfcb
@ -56,6 +56,7 @@ namespace {
|
||||
if (VD->hasGlobalStorage() && !VD->getType().isConstQualified()
|
||||
&& VD->getTemplateSpecializationKind() == TSK_Undeclared)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -231,6 +232,18 @@ namespace cling {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
||||
// FIXME: This is a temporary fix for the ROOT module preloading mechanism.
|
||||
// When we preload modules we would like to enable a module as if we called
|
||||
// clang::Sema::ActOnModuleImport (which does not call HandleTopLevelDecl).
|
||||
// However, we need a valid source locations as modules are very sensitive
|
||||
// to them. In order to have a valid source location,
|
||||
// Interpreter::loadModule calls '#pragma clang module import "A"', which
|
||||
// calls HandleTopLevelDecl which causes CodeGen to run the module
|
||||
// initializers eagerly.
|
||||
if (DGR.isSingleDecl() && isa<ImportDecl>(DGR.getSingleDecl()))
|
||||
return true;
|
||||
|
||||
m_Consumer->HandleTopLevelDecl(DGR);
|
||||
}
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user