[sourcekit] Change getASTManager() to return shared_ptr

Addressing review feedback: this avoids calling shared_from_this() from
outside the implementation.  Note: it is not possible to use private
inheritance of enable_shared_from_this to prevent this issue in general,
because enabled_shared_from_this relies on the shared_ptr constructor
being able to detect that the type has this inheritance, which means it
must be public.
This commit is contained in:
Ben Langmuir
2018-09-25 16:42:41 -07:00
parent 2fbe270c6d
commit b04ffcca86
7 changed files with 20 additions and 20 deletions

View File

@@ -1058,7 +1058,7 @@ struct SwiftEditorDocument::Implementation {
Implementation(StringRef FilePath, SwiftLangSupport &LangSupport,
CodeFormatOptions options)
: ASTMgr(LangSupport.getASTManager().shared_from_this()),
: ASTMgr(LangSupport.getASTManager()),
NotificationCtr(LangSupport.getNotificationCenter()),
FilePath(FilePath), FormatOptions(options) {
SemanticInfo =
@@ -1735,7 +1735,7 @@ void SwiftEditorDocument::parse(ImmutableTextSnapshotRef Snapshot,
Args.push_back("-");
std::string Error;
// Ignore possible error(s)
Lang.getASTManager().
Lang.getASTManager()->
initCompilerInvocation(CompInv, Args, StringRef(), Error);
}
CompInv.getLangOptions().BuildSyntaxTree = BuildSyntaxTree;