summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2018-05-16 13:50:05 +0000
committerIvan Donchevskii <ivan.donchevskii@qt.io>2018-05-16 13:50:05 +0000
commit091069c91e8a0fa173df7895502558f645fb7b9c (patch)
tree67d30c2de9077634f6a62a5a1d368d6d80abae3f
parent076eba20bc1d8e01ca178eb90b29a27ad09f64b9 (diff)
downloadbcm5719-llvm-091069c91e8a0fa173df7895502558f645fb7b9c.tar.gz
bcm5719-llvm-091069c91e8a0fa173df7895502558f645fb7b9c.zip
[Frontend] Avoid running plugins during code completion parse
The parsing that is done for code completion is a special case that will discard any generated diagnostics, so avoid running plugins for this case in the first place to avoid performance penalties due to the plugins. A scenario for this is for example libclang with extra plugins like tidy. Patch by Nikolai Kosjar Differential Revision: https://reviews.llvm.org/D46050 llvm-svn: 332469
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp16
-rw-r--r--clang/test/Index/complete-and-plugins.c6
2 files changed, 16 insertions, 6 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index e4fb022c2a1..1ebc37310de 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -150,12 +150,16 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI,
return nullptr;
// If there are no registered plugins we don't need to wrap the consumer
- if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end())
- 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;
+ 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;
std::vector<std::unique_ptr<ASTConsumer>> AfterConsumers;
for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
ie = FrontendPluginRegistry::end();
diff --git a/clang/test/Index/complete-and-plugins.c b/clang/test/Index/complete-and-plugins.c
new file mode 100644
index 00000000000..60c9214018b
--- /dev/null
+++ b/clang/test/Index/complete-and-plugins.c
@@ -0,0 +1,6 @@
+// RUN: c-index-test -code-completion-at=%s:7:1 -load %llvmshlibdir/PrintFunctionNames%pluginext -add-plugin print-fns %s | FileCheck %s
+// REQUIRES: plugins, examples
+// CHECK: macro definition:{{.*}}
+// CHECK-NOT: top-level-decl: "x"
+
+void x();
OpenPOWER on IntegriCloud