[PATCH] D126524: [CompilerInstance] Fix weird condition on `createCodeCompletionConsumer`

Yuki Okushi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 27 01:43:43 PDT 2022


JohnTitor created this revision.
Herald added a project: All.
JohnTitor requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes llvm#53545


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126524

Files:
  clang/lib/Frontend/CompilerInstance.cpp


Index: clang/lib/Frontend/CompilerInstance.cpp
===================================================================
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -710,15 +710,13 @@
 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;
-  } else if (EnableCodeCompletion(getPreprocessor(), Loc.FileName,
-                                  Loc.Line, Loc.Column)) {
+    setCodeCompletionConsumer(createCodeCompletionConsumer(
+        getPreprocessor(), Loc.FileName, Loc.Line, Loc.Column,
+        getFrontendOpts().CodeCompleteOpts, llvm::outs()));
+    return;
+  } else if (!CompletionConsumer &&
+             EnableCodeCompletion(getPreprocessor(), Loc.FileName, Loc.Line,
+                                  Loc.Column)) {
     setCodeCompletionConsumer(nullptr);
     return;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126524.432491.patch
Type: text/x-patch
Size: 1264 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220527/9a6287cd/attachment.bin>


More information about the cfe-commits mailing list