Index: cfe/trunk/lib/Frontend/FrontendAction.cpp =================================================================== --- cfe/trunk/lib/Frontend/FrontendAction.cpp +++ cfe/trunk/lib/Frontend/FrontendAction.cpp @@ -150,12 +150,16 @@ 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> 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> Consumers; std::vector> AfterConsumers; for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(), ie = FrontendPluginRegistry::end(); Index: cfe/trunk/test/Index/complete-and-plugins.c =================================================================== --- cfe/trunk/test/Index/complete-and-plugins.c +++ cfe/trunk/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();