Reset Sema::CurContext to TU before auto-import:
Sema create an ImportDecl, and that should not end up e.g. inside a class definition, or wherever else the "autoparsing" was triggered. Fixes roottest-root-meta-assertVarOffset. (cherry picked from commit 4d8fcf0984118663a356d462eeec6cb6c34ebfef)
This commit is contained in:
parent
02ec8bf986
commit
eac42c613b
@ -870,9 +870,15 @@ namespace cling {
|
||||
Preprocessor& PP = getCI()->getPreprocessor();
|
||||
IdentifierInfo* II = PP.getIdentifierInfo(M->Name);
|
||||
SourceLocation ValidLoc = getNextAvailableLoc();
|
||||
|
||||
// Don't push the ImportDecl into a ClassDecl or whatever - who knows which
|
||||
// context triggered this import!
|
||||
DeclContext *OldDC = getSema().CurContext;
|
||||
getSema().CurContext = getSema().getASTContext().getTranslationUnitDecl();
|
||||
bool success =
|
||||
!getSema().ActOnModuleImport(ValidLoc, /*ExportLoc*/ {}, ValidLoc,
|
||||
std::make_pair(II, ValidLoc)).isInvalid();
|
||||
getSema().CurContext = OldDC;
|
||||
|
||||
if (success) {
|
||||
// Also make the module visible in the preprocessor to export its macros.
|
||||
|
Loading…
x
Reference in New Issue
Block a user