[clang] d3d3e25 - [CompilerInstance] Fix weird condition on `createCodeCompletionConsumer`

Yuki Okushi via cfe-commits cfe-commits at lists.llvm.org
Fri May 27 22:59:22 PDT 2022


Author: Yuki Okushi
Date: 2022-05-28T14:58:04+09:00
New Revision: d3d3e2528e60c93000c6d7f90053d1672cc7b47d

URL: https://github.com/llvm/llvm-project/commit/d3d3e2528e60c93000c6d7f90053d1672cc7b47d
DIFF: https://github.com/llvm/llvm-project/commit/d3d3e2528e60c93000c6d7f90053d1672cc7b47d.diff

LOG: [CompilerInstance] Fix weird condition on `createCodeCompletionConsumer`

Fixes llvm#53545

Differential Revision: https://reviews.llvm.org/D126524

Added: 
    

Modified: 
    clang/lib/Frontend/CompilerInstance.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index bb896449b621..0ec7964bc599 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -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);


        


More information about the cfe-commits mailing list