Skip to content

Commit af81adb

Browse files
committed
sourcekitd source.request.index_to_store fixes - new test and minor changes
1 parent d618233 commit af81adb

File tree

5 files changed

+36
-11
lines changed

5 files changed

+36
-11
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
struct OtherStruct {
2+
let x: Int
3+
let y: Int
4+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %sourcekitd-test -req=index-to-store %s -index-store-path %t/idx -index-unit-output-path %t/indexstore_multifile.o -- -c -module-name indexstoremodule -o args_output_path.o %s %S/Inputs/indexstore_multifile_other.swift
3+
// RUN: c-index-test core -print-unit %t/idx | %FileCheck --dump-input=always --dump-input-filter=all %s
4+
5+
struct Foo {
6+
let bar: Int
7+
let counter: Int
8+
let other: OtherStruct
9+
10+
init(bar: Int, counter: Int = 0, other: OtherStruct) {
11+
self.bar = bar
12+
self.counter = counter
13+
self.other = other
14+
}
15+
}
16+
17+
// CHECK: indexstore_multifile.o-{{.*}}
18+
// CHECK: module-name: indexstoremodule
19+
// CHECK: main-path: SOURCE_DIR/test/SourceKit/Indexing/indexstore_multifile.swift
20+
// CHECK: out-file: BUILD_DIR{{.*}}indexstore_multifile.o
21+
// CHECK: is-debug: 1
22+
// CHECK: Unit | system | Swift | {{.*}}{{/|\\}}Swift.swiftmodule
23+
// CHECK: Record | user | SOURCE_DIR/test/SourceKit/Indexing/indexstore_multifile.swift | indexstore_multifile.swift-{{.*}}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %sourcekitd-test -req=index-to-store %s -index-store-path %t/idx -index-unit-output-path %t/indexstore.o -- -c -module-name indexstoremodule -file-prefix-map %S=REMAPPED_SRC_ROOT -file-prefix-map %t=REMAPPED_OUT_DIR %s
2+
// RUN: %sourcekitd-test -req=index-to-store %s -index-store-path %t/idx -index-unit-output-path %t/indexstore_with_remappings.o -- -c -module-name indexstoremodule -file-prefix-map %S=REMAPPED_SRC_ROOT -file-prefix-map %t=REMAPPED_OUT_DIR %s
33
// RUN: c-index-test core -print-unit %t/idx | %FileCheck %s
44

55
class Foo {
@@ -9,9 +9,9 @@ class Foo {
99
}
1010
}
1111

12-
// CHECK: indexstore.o-{{.*}}
12+
// CHECK: indexstore_with_remappings.o-{{.*}}
1313
// CHECK: module-name: indexstoremodule
14-
// CHECK: main-path: REMAPPED_SRC_ROOT/indexstore.swift
15-
// CHECK: out-file: REMAPPED_OUT_DIR/indexstore.o
14+
// CHECK: main-path: REMAPPED_SRC_ROOT/indexstore_with_remappings.swift
15+
// CHECK: out-file: REMAPPED_OUT_DIR/indexstore_with_remappings.o
1616
// CHECK: is-debug: 1
1717
// CHECK: Unit | system | Swift | {{.*}}{{/|\\}}Swift.swiftmodule

tools/SourceKit/lib/SwiftLang/SwiftIndexing.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,13 @@ static void emitIndexDataForSourceFile(SourceFile &PrimarySourceFile,
401401
}
402402

403403
void SwiftLangSupport::indexToStore(
404-
StringRef InputFile, ArrayRef<const char *> Args,
404+
StringRef PrimaryFilePath, ArrayRef<const char *> Args,
405405
IndexStoreOptions Opts,
406406
SourceKitCancellationToken CancellationToken,
407407
IndexToStoreReceiver Receiver) {
408408
std::string Error;
409409
SwiftInvocationRef Invok =
410-
ASTMgr->getTypecheckInvocation(Args, InputFile, Error);
410+
ASTMgr->getTypecheckInvocation(Args, PrimaryFilePath, Error);
411411
if (!Invok) {
412412
LOG_WARN_FUNC("failed to create an ASTInvocation: " << Error);
413413
Receiver(RequestResult<IndexStoreInfo>::fromError(Error));
@@ -439,10 +439,8 @@ void SwiftLangSupport::indexToStore(
439439
};
440440

441441
auto ASTConsumer = std::make_shared<IndexStoreASTConsumer>(std::move(Receiver), std::move(Opts));
442-
/// FIXME: When request cancellation is implemented and Xcode adopts it,
443-
/// don't use 'OncePerASTToken'.
444-
static const char OncePerASTToken = 0;
445-
getASTManager()->processASTAsync(Invok, ASTConsumer, &OncePerASTToken,
442+
getASTManager()->processASTAsync(Invok, ASTConsumer,
443+
/*OncePerASTToken=*/nullptr,
446444
CancellationToken,
447445
llvm::vfs::getRealFileSystem());
448446
}

tools/SourceKit/tools/sourcekitd/lib/Service/Requests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ static void handleRequestIndexToStore(
14441444
else
14451445
return Rec(createErrorRequestInvalid("'key.index_unit_output_path' is required"));
14461446
1447-
SmallVector<const char *, 8> Args;
1447+
SmallVector<const char *, 0> Args;
14481448
if (getCompilerArgumentsForRequestOrEmitError(Req, Args, Rec))
14491449
return;
14501450
LangSupport &Lang = getGlobalContext().getSwiftLangSupport();

0 commit comments

Comments
 (0)