Skip to content

Commit 6a3df0a

Browse files
committed
[Index] Write empty record files
When indexing an empty Swift file, we get a unit file that doesn’t have any record dependency declared on the source file. Because of this, we always assume that the empty file has an out of date index store entry and re-index it on project open. Write empty record files to fix this. rdar://128711594
1 parent f3d4969 commit 6a3df0a

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

lib/Index/IndexRecord.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,6 @@ StringRef StdlibGroupsIndexRecordingConsumer::findGroupForSymbol(const IndexSymb
285285
static bool writeRecord(SymbolTracker &record, std::string Filename,
286286
std::string indexStorePath, DiagnosticEngine *diags,
287287
std::string &outRecordFile) {
288-
if (record.getOccurrences().empty()) {
289-
outRecordFile = std::string();
290-
return false;
291-
}
292-
293288
IndexRecordWriter recordWriter(indexStorePath);
294289
std::string error;
295290
auto result = recordWriter.beginRecord(

test/Index/Store/record-empty.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
// RUN: %target-swift-frontend -index-store-path %t/idx -o %t/file.o -typecheck -primary-file %s
33
// RUN: %target-swift-frontend -index-store-path %t/idx -o %t/file.o -typecheck %s
44
// RUN: c-index-test core -print-unit %t/idx | %FileCheck %s
5-
// CHECK-NOT: Record{{.*}}record-empty
5+
// CHECK: Record | user | {{.*}}/record-empty.swift

0 commit comments

Comments
 (0)