mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[sourcekit] Stop storing a bare reference to LangSupport in ASTManager
This fixes a use-after-free when an AST build finishes after shutdown().
This commit is contained in:
@@ -179,7 +179,10 @@ SwiftLangSupport::SwiftLangSupport(SourceKit::Context &SKCtx)
|
||||
llvm::sys::path::append(LibPath, "swift");
|
||||
RuntimeResourcePath = LibPath.str();
|
||||
|
||||
ASTMgr = std::make_shared<SwiftASTManager>(*this);
|
||||
Stats = std::make_shared<SwiftStatistics>();
|
||||
EditorDocuments = std::make_shared<SwiftEditorDocumentFileMap>();
|
||||
ASTMgr = std::make_shared<SwiftASTManager>(EditorDocuments, Stats,
|
||||
RuntimeResourcePath);
|
||||
// By default, just use the in-memory cache.
|
||||
CCCache->inMemory = llvm::make_unique<ide::CodeCompletionCache>();
|
||||
}
|
||||
@@ -766,7 +769,7 @@ std::string SwiftLangSupport::resolvePathSymlinks(StringRef FilePath) {
|
||||
|
||||
void SwiftLangSupport::getStatistics(StatisticsReceiver receiver) {
|
||||
std::vector<Statistic *> stats = {
|
||||
#define SWIFT_STATISTIC(VAR, UID, DESC) &Stats.VAR,
|
||||
#define SWIFT_STATISTIC(VAR, UID, DESC) &Stats->VAR,
|
||||
#include "SwiftStatistics.def"
|
||||
};
|
||||
receiver(stats);
|
||||
|
||||
Reference in New Issue
Block a user