Skip to content

Commit e11efcb

Browse files
committed
ClangImporter: Fix external project crash in lookups
Before going and asking for the top level module, check for nullness. In addition, only ask for the top level of the module that had a redeclaration. rdar://problem/23701588
1 parent 99f40ee commit e11efcb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/ClangImporter/ClangImporter.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -2302,9 +2302,10 @@ static bool isVisibleFromModule(const ClangModuleUnit *ModuleFilter,
23022302
continue;
23032303
auto OwningClangModule = getClangOwningModule(Redeclaration,
23042304
ClangASTContext);
2305-
OwningClangModule = OwningClangModule->getTopLevelModule();
2305+
if (OwningClangModule)
2306+
OwningClangModule = OwningClangModule->getTopLevelModule();
23062307

2307-
if (OwningClangModule == ModuleFilter->getClangModule()->getTopLevelModule())
2308+
if (OwningClangModule == ModuleFilter->getClangModule())
23082309
return true;
23092310
}
23102311
} else if (isa<clang::TagDecl>(D)) {
@@ -2315,9 +2316,10 @@ static bool isVisibleFromModule(const ClangModuleUnit *ModuleFilter,
23152316
continue;
23162317
auto OwningClangModule = getClangOwningModule(Redeclaration,
23172318
ClangASTContext);
2318-
OwningClangModule = OwningClangModule->getTopLevelModule();
2319+
if (OwningClangModule)
2320+
OwningClangModule = OwningClangModule->getTopLevelModule();
23192321

2320-
if (OwningClangModule == ModuleFilter->getClangModule()->getTopLevelModule())
2322+
if (OwningClangModule == ModuleFilter->getClangModule())
23212323
return true;
23222324
}
23232325
}

0 commit comments

Comments
 (0)