[SourceKit] Reuse compiler instance between multiple completion

- Introduce ide::CompletionInstance to manage CompilerInstance
- `CompletionInstance` vends the cached CompilerInstance when:
-- The compiler arguments (i.e. CompilerInvocation) has has not changed
-- The primary file is the same
-- The completion happens inside function bodies in both previous and
   current completion
-- The interface hash of the primary file has not changed
- Otherwise, it vends a fresh CompilerInstance and cache it for the next
  completion

rdar://problem/20787086
This commit is contained in:
Rintaro Ishizaki
2019-11-18 18:02:41 +09:00
parent ff97c06e8d
commit 62c44126b6
23 changed files with 589 additions and 318 deletions

View File

@@ -58,7 +58,7 @@ class ImportDepth {
public:
ImportDepth() = default;
ImportDepth(ASTContext &context, CompilerInvocation &invocation);
ImportDepth(ASTContext &context, const CompilerInvocation &invocation);
Optional<uint8_t> lookup(StringRef module) {
auto I = depths.find(module);
@@ -320,7 +320,8 @@ CodeCompletionViewRef CodeCompletionOrganizer::takeResultsView() {
// ImportDepth
//===----------------------------------------------------------------------===//
ImportDepth::ImportDepth(ASTContext &context, CompilerInvocation &invocation) {
ImportDepth::ImportDepth(ASTContext &context,
const CompilerInvocation &invocation) {
llvm::DenseSet<ModuleDecl *> seen;
std::deque<std::pair<ModuleDecl *, uint8_t>> worklist;