Merge pull request #10797 from akyrtzi/sourcekit-ignore-index-store-flag-4.0

[4.0][SourceKit] Ignore the index-store-path flag for the sourcekitd requests
diff --git a/test/SourceKit/Misc/ignore_index_store_flag.swift b/test/SourceKit/Misc/ignore_index_store_flag.swift
new file mode 100644
index 0000000..2ed02b0
--- /dev/null
+++ b/test/SourceKit/Misc/ignore_index_store_flag.swift
@@ -0,0 +1,14 @@
+var s = 10
+s.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: touch %t/t.h
+// RUN: %sourcekitd-test -req=sema %s -- %s -import-objc-header %t/t.h -pch-output-dir %t/pch -index-store-path %t/idx | %FileCheck %s -check-prefix=DIAG
+// RUN: not find %t/idx
+// DIAG: expected member name
+
+// RUN: rm -rf %t/pch %t/idx
+// RUN: %sourcekitd-test -req=complete -pos=2:3 %s -- %s -import-objc-header %t/t.h -pch-output-dir %t/pch -index-store-path %t/idx | %FileCheck %s -check-prefix=COMPLETE
+// RUN: not find %t/idx
+// COMPLETE: littleEndian
diff --git a/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp b/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp
index d596924..f06d50a 100644
--- a/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp
+++ b/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp
@@ -419,6 +419,10 @@
     FrontendOpts.PlaygroundTransform = false;
   }
 
+  // Disable the index-store functionality for the sourcekitd requests.
+  FrontendOpts.IndexStorePath.clear();
+  ImporterOpts.IndexStorePath.clear();
+
   if (!PrimaryFile.empty()) {
     Optional<unsigned> PrimaryIndex;
     for (auto i : indices(Invocation.getFrontendOptions().InputFilenames)) {