From: Ivan Donchevskii Date: Thu, 17 May 2018 09:21:07 +0000 (+0000) Subject: [Frontend] Avoid running plugins during code completion parse X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3303890be9b4217dfa673c5d0647a9bd2ae31851;p=clang [Frontend] Avoid running plugins during code completion parse Second attempt. Proper line endings. 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332586 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp index e4fb022c2a..122dc23388 100644 --- a/lib/Frontend/FrontendAction.cpp +++ b/lib/Frontend/FrontendAction.cpp @@ -153,6 +153,10 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, 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> Consumers; diff --git a/test/Index/complete-and-plugins.c b/test/Index/complete-and-plugins.c new file mode 100644 index 0000000000..0592aaa9ef --- /dev/null +++ b/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();