Skip to content

Commit f94d653

Browse files
committed
Guard for null result from ClangModuleUnit::getClangModule().
The documentation for this method states that this can return null if the module unit represents [the] imported headers. We have a crash report on dereferencing the result of this function farther down, and I suspect it's hitting exactly that case. Unfortunately we only have a back trace and no test case. Fixes: rdar://problem/41888568
1 parent 165c5e8 commit f94d653

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -3610,7 +3610,7 @@ bool ClangImporter::isInOverlayModuleForImportedModule(
36103610
importedDC = importedDC->getModuleScopeContext();
36113611

36123612
auto importedClangModuleUnit = dyn_cast<ClangModuleUnit>(importedDC);
3613-
if (!importedClangModuleUnit)
3613+
if (!importedClangModuleUnit || !importedClangModuleUnit->getClangModule())
36143614
return false;
36153615

36163616
auto overlayModule = overlayDC->getParentModule();

0 commit comments

Comments
 (0)