mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-31 18:00:26 +00:00
Misc fixes
This commit is contained in:
parent
7f4d902dcf
commit
26c0bfe71d
@ -45,7 +45,7 @@ struct Id {
|
|||||||
namespace std {
|
namespace std {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct hash<Id<T>> {
|
struct hash<Id<T>> {
|
||||||
size_t operator()(const Id<T>& k) const { return hash<uint64_t>()(k.id); }
|
size_t operator()(const Id<T>& k) const { return hash<size_t>()(k.id); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,4 +455,4 @@ struct IndexedFile {
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::vector<std::unique_ptr<IndexedFile>> Parse(FileConsumer::SharedState* file_consumer_shared, std::string filename, std::vector<std::string> args, bool dump_ast = false);
|
std::vector<std::unique_ptr<IndexedFile>> Parse(FileConsumer::SharedState* file_consumer_shared, std::string filename, std::vector<std::string> args, bool dump_ast = false);
|
||||||
void IndexInit();
|
void IndexInit();
|
||||||
|
@ -13,10 +13,11 @@
|
|||||||
|
|
||||||
struct CompileCommandsEntry {
|
struct CompileCommandsEntry {
|
||||||
std::string directory;
|
std::string directory;
|
||||||
std::string filename;
|
std::string file;
|
||||||
|
std::string command;
|
||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(CompileCommandsEntry, directory, filename, args);
|
MAKE_REFLECT_STRUCT(CompileCommandsEntry, directory, file, command, args);
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -39,11 +40,11 @@ static const char *kValueArgs[] = {
|
|||||||
"-arch",
|
"-arch",
|
||||||
"-b",
|
"-b",
|
||||||
"-gcc-toolchain",
|
"-gcc-toolchain",
|
||||||
"-imacros",
|
//"-imacros",
|
||||||
"-imultilib",
|
"-imultilib",
|
||||||
"-include",
|
//"-include",
|
||||||
"-iprefix",
|
//"-iprefix",
|
||||||
"-isysroot",
|
//"-isysroot",
|
||||||
"-ivfsoverlay",
|
"-ivfsoverlay",
|
||||||
"-iwithprefix",
|
"-iwithprefix",
|
||||||
"-iwithprefixbefore",
|
"-iwithprefixbefore",
|
||||||
@ -93,13 +94,15 @@ static const char *kBlacklist[] = {
|
|||||||
//"-f",
|
//"-f",
|
||||||
//"-pipe",
|
//"-pipe",
|
||||||
//"-W",
|
//"-W",
|
||||||
|
// TODO
|
||||||
|
"-Wno-unused-lambda-capture",
|
||||||
"/",
|
"/",
|
||||||
"..",
|
"..",
|
||||||
};
|
};
|
||||||
|
|
||||||
CompilationEntry GetCompilationEntryFromCompileCommandEntry(const CompileCommandsEntry& entry) {
|
CompilationEntry GetCompilationEntryFromCompileCommandEntry(const CompileCommandsEntry& entry) {
|
||||||
CompilationEntry result;
|
CompilationEntry result;
|
||||||
result.filename = NormalizePath(entry.filename);
|
result.filename = NormalizePath(entry.file);
|
||||||
|
|
||||||
unsigned int num_args = entry.args.size();
|
unsigned int num_args = entry.args.size();
|
||||||
result.args.reserve(num_args);
|
result.args.reserve(num_args);
|
||||||
@ -199,7 +202,7 @@ std::vector<CompilationEntry> LoadFromDirectoryListing(const std::string& projec
|
|||||||
|
|
||||||
std::vector<CompilationEntry> LoadCompilationEntriesFromDirectory(const std::string& project_directory) {
|
std::vector<CompilationEntry> LoadCompilationEntriesFromDirectory(const std::string& project_directory) {
|
||||||
// TODO: Figure out if this function or the clang one is faster.
|
// TODO: Figure out if this function or the clang one is faster.
|
||||||
return LoadFromCompileCommandsJson(project_directory);
|
//return LoadFromCompileCommandsJson(project_directory);
|
||||||
|
|
||||||
CXCompilationDatabase_Error cx_db_load_error;
|
CXCompilationDatabase_Error cx_db_load_error;
|
||||||
CXCompilationDatabase cx_db = clang_CompilationDatabase_fromDirectory(project_directory.c_str(), &cx_db_load_error);
|
CXCompilationDatabase cx_db = clang_CompilationDatabase_fromDirectory(project_directory.c_str(), &cx_db_load_error);
|
||||||
@ -218,16 +221,16 @@ std::vector<CompilationEntry> LoadCompilationEntriesFromDirectory(const std::str
|
|||||||
std::string directory = clang::ToString(clang_CompileCommand_getDirectory(cx_command));
|
std::string directory = clang::ToString(clang_CompileCommand_getDirectory(cx_command));
|
||||||
std::string relative_filename = clang::ToString(clang_CompileCommand_getFilename(cx_command));
|
std::string relative_filename = clang::ToString(clang_CompileCommand_getFilename(cx_command));
|
||||||
std::string absolute_filename = directory + "/" + relative_filename;
|
std::string absolute_filename = directory + "/" + relative_filename;
|
||||||
|
|
||||||
CompileCommandsEntry entry;
|
CompileCommandsEntry entry;
|
||||||
entry.filename = NormalizePath(absolute_filename);
|
entry.file = NormalizePath(absolute_filename);
|
||||||
entry.directory = directory;
|
entry.directory = directory;
|
||||||
|
|
||||||
unsigned int num_args = clang_CompileCommand_getNumArgs(cx_command);
|
unsigned int num_args = clang_CompileCommand_getNumArgs(cx_command);
|
||||||
entry.args.reserve(num_args);
|
entry.args.reserve(num_args);
|
||||||
for (int i = 0; i < num_args; ++i)
|
for (int i = 0; i < num_args; ++i)
|
||||||
entry.args.push_back(clang::ToString(clang_CompileCommand_getArg(cx_command, i)));
|
entry.args.push_back(clang::ToString(clang_CompileCommand_getArg(cx_command, i)));
|
||||||
|
|
||||||
result.push_back(GetCompilationEntryFromCompileCommandEntry(entry));
|
result.push_back(GetCompilationEntryFromCompileCommandEntry(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void AddMergeableRange(
|
|||||||
// time at the cost of some additional memory.
|
// time at the cost of some additional memory.
|
||||||
|
|
||||||
// Build lookup table.
|
// Build lookup table.
|
||||||
google::dense_hash_map<TId, size_t> id_to_index;
|
google::dense_hash_map<TId, size_t, std::hash<TId>> id_to_index;
|
||||||
id_to_index.set_empty_key(TId(-1));
|
id_to_index.set_empty_key(TId(-1));
|
||||||
id_to_index.resize(dest->size());
|
id_to_index.resize(dest->size());
|
||||||
for (size_t i = 0; i < dest->size(); ++i)
|
for (size_t i = 0; i < dest->size(); ++i)
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include <sparsehash/dense_hash_map>
|
#include <sparsehash/dense_hash_map>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
using Usr = std::string;
|
using Usr = std::string;
|
||||||
|
|
||||||
struct QueryFile;
|
struct QueryFile;
|
||||||
@ -308,7 +310,7 @@ struct IdMap {
|
|||||||
SymbolIdx ToSymbol(IndexFuncId id) const;
|
SymbolIdx ToSymbol(IndexFuncId id) const;
|
||||||
SymbolIdx ToSymbol(IndexVarId id) const;
|
SymbolIdx ToSymbol(IndexVarId id) const;
|
||||||
private:
|
private:
|
||||||
google::dense_hash_map<IndexTypeId, QueryTypeId> cached_type_ids_;
|
google::dense_hash_map<IndexTypeId, QueryTypeId, std::hash<IndexTypeId>> cached_type_ids_;
|
||||||
google::dense_hash_map<IndexFuncId, QueryFuncId> cached_func_ids_;
|
google::dense_hash_map<IndexFuncId, QueryFuncId, std::hash<IndexFuncId>> cached_func_ids_;
|
||||||
google::dense_hash_map<IndexVarId, QueryVarId> cached_var_ids_;
|
google::dense_hash_map<IndexVarId, QueryVarId, std::hash<IndexVarId>> cached_var_ids_;
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "position.h"
|
#include "position.h"
|
||||||
|
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
int GetOffsetForPosition(lsPosition position, const std::string& content) {
|
int GetOffsetForPosition(lsPosition position, const std::string& content) {
|
||||||
@ -168,4 +170,4 @@ std::vector<CXUnsavedFile> WorkingFiles::AsUnsavedFiles() const {
|
|||||||
for (auto& file : files)
|
for (auto& file : files)
|
||||||
result.push_back(file->AsUnsavedFile());
|
result.push_back(file->AsUnsavedFile());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user