[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

@@ -1335,7 +1335,7 @@ void SwiftLangSupport::findLocalRenameRanges(
/// FIXME: When request cancellation is implemented and Xcode adopts it,
/// don't use 'OncePerASTToken'.
static const char OncePerASTToken = 0;
getASTManager().processASTAsync(Invok, ASTConsumer, &OncePerASTToken);
getASTManager()->processASTAsync(Invok, ASTConsumer, &OncePerASTToken);
}
SourceFile *SwiftLangSupport::getSyntacticSourceFile(
@@ -1343,7 +1343,7 @@ SourceFile *SwiftLangSupport::getSyntacticSourceFile(
CompilerInstance &ParseCI, std::string &Error) {
CompilerInvocation Invocation;
bool Failed = getASTManager().initCompilerInvocationNoInputs(
bool Failed = getASTManager()->initCompilerInvocationNoInputs(
Invocation, Args, ParseCI.getDiags(), Error);
if (Failed) {
Error = "Compiler invocation init failed";
@@ -1398,7 +1398,7 @@ void SwiftLangSupport::getDocInfo(llvm::MemoryBuffer *InputBuf,
CompilerInvocation Invocation;
std::string Error;
bool Failed = getASTManager().initCompilerInvocationNoInputs(
bool Failed = getASTManager()->initCompilerInvocationNoInputs(
Invocation, Args, CI.getDiags(), Error, /*AllowInputs=*/false);
if (Failed) {
@@ -1434,7 +1434,7 @@ findModuleGroups(StringRef ModuleName, ArrayRef<const char *> Args,
CI.addDiagnosticConsumer(&PrintDiags);
std::vector<StringRef> Groups;
std::string Error;
if (getASTManager().initCompilerInvocationNoInputs(Invocation, Args,
if (getASTManager()->initCompilerInvocationNoInputs(Invocation, Args,
CI.getDiags(), Error)) {
Receiver(Groups, Error);
return;