[CompilerInstance] Fix weird condition on `createCodeCompletionConsumer`

Fixes llvm#53545

Differential Revision: https://reviews.llvm.org/D126524
This commit is contained in:
Yuki Okushi 2022-05-27 17:42:49 +09:00
parent 3b4500014a
commit d3d3e2528e
No known key found for this signature in database
GPG Key ID: 379CEEFDD63E5DD7
1 changed files with 4 additions and 7 deletions

View File

@ -710,13 +710,10 @@ static bool EnableCodeCompletion(Preprocessor &PP,
void CompilerInstance::createCodeCompletionConsumer() {
const ParsedSourceLocation &Loc = getFrontendOpts().CodeCompletionAt;
if (!CompletionConsumer) {
setCodeCompletionConsumer(
createCodeCompletionConsumer(getPreprocessor(),
Loc.FileName, Loc.Line, Loc.Column,
getFrontendOpts().CodeCompleteOpts,
llvm::outs()));
if (!CompletionConsumer)
return;
setCodeCompletionConsumer(createCodeCompletionConsumer(
getPreprocessor(), Loc.FileName, Loc.Line, Loc.Column,
getFrontendOpts().CodeCompleteOpts, llvm::outs()));
return;
} else if (EnableCodeCompletion(getPreprocessor(), Loc.FileName,
Loc.Line, Loc.Column)) {
setCodeCompletionConsumer(nullptr);