19 #include "clang/Tooling/ArgumentsAdjusters.h" 20 #include "clang/Tooling/CommonOptionsParser.h" 21 #include "clang/Tooling/Execution.h" 22 #include "clang/Tooling/Tooling.h" 23 #include "llvm/Support/CommandLine.h" 24 #include "llvm/Support/Signals.h" 30 static llvm::cl::opt<IndexFileFormat>
31 Format(
"format", llvm::cl::desc(
"Format of the index to be written"),
33 "human-readable YAML format"),
35 "binary RIFF format")),
38 class IndexActionFactory :
public tooling::FrontendActionFactory {
40 IndexActionFactory(IndexFileIn &
Result) : Result(Result) {}
42 clang::FrontendAction *create()
override {
43 SymbolCollector::Options Opts;
44 Opts.CountReferences =
true;
49 std::lock_guard<std::mutex> Lock(SymbolsMu);
50 for (
const auto &Sym : S) {
51 if (
const auto *Existing =
Symbols.find(Sym.ID))
58 std::lock_guard<std::mutex> Lock(SymbolsMu);
59 for (
const auto &Sym : S) {
61 for (
const auto &Ref : Sym.second)
62 Refs.insert(Sym.first, Ref);
66 std::lock_guard<std::mutex> Lock(SymbolsMu);
67 for (
const auto &R : S) {
77 ~IndexActionFactory() {
95 int main(
int argc,
const char **argv) {
96 llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
98 const char *Overview = R
"( 99 Creates an index of symbol information etc in a whole project. 101 Example usage for a project using CMake compile commands: 103 $ clangd-indexer --executor=all-TUs compile_commands.json > clangd.dex 105 Example usage for file sequence index without flags: 107 $ clangd-indexer File1.cpp File2.cpp ... FileN.cpp > clangd.dex 109 Note: only symbols from header files will be indexed. 112 auto Executor = clang::tooling::createExecutorFromCommandLineArgs(
113 argc, argv, llvm::cl::GeneralCategory, Overview);
122 auto Err = Executor->get()->execute(
123 llvm::make_unique<clang::clangd::IndexActionFactory>(Data),
124 clang::tooling::getStripPluginsAdjuster());
131 Out.
Format = clang::clangd::Format;
int main(int argc, const char **argv)
static llvm::StringRef toString(SpecialMemberFunctionsCheck::SpecialMemberFunctionKind K)
Symbol mergeSymbol(const Symbol &L, const Symbol &R)
CodeCompletionBuilder Builder
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::unique_ptr< FrontendAction > createStaticIndexingAction(SymbolCollector::Options Opts, std::function< void(SymbolSlab)> SymbolsCallback, std::function< void(RefSlab)> RefsCallback, std::function< void(RelationSlab)> RelationsCallback, std::function< void(IncludeGraph)> IncludeGraphCallback)
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result