diff --git a/src/clang_cursor.cc b/src/clang_cursor.cc index 1e82bd30..45842bae 100644 --- a/src/clang_cursor.cc +++ b/src/clang_cursor.cc @@ -60,7 +60,7 @@ std::string ClangType::get_usr() const { return ClangCursor(clang_getTypeDeclaration(cx_type)).get_usr(); } -USR ClangType::get_usr_hash() const { +Usr ClangType::get_usr_hash() const { return ClangCursor(clang_getTypeDeclaration(cx_type)).get_usr_hash(); } @@ -172,9 +172,9 @@ std::string ClangCursor::get_usr() const { return ::ToString(clang_getCursorUSR(cx_cursor)); } -USR ClangCursor::get_usr_hash() const { +Usr ClangCursor::get_usr_hash() const { CXString usr = clang_getCursorUSR(cx_cursor); - USR ret = HashUSR(clang_getCString(usr)); + Usr ret = HashUSR(clang_getCString(usr)); clang_disposeString(usr); return ret; } diff --git a/src/clang_cursor.h b/src/clang_cursor.h index 78f10cd7..c4a7c580 100644 --- a/src/clang_cursor.h +++ b/src/clang_cursor.h @@ -9,12 +9,12 @@ #include #include -using USR = uint64_t; +using Usr = uint64_t; Range ResolveCXSourceRange(const CXSourceRange& range, CXFile* cx_file = nullptr); -USR HashUSR(const char* usr); +Usr HashUSR(const char* usr); class ClangType { public: @@ -29,7 +29,7 @@ class ClangType { // ClangCursor is not defined so we have to return CXCursor CXCursor get_declaration() const; std::string get_usr() const; - USR get_usr_hash() const; + Usr get_usr_hash() const; std::string get_spelling() const; ClangType get_canonical() const; @@ -60,7 +60,7 @@ class ClangCursor { Range get_extent() const; std::string get_display_name() const; std::string get_usr() const; - USR get_usr_hash() const; + Usr get_usr_hash() const; bool is_definition() const; diff --git a/src/indexer.cc b/src/indexer.cc index caa52737..bf225499 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -112,10 +112,10 @@ ClangSymbolKind GetSymbolKind(CXIdxEntityKind kind) { // constructor we will not be able to attribute the constructor call correctly. struct ConstructorCache { struct Constructor { - USR usr; + Usr usr; std::vector param_type_desc; }; - std::unordered_map> constructors_; + std::unordered_map> constructors_; // This should be called whenever there is a constructor declaration. void NotifyConstructor(ClangCursor ctor_cursor) { @@ -142,8 +142,8 @@ struct ConstructorCache { // Tries to lookup a constructor in |type_usr| that takes arguments most // closely aligned to |param_type_desc|. - optional TryFindConstructorUsr( - USR type_usr, + optional TryFindConstructorUsr( + Usr type_usr, const std::vector& param_type_desc) { auto count_matching_prefix_length = [](const char* a, const char* b) { int matched = 0; @@ -170,7 +170,7 @@ struct ConstructorCache { if (ctors.empty()) return nullopt; - USR best_usr; + Usr best_usr; int best_score = INT_MIN; // Scan constructors for the best possible match. @@ -487,7 +487,7 @@ IndexFile::IndexFile(const std::string& path, } // TODO: Optimize for const char*? -IndexTypeId IndexFile::ToTypeId(USR usr) { +IndexTypeId IndexFile::ToTypeId(Usr usr) { auto it = id_cache.usr_to_type_id.find(usr); if (it != id_cache.usr_to_type_id.end()) return it->second; @@ -498,7 +498,7 @@ IndexTypeId IndexFile::ToTypeId(USR usr) { id_cache.type_id_to_usr[id] = usr; return id; } -IndexFuncId IndexFile::ToFuncId(USR usr) { +IndexFuncId IndexFile::ToFuncId(Usr usr) { auto it = id_cache.usr_to_func_id.find(usr); if (it != id_cache.usr_to_func_id.end()) return it->second; @@ -509,7 +509,7 @@ IndexFuncId IndexFile::ToFuncId(USR usr) { id_cache.func_id_to_usr[id] = usr; return id; } -IndexVarId IndexFile::ToVarId(USR usr) { +IndexVarId IndexFile::ToVarId(Usr usr) { auto it = id_cache.usr_to_var_id.find(usr); if (it != id_cache.usr_to_var_id.end()) return it->second; @@ -547,7 +547,7 @@ std::string IndexFile::ToString() { return Serialize(SerializeFormat::Json, *this); } -IndexType::IndexType(IndexTypeId id, USR usr) : usr(usr), id(id) {} +IndexType::IndexType(IndexTypeId id, Usr usr) : usr(usr), id(id) {} void RemoveItem(std::vector& ranges, Range to_remove) { auto it = std::find(ranges.begin(), ranges.end(), to_remove); @@ -951,7 +951,7 @@ ClangCursor::VisitResult AddDeclInitializerUsagesVisitor(ClangCursor cursor, break; // TODO: when we resolve the template type to the definition, we get a - // different USR. + // different Usr. // ClangCursor ref = // cursor.get_referenced().template_specialization_to_template_definition().get_type().strip_qualifiers().get_usr_hash(); @@ -1011,7 +1011,7 @@ ClangCursor::VisitResult VisitMacroDefinitionAndExpansions(ClangCursor cursor, // only real difference will be that we show 'callers' instead of 'refs' // (especially since macros cannot have overrides) - USR decl_usr; + Usr decl_usr; if (cursor.get_kind() == CXCursor_MacroDefinition) decl_usr = cursor.get_usr_hash(); else @@ -1777,7 +1777,7 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) { // the constructor function we add a usage to. optional opt_found_type = FindType(ref->cursor); if (opt_found_type) { - USR ctor_type_usr = opt_found_type->get_referenced().get_usr_hash(); + Usr ctor_type_usr = opt_found_type->get_referenced().get_usr_hash(); ClangCursor call_cursor = ref->cursor; // Build a type description from the parameters of the call, so we @@ -1790,7 +1790,7 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) { } // Try to find the constructor and add a reference. - optional ctor_usr = + optional ctor_usr = param->ctors.TryFindConstructorUsr(ctor_type_usr, call_type_desc); if (ctor_usr) { IndexFunc* ctor = db->Resolve(db->ToFuncId(*ctor_usr)); diff --git a/src/indexer.h b/src/indexer.h index 7eac4052..cf75ccef 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -260,7 +260,7 @@ struct IndexType { using Def = TypeDefDefinitionData; - USR usr; + Usr usr; IndexTypeId id; Def def; @@ -276,7 +276,7 @@ struct IndexType { std::vector uses; IndexType() {} // For serialization. - IndexType(IndexTypeId id, USR usr); + IndexType(IndexTypeId id, Usr usr); bool operator<(const IndexType& other) const { return id < other.id; } }; @@ -362,7 +362,7 @@ struct IndexFunc { IndexFuncRef, Range>; - USR usr; + Usr usr; IndexFuncId id; Def def; @@ -392,7 +392,7 @@ struct IndexFunc { std::vector callers; IndexFunc() {} // For serialization. - IndexFunc(IndexFuncId id, USR usr) : usr(usr), id(id) { + IndexFunc(IndexFuncId id, Usr usr) : usr(usr), id(id) { // assert(usr.size() > 0); } @@ -469,7 +469,7 @@ void Reflect(TVisitor& visitor, struct IndexVar { using Def = VarDefDefinitionData; - USR usr; + Usr usr; IndexVarId id; Def def; @@ -478,7 +478,7 @@ struct IndexVar { std::vector uses; IndexVar() {} // For serialization. - IndexVar(IndexVarId id, USR usr) : usr(usr), id(id) { + IndexVar(IndexVarId id, Usr usr) : usr(usr), id(id) { // assert(usr.size() > 0); } @@ -488,12 +488,12 @@ MAKE_HASHABLE(IndexVar, t.id); struct IdCache { std::string primary_file; - std::unordered_map usr_to_type_id; - std::unordered_map usr_to_func_id; - std::unordered_map usr_to_var_id; - std::unordered_map type_id_to_usr; - std::unordered_map func_id_to_usr; - std::unordered_map var_id_to_usr; + std::unordered_map usr_to_type_id; + std::unordered_map usr_to_func_id; + std::unordered_map usr_to_var_id; + std::unordered_map type_id_to_usr; + std::unordered_map func_id_to_usr; + std::unordered_map var_id_to_usr; IdCache(const std::string& primary_file); }; @@ -545,9 +545,9 @@ struct IndexFile { IndexFile(const std::string& path, const optional& contents); - IndexTypeId ToTypeId(USR usr); - IndexFuncId ToFuncId(USR usr); - IndexVarId ToVarId(USR usr); + IndexTypeId ToTypeId(Usr usr); + IndexFuncId ToFuncId(Usr usr); + IndexVarId ToVarId(Usr usr); IndexTypeId ToTypeId(const CXCursor& usr); IndexFuncId ToFuncId(const CXCursor& usr); IndexVarId ToVarId(const CXCursor& usr); diff --git a/src/query.cc b/src/query.cc index f54b324a..921b24bb 100644 --- a/src/query.cc +++ b/src/query.cc @@ -291,7 +291,7 @@ QueryFileId GetQueryFileIdFromPath(QueryDatabase* query_db, return QueryFileId(idx); } -QueryTypeId GetQueryTypeIdFromUsr(QueryDatabase* query_db, USR usr) { +QueryTypeId GetQueryTypeIdFromUsr(QueryDatabase* query_db, Usr usr) { auto it = query_db->usr_to_type.find(usr); if (it != query_db->usr_to_type.end()) return QueryTypeId(it->second.id); @@ -302,7 +302,7 @@ QueryTypeId GetQueryTypeIdFromUsr(QueryDatabase* query_db, USR usr) { return QueryTypeId(idx); } -QueryFuncId GetQueryFuncIdFromUsr(QueryDatabase* query_db, USR usr) { +QueryFuncId GetQueryFuncIdFromUsr(QueryDatabase* query_db, Usr usr) { auto it = query_db->usr_to_func.find(usr); if (it != query_db->usr_to_func.end()) return QueryFuncId(it->second.id); diff --git a/src/query.h b/src/query.h index e372a87d..26e21cda 100644 --- a/src/query.h +++ b/src/query.h @@ -7,8 +7,6 @@ #include -using Usr = USR; - struct QueryFile; struct QueryType; struct QueryFunc; @@ -170,10 +168,10 @@ void Reflect(TVisitor& visitor, MergeableUpdate& value) { template struct WithUsr { - USR usr; + Usr usr; T value; - WithUsr(USR usr, const T& value) : usr(usr), value(value) {} + WithUsr(Usr usr, const T& value) : usr(usr), value(value) {} }; template void Reflect(TVisitor& visitor, WithUsr& value) { @@ -225,7 +223,7 @@ struct QueryType { using InstancesUpdate = MergeableUpdate; using UsesUpdate = MergeableUpdate; - USR usr; + Usr usr; optional def; std::vector derived; std::vector instances; @@ -246,7 +244,7 @@ struct QueryFunc { using DerivedUpdate = MergeableUpdate; using CallersUpdate = MergeableUpdate; - USR usr; + Usr usr; optional def; std::vector declarations; std::vector derived;