Author: yvvan Date: Wed May 16 06:50:05 2018 New Revision: 332469 URL: http://llvm.org/viewvc/llvm-project?rev=332469&view=rev Log: [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 Added: cfe/trunk/test/Index/complete-and-plugins.c Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=332469&r1=332468&r2=332469&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original) +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Wed May 16 06:50:05 2018 @@ -150,12 +150,16 @@ FrontendAction::CreateWrappedASTConsumer 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(); Added: cfe/trunk/test/Index/complete-and-plugins.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-and-plugins.c?rev=332469&view=auto ============================================================================== --- cfe/trunk/test/Index/complete-and-plugins.c (added) +++ cfe/trunk/test/Index/complete-and-plugins.c Wed May 16 06:50:05 2018 @@ -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(); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits