mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 15:45:08 +00:00
Do not index standard library headers
This commit is contained in:
parent
49c6f7787a
commit
36f69e61a9
@ -604,7 +604,7 @@ void LanguageServerMain(std::string process_name) {
|
||||
|
||||
|
||||
|
||||
int mai232n(int argc, char** argv) {
|
||||
int main(int argc, char** argv) {
|
||||
// We need to write to stdout in binary mode because in Windows, writing
|
||||
// \n will implicitly write \r\n. Language server API will ignore a
|
||||
// \r\r\n split request.
|
||||
|
35
indexer.cpp
35
indexer.cpp
@ -1,5 +1,7 @@
|
||||
#include "indexer.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "serializer.h"
|
||||
|
||||
IndexedFile::IndexedFile(const std::string& path)
|
||||
@ -555,9 +557,10 @@ optional<TypeId> AddDeclUsages(IndexedFile* db, clang::Cursor decl_cursor,
|
||||
return param.initial_type;
|
||||
}
|
||||
|
||||
|
||||
void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
||||
bool is_system_def = clang_Location_isInSystemHeader(clang_getCursorLocation(decl->cursor));
|
||||
if (is_system_def)
|
||||
return;
|
||||
|
||||
IndexParam* param = static_cast<IndexParam*>(client_data);
|
||||
IndexedFile* db = param->db;
|
||||
@ -861,6 +864,10 @@ bool IsFunction(CXCursorKind kind) {
|
||||
}
|
||||
|
||||
void indexEntityReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
||||
if (clang_Location_isInSystemHeader(clang_getCursorLocation(ref->cursor)) ||
|
||||
clang_Location_isInSystemHeader(clang_getCursorLocation(ref->referencedEntity->cursor)))
|
||||
return;
|
||||
|
||||
IndexParam* param = static_cast<IndexParam*>(client_data);
|
||||
IndexedFile* db = param->db;
|
||||
clang::Cursor cursor(ref->cursor);
|
||||
@ -1007,6 +1014,28 @@ void indexEntityReference(CXClientData client_data, const CXIdxEntityRefInfo* re
|
||||
}
|
||||
|
||||
|
||||
void emptyIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {}
|
||||
void emptyIndexEntityReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {}
|
||||
|
||||
struct Timer {
|
||||
using Clock = std::chrono::high_resolution_clock;
|
||||
std::chrono::time_point<Clock> start_;
|
||||
|
||||
Timer() {
|
||||
Reset();
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
start_ = Clock::now();
|
||||
}
|
||||
|
||||
void PrintElapsed() {
|
||||
std::chrono::time_point<Clock> end = Clock::now();
|
||||
|
||||
std::cerr << "Indexing took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start_).count() << "ms" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
IndexedFile Parse(std::string filename, std::vector<std::string> args, bool dump_ast) {
|
||||
clang::Index index(0 /*excludeDeclarationsFromPCH*/, 0 /*displayDiagnostics*/);
|
||||
clang::TranslationUnit tu(index, filename, args);
|
||||
@ -1018,6 +1047,7 @@ IndexedFile Parse(std::string filename, std::vector<std::string> args, bool dump
|
||||
|
||||
IndexerCallbacks callbacks[] = {
|
||||
{ &abortQuery, &diagnostic, &enteredMainFile, &ppIncludedFile, &importedASTFile, &startedTranslationUnit, &indexDeclaration, &indexEntityReference }
|
||||
//{ &abortQuery, &diagnostic, &enteredMainFile, &ppIncludedFile, &importedASTFile, &startedTranslationUnit, &emptyIndexDeclaration, &emptyIndexEntityReference }
|
||||
/*
|
||||
callbacks.abortQuery = &abortQuery;
|
||||
callbacks.diagnostic = &diagnostic;
|
||||
@ -1033,8 +1063,11 @@ IndexedFile Parse(std::string filename, std::vector<std::string> args, bool dump
|
||||
IndexedFile db(filename);
|
||||
NamespaceHelper ns;
|
||||
IndexParam param(&db, &ns);
|
||||
|
||||
Timer time;
|
||||
clang_indexTranslationUnit(index_action, ¶m, callbacks, sizeof(callbacks),
|
||||
CXIndexOpt_IndexFunctionLocalSymbols | CXIndexOpt_SkipParsedBodiesInSession, tu.cx_tu);
|
||||
time.PrintElapsed();
|
||||
|
||||
clang_IndexAction_dispose(index_action);
|
||||
|
||||
|
4
test.cc
4
test.cc
@ -82,7 +82,7 @@ void VerifySerializeToFrom(IndexedFile* file) {
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main23(int argc, char** argv) {
|
||||
// TODO: Assert that we need to be on clang >= 3.9.1
|
||||
|
||||
/*
|
||||
@ -98,7 +98,7 @@ int main(int argc, char** argv) {
|
||||
//if (path != "tests/constructors/invalid_reference.cc") continue;
|
||||
//if (path == "tests/inheritance/class_inherit_templated_parent.cc") continue;
|
||||
//if (path != "tests/namespaces/namespace_reference.cc") continue;
|
||||
if (path == "tests/stl.cc") continue;
|
||||
//if (path != "tests/stl.cc") continue;
|
||||
|
||||
//if (path != "tests/templates/template_class_type_usage_folded_into_one.cc") continue;
|
||||
//path = "C:/Users/jacob/Desktop/superindex/indexer/" + path;
|
||||
|
Loading…
Reference in New Issue
Block a user