From f949e321f2a3c39a33d2c7b8706b1592d2a8c717 Mon Sep 17 00:00:00 2001 From: qining Date: Thu, 11 Aug 2016 18:19:50 -0400 Subject: [PATCH] Make the lookup up of type id accepts const arg --- source/opt/type_manager.cpp | 2 +- source/opt/type_manager.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/opt/type_manager.cpp b/source/opt/type_manager.cpp index 1e8bd33..351791c 100644 --- a/source/opt/type_manager.cpp +++ b/source/opt/type_manager.cpp @@ -40,7 +40,7 @@ Type* TypeManager::GetType(uint32_t id) const { return nullptr; } -uint32_t TypeManager::GetId(Type* type) const { +uint32_t TypeManager::GetId(const Type* type) const { auto iter = type_to_id_.find(type); if (iter != type_to_id_.end()) return (*iter).second; return 0; diff --git a/source/opt/type_manager.h b/source/opt/type_manager.h index 4d5dbd9..c6690cc 100644 --- a/source/opt/type_manager.h +++ b/source/opt/type_manager.h @@ -42,7 +42,7 @@ namespace analysis { class TypeManager { public: using IdToTypeMap = std::unordered_map>; - using TypeToIdMap = std::unordered_map; + using TypeToIdMap = std::unordered_map; using ForwardPointerVector = std::vector>; TypeManager(const spvtools::ir::Module& module) { AnalyzeTypes(module); } @@ -56,7 +56,7 @@ class TypeManager { Type* GetType(uint32_t id) const; // Returns the id for the given |type|. Returns 0 if can not find the given // |type|. - uint32_t GetId(Type* type) const; + uint32_t GetId(const Type* type) const; // Returns the number of types hold in this manager. size_t NumTypes() const { return id_to_type_.size(); } -- 2.7.4