diff --git a/src/indexer.h b/src/indexer.h index 8b0c1459..cac79feb 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -45,7 +45,7 @@ struct Id { namespace std { template struct hash> { - size_t operator()(const Id& k) const { return hash()(k.id); } + size_t operator()(const Id& k) const { return hash()(k.id); } }; } @@ -455,4 +455,4 @@ struct IndexedFile { }; std::vector> Parse(FileConsumer::SharedState* file_consumer_shared, std::string filename, std::vector args, bool dump_ast = false); -void IndexInit(); \ No newline at end of file +void IndexInit(); diff --git a/src/project.cc b/src/project.cc index 99877cc9..10787fbb 100644 --- a/src/project.cc +++ b/src/project.cc @@ -13,10 +13,11 @@ struct CompileCommandsEntry { std::string directory; - std::string filename; + std::string file; + std::string command; std::vector args; }; -MAKE_REFLECT_STRUCT(CompileCommandsEntry, directory, filename, args); +MAKE_REFLECT_STRUCT(CompileCommandsEntry, directory, file, command, args); namespace { @@ -39,11 +40,11 @@ static const char *kValueArgs[] = { "-arch", "-b", "-gcc-toolchain", - "-imacros", + //"-imacros", "-imultilib", - "-include", - "-iprefix", - "-isysroot", + //"-include", + //"-iprefix", + //"-isysroot", "-ivfsoverlay", "-iwithprefix", "-iwithprefixbefore", @@ -93,13 +94,15 @@ static const char *kBlacklist[] = { //"-f", //"-pipe", //"-W", + // TODO + "-Wno-unused-lambda-capture", "/", "..", }; CompilationEntry GetCompilationEntryFromCompileCommandEntry(const CompileCommandsEntry& entry) { CompilationEntry result; - result.filename = NormalizePath(entry.filename); + result.filename = NormalizePath(entry.file); unsigned int num_args = entry.args.size(); result.args.reserve(num_args); @@ -199,7 +202,7 @@ std::vector LoadFromDirectoryListing(const std::string& projec std::vector LoadCompilationEntriesFromDirectory(const std::string& project_directory) { // 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 cx_db = clang_CompilationDatabase_fromDirectory(project_directory.c_str(), &cx_db_load_error); @@ -218,16 +221,16 @@ std::vector LoadCompilationEntriesFromDirectory(const std::str std::string directory = clang::ToString(clang_CompileCommand_getDirectory(cx_command)); std::string relative_filename = clang::ToString(clang_CompileCommand_getFilename(cx_command)); std::string absolute_filename = directory + "/" + relative_filename; - + CompileCommandsEntry entry; - entry.filename = NormalizePath(absolute_filename); + entry.file = NormalizePath(absolute_filename); entry.directory = directory; unsigned int num_args = clang_CompileCommand_getNumArgs(cx_command); entry.args.reserve(num_args); for (int i = 0; i < num_args; ++i) entry.args.push_back(clang::ToString(clang_CompileCommand_getArg(cx_command, i))); - + result.push_back(GetCompilationEntryFromCompileCommandEntry(entry)); } diff --git a/src/query.cc b/src/query.cc index d760d676..b11b1137 100644 --- a/src/query.cc +++ b/src/query.cc @@ -71,7 +71,7 @@ void AddMergeableRange( // time at the cost of some additional memory. // Build lookup table. - google::dense_hash_map id_to_index; + google::dense_hash_map> id_to_index; id_to_index.set_empty_key(TId(-1)); id_to_index.resize(dest->size()); for (size_t i = 0; i < dest->size(); ++i) diff --git a/src/query.h b/src/query.h index 41e6610e..9b8ccaac 100644 --- a/src/query.h +++ b/src/query.h @@ -5,6 +5,8 @@ #include +#include + using Usr = std::string; struct QueryFile; @@ -308,7 +310,7 @@ struct IdMap { SymbolIdx ToSymbol(IndexFuncId id) const; SymbolIdx ToSymbol(IndexVarId id) const; private: - google::dense_hash_map cached_type_ids_; - google::dense_hash_map cached_func_ids_; - google::dense_hash_map cached_var_ids_; + google::dense_hash_map> cached_type_ids_; + google::dense_hash_map> cached_func_ids_; + google::dense_hash_map> cached_var_ids_; }; diff --git a/src/working_files.cc b/src/working_files.cc index 72b30eb1..b6b14d2b 100644 --- a/src/working_files.cc +++ b/src/working_files.cc @@ -2,6 +2,8 @@ #include "position.h" +#include + namespace { int GetOffsetForPosition(lsPosition position, const std::string& content) { @@ -168,4 +170,4 @@ std::vector WorkingFiles::AsUnsavedFiles() const { for (auto& file : files) result.push_back(file->AsUnsavedFile()); return result; -} \ No newline at end of file +}