Skip to content

Commit 51bbea6

Browse files
Merge pull request #35923 from apple/QuietMisdreavus/dont-crash-on-failed-loads
don't crash the symbol graph tool when a module fails to load
2 parents a5b8046 + 65665eb commit 51bbea6

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift %S/Inputs/FailedLoad/A.swift -module-name A -emit-module -emit-module-path %t/
3+
// RUN: %target-build-swift %s -module-name FailedLoad -emit-module -I %t -emit-module-path %t/
4+
5+
// RUN: rm %t/A.swiftmodule
6+
7+
// RUN: not %target-swift-symbolgraph-extract -module-name FailedLoad -I %t -pretty-print -output-dir %t 2>&1 | %FileCheck %s
8+
9+
// CHECK-NOT: Emitting symbol graph for module file
10+
11+
import A
12+
13+
public struct Outer {
14+
public var Something: A.Inner
15+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public struct Inner {
2+
public var Field: String
3+
}

tools/driver/swift_symbolgraph_extract_main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,14 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args, const char *Argv
238238
}
239239
return EXIT_FAILURE;
240240
}
241+
242+
if (M->failedToLoad()) {
243+
llvm::errs() << "Error: Failed to load the module '" << options::ModuleName
244+
<< "'. Are you missing build dependencies or include/framework directories?\n"
245+
<< "See the previous error messages for details. Aborting.\n";
246+
247+
return EXIT_FAILURE;
248+
}
241249

242250
const auto &MainFile = M->getMainFile(FileUnitKind::SerializedAST);
243251
llvm::errs() << "Emitting symbol graph for module file: " << MainFile.getModuleDefiningPath() << '\n';

0 commit comments

Comments
 (0)