Skip to content

Commit 081fb8a

Browse files
authored
Merge pull request #986 from vedantk/eng/PR-60734897
[SwiftASTContext] Add missing null check in ImportType
2 parents 930f87d + 1634e74 commit 081fb8a

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

lldb/source/Symbol/SwiftASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5260,7 +5260,7 @@ CompilerType SwiftASTContext::ImportType(CompilerType &type, Status &error) {
52605260
auto *ts = type.GetTypeSystem();
52615261
SwiftASTContext *swift_ast_ctx = llvm::dyn_cast_or_null<SwiftASTContext>(ts);
52625262

5263-
if (swift_ast_ctx == nullptr && !llvm::isa<TypeSystemSwift>(ts)) {
5263+
if (swift_ast_ctx == nullptr && (!ts || !llvm::isa<TypeSystemSwift>(ts))) {
52645264
error.SetErrorString("Can't import clang type into a Swift ASTContext.");
52655265
return CompilerType();
52665266
} else if (swift_ast_ctx == this) {
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1+
import NoSwiftmoduleHelper
2+
13
// The struct could not possibly be resolved with just the mangled type name.
24
struct s { let i = 0 }
35

6+
func useTypeFromOtherModule(x: S2) {
7+
// break here
8+
}
9+
410
func f<T>(_ t: T) {
511
let number = 1 // CHECK-DAG: (Int) number = 1
612
let array = [1, 2, 3] // CHECK-DAG: ([Int]) array = 3 values
713
let string = "hello" // CHECK-DAG: (String) string = "hello"
814
let tuple = (0, 1) // CHECK-DAG: (Int, Int) tuple = (0 = 0, 1 = 1)
915
let strct = s() // CHECK-DAG: strct ={{$}}
16+
let strct2 = S2() // CHECK-DAG: strct2 = <extracting data from value failed>
1017
let generic = t // CHECK-DAG: (Int) generic = 23
1118
let generic_tuple = (t, t) // CHECK-DAG: generic_tuple =
1219
// FIXME: CHECK-DAG: <read memory {{.*}} failed
13-
print(number) // break here
20+
print(number)
21+
useTypeFromOtherModule(x: S2())
1422
}
1523

1624
f(23)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public struct S2 {
2+
public init() {}
3+
}
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
# This tests debugging without the presence of a .swiftmodule.
22

33
# RUN: rm -rf %t && mkdir %t && cd %t
4+
#
5+
# Test what happens when we import NoSwiftmoduleHelper from main and use types
6+
# from it (this used to crash, see rdar://60734897).
47
# RUN: %target-swift-frontend -c -g -serialize-debugging-options \
58
# RUN: -module-cache-path %t/cache \
9+
# RUN: -parse-as-library \
10+
# RUN: -module-name NoSwiftmoduleHelper \
11+
# RUN: -emit-module \
12+
# RUN: -emit-module-path NoSwiftmoduleHelper.swiftmodule \
13+
# RUN: %S/Inputs/NoSwiftmoduleHelper.swift \
14+
# RUN: -o NoSwiftmoduleHelper.o
15+
16+
# RUN: %target-swift-frontend -c -g -serialize-debugging-options \
17+
# RUN: -module-cache-path %t/cache -I %t \
618
# RUN: -primary-file %S/Inputs/No.swiftmodule.swift \
719
# RUN: -module-name main -o %t/main.o
8-
# RUN: %target-swiftc -o %t/a.out %t/main.o
20+
#
21+
# RUN: %target-swiftc -o %t/a.out %t/main.o %t/NoSwiftmoduleHelper.o
922
# RUN: %lldb %t/a.out -s %s | FileCheck %S/Inputs/No.swiftmodule.swift
1023

1124
breakpoint set -p "break here"
1225
run
1326
fr var
27+
up
28+
fr var

0 commit comments

Comments
 (0)