Skip to content

Commit b026d0a

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 (cherry picked from commit f94d653)
1 parent 5696fb5 commit b026d0a

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
@@ -3585,7 +3585,7 @@ bool swift::isInOverlayModuleForImportedModule(const DeclContext *overlayDC,
35853585
importedDC = importedDC->getModuleScopeContext();
35863586

35873587
auto importedClangModuleUnit = dyn_cast<ClangModuleUnit>(importedDC);
3588-
if (!importedClangModuleUnit)
3588+
if (!importedClangModuleUnit || !importedClangModuleUnit->getClangModule())
35893589
return false;
35903590

35913591
auto overlayModule = overlayDC->getParentModule();

0 commit comments

Comments
 (0)