File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
tools/SourceKit/lib/SwiftLang Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %{python} %utils/split_file.py -o %t %s
3
+
4
+ // This used to crash with a nullptr dereference because we didn't store a
5
+ // snapshot in the FileContents of primary.swift when it is opened for the first
6
+ // time but we are trying to access the snapshot when trying determining if we
7
+ // can reuse the AST for the cursor info request
8
+
9
+ // RUN: %sourcekitd-test \
10
+ // RUN: -req=open %t/primary.swift -- %t/primary.swift %t/secondary.swift \
11
+ // RUN: == -req=close %t/primary.swift \
12
+ // RUN: == -req=open %t/primary.swift -- %t/primary.swift \
13
+ // RUN: == -req=cursor -pos 2:8 %t/primary.swift -- %t/primary.swift %t/secondary.swift \
14
+ // RUN: | %FileCheck %s
15
+
16
+ // BEGIN primary.swift
17
+
18
+ struct Foo { }
19
+ // CHECK: source.lang.swift.decl.struct
20
+ // CHECK-NEXT: Foo
21
+ // CHECK-NEXT: s:4main3FooV
22
+
23
+ // BEGIN secondary.swift
Original file line number Diff line number Diff line change @@ -1185,7 +1185,9 @@ ASTBuildOperationRef ASTProducer::getBuildOperationForConsumer(
1185
1185
std::vector<ImmutableTextSnapshotRef> Snapshots;
1186
1186
Snapshots.reserve (BuildOp->getFileContents ().size ());
1187
1187
for (auto &FileContent : BuildOp->getFileContents ()) {
1188
- Snapshots.push_back (FileContent.Snapshot );
1188
+ if (FileContent.Snapshot ) {
1189
+ Snapshots.push_back (FileContent.Snapshot );
1190
+ }
1189
1191
}
1190
1192
if (BuildOp->matchesSourceState (FileSystem)) {
1191
1193
++Mgr->Impl .Stats ->numASTCacheHits ;
You can’t perform that action at this time.
0 commit comments