[PATCH] D46050: [Frontend] Avoid running plugins during code completion parse

Nikolai Kosjar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 26 02:37:06 PDT 2018


nik updated this revision to Diff 144084.
nik added a comment.

Added a test and clarified scenario in commit message.


Repository:
  rC Clang

https://reviews.llvm.org/D46050

Files:
  lib/Frontend/FrontendAction.cpp
  test/Frontend/plugins.c


Index: test/Frontend/plugins.c
===================================================================
--- test/Frontend/plugins.c
+++ test/Frontend/plugins.c
@@ -3,3 +3,9 @@
 
 // CHECK: top-level-decl: "x"
 void x();
+
+// RUN: c-index-test -code-completion-at=%s:6:1 -load %llvmshlibdir/PrintFunctionNames%pluginext -add-plugin print-fns %s | FileCheck -check-prefix=CHECK-COMPLETION-WITHOUT-PLUGINS  %s
+// REQUIRES: plugins, examples
+
+// CHECK-COMPLETION-WITHOUT-PLUGINS: macro definition:{{.*}}
+// CHECK-COMPLETION-WITHOUT-PLUGINS-NOT: top-level-decl: "x"
Index: lib/Frontend/FrontendAction.cpp
===================================================================
--- lib/Frontend/FrontendAction.cpp
+++ lib/Frontend/FrontendAction.cpp
@@ -153,6 +153,10 @@
   if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end())
     return Consumer;
 
+  // If this is a code completion run, avoid invoking the plugin consumers
+  if (CI.hasCodeCompletionConsumer())
+    return Consumer;
+
   // Collect the list of plugins that go before the main action (in Consumers)
   // or after it (in AfterConsumers)
   std::vector<std::unique_ptr<ASTConsumer>> Consumers;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46050.144084.patch
Type: text/x-patch
Size: 1171 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180426/0605afdc/attachment.bin>


More information about the cfe-commits mailing list