[clangd] Make binary index format the default, remove dead flag.

Reviewers: hokein

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D52872

llvm-svn: 343841
This commit is contained in:
Sam McCall 2018-10-05 09:05:28 +00:00
parent 980b424cbf
commit 722d6c6041
1 changed files with 4 additions and 23 deletions

View File

@ -7,8 +7,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// GlobalSymbolBuilder is a tool to extract symbols from a whole project. // clangd-indexer is a tool to gather index data (symbols, xrefs) from source.
// This tool is **experimental** only. Don't use it in production code.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -21,7 +20,6 @@
#include "clang/Tooling/Execution.h" #include "clang/Tooling/Execution.h"
#include "clang/Tooling/Tooling.h" #include "clang/Tooling/Tooling.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Signals.h" #include "llvm/Support/Signals.h"
using namespace llvm; using namespace llvm;
@ -32,22 +30,13 @@ namespace clang {
namespace clangd { namespace clangd {
namespace { namespace {
static llvm::cl::opt<std::string> AssumedHeaderDir(
"assume-header-dir",
llvm::cl::desc("The index includes header that a symbol is defined in. "
"If the absolute path cannot be determined (e.g. an "
"in-memory VFS) then the relative path is resolved against "
"this directory, which must be absolute. If this flag is "
"not given, such headers will have relative paths."),
llvm::cl::init(""));
static llvm::cl::opt<IndexFileFormat> static llvm::cl::opt<IndexFileFormat>
Format("format", llvm::cl::desc("Format of the index to be written"), Format("format", llvm::cl::desc("Format of the index to be written"),
llvm::cl::values(clEnumValN(IndexFileFormat::YAML, "yaml", llvm::cl::values(clEnumValN(IndexFileFormat::YAML, "yaml",
"human-readable YAML format"), "human-readable YAML format"),
clEnumValN(IndexFileFormat::RIFF, "binary", clEnumValN(IndexFileFormat::RIFF, "binary",
"binary RIFF format")), "binary RIFF format")),
llvm::cl::init(IndexFileFormat::YAML)); llvm::cl::init(IndexFileFormat::RIFF));
class IndexActionFactory : public tooling::FrontendActionFactory { class IndexActionFactory : public tooling::FrontendActionFactory {
public: public:
@ -55,7 +44,6 @@ public:
clang::FrontendAction *create() override { clang::FrontendAction *create() override {
SymbolCollector::Options Opts; SymbolCollector::Options Opts;
Opts.FallbackDir = AssumedHeaderDir;
return createStaticIndexingAction( return createStaticIndexingAction(
Opts, Opts,
[&](SymbolSlab S) { [&](SymbolSlab S) {
@ -102,15 +90,14 @@ int main(int argc, const char **argv) {
const char *Overview = R"( const char *Overview = R"(
Creates an index of symbol information etc in a whole project. Creates an index of symbol information etc in a whole project.
This is **experimental** and not production-ready!
Example usage for a project using CMake compile commands: Example usage for a project using CMake compile commands:
$ clangd-indexer --executor=all-TUs compile_commands.json > index.yaml $ clangd-indexer --executor=all-TUs compile_commands.json > clangd.dex
Example usage for file sequence index without flags: Example usage for file sequence index without flags:
$ clangd-indexer File1.cpp File2.cpp ... FileN.cpp > index.yaml $ clangd-indexer File1.cpp File2.cpp ... FileN.cpp > clangd.dex
Note: only symbols from header files will be indexed. Note: only symbols from header files will be indexed.
)"; )";
@ -123,12 +110,6 @@ int main(int argc, const char **argv) {
return 1; return 1;
} }
if (!clang::clangd::AssumedHeaderDir.empty() &&
!llvm::sys::path::is_absolute(clang::clangd::AssumedHeaderDir)) {
llvm::errs() << "--assume-header-dir must be an absolute path.\n";
return 1;
}
// Collect symbols found in each translation unit, merging as we go. // Collect symbols found in each translation unit, merging as we go.
clang::clangd::IndexFileIn Data; clang::clangd::IndexFileIn Data;
auto Err = Executor->get()->execute( auto Err = Executor->get()->execute(