[SourceKitSwiftLang] Avoid call with null this

If an imported Objective-C method had no owning clang module, passCursorInfoForDecl() would call clang::Module::getFullModuleName() on a null instance. The current implementation of this method happens to terminate its loop immediately and return an empty string, but it’s best not to depend on this. Fixes a UBSan error in SourceKit/Mixed/cursor_mixed_header.swift.
This commit is contained in:
Brent Royal-Gordon
2018-08-26 06:04:33 -07:00
parent 9893c392ec
commit 4d7046f95a

View File

@@ -873,7 +873,8 @@ static bool passCursorInfoForDecl(SourceFile* SF,
auto ClangNode = VD->getClangNode();
if (ClangNode) {
auto ClangMod = Importer->getClangOwningModule(ClangNode);
ModuleName = ClangMod->getFullModuleName();
if (ClangMod)
ModuleName = ClangMod->getFullModuleName();
} else if (VD->getLoc().isInvalid() && VD->getModuleContext() != MainModule) {
ModuleName = VD->getModuleContext()->getName().str();
}