From 50aaba78e451f585f331cb97b802dc4ec1d58093 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 9 Sep 2019 18:37:11 +0900 Subject: [PATCH] [locomotiv] Use const if possible (#7264) "annot_data" and "annot_domain" do not change the node itself. This commit revies the signature of these helpers to express this property explicitly. Signed-off-by: Jonghyun Park --- compiler/locomotiv/src/NodeDataImpl.cpp | 2 +- compiler/locomotiv/src/NodeDataImpl.h | 2 +- compiler/locomotiv/src/NodeDomain.cpp | 2 +- compiler/locomotiv/src/NodeDomain.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/locomotiv/src/NodeDataImpl.cpp b/compiler/locomotiv/src/NodeDataImpl.cpp index 55d7b5a..1111f4c 100644 --- a/compiler/locomotiv/src/NodeDataImpl.cpp +++ b/compiler/locomotiv/src/NodeDataImpl.cpp @@ -43,7 +43,7 @@ void annot_data(loco::Node *node, std::unique_ptr &&data) node->annot(std::unique_ptr(impl)); } -const NodeData *annot_data(loco::Node *node) +const NodeData *annot_data(const loco::Node *node) { auto impl = node->annot(); auto data = dynamic_cast(impl); diff --git a/compiler/locomotiv/src/NodeDataImpl.h b/compiler/locomotiv/src/NodeDataImpl.h index 012a8c8..1c52957 100644 --- a/compiler/locomotiv/src/NodeDataImpl.h +++ b/compiler/locomotiv/src/NodeDataImpl.h @@ -50,7 +50,7 @@ private: void annot_data(loco::Node *node, std::unique_ptr &&data); /// @brief Wrapper to get NodeDataImpl annotation of node -const NodeData *annot_data(loco::Node *node); +const NodeData *annot_data(const loco::Node *node); /// @brief Erase already annotated NodeDataImpl void erase_annot_data(loco::Node *node); diff --git a/compiler/locomotiv/src/NodeDomain.cpp b/compiler/locomotiv/src/NodeDomain.cpp index a1f3a56..709b9fe 100644 --- a/compiler/locomotiv/src/NodeDomain.cpp +++ b/compiler/locomotiv/src/NodeDomain.cpp @@ -39,7 +39,7 @@ void annot_domain(loco::Node *node, const loco::Domain &domain) node->annot(std::move(node_domain)); } -loco::Domain annot_domain(loco::Node *node) +loco::Domain annot_domain(const loco::Node *node) { auto node_domain = node->annot(); if (node_domain) diff --git a/compiler/locomotiv/src/NodeDomain.h b/compiler/locomotiv/src/NodeDomain.h index 6e517a6..fc93f77 100644 --- a/compiler/locomotiv/src/NodeDomain.h +++ b/compiler/locomotiv/src/NodeDomain.h @@ -27,7 +27,7 @@ namespace locomotiv void annot_domain(loco::Node *node, const loco::Domain &domain); /// @brief Wrapper to get domain annotation of node -loco::Domain annot_domain(loco::Node *node); +loco::Domain annot_domain(const loco::Node *node); /// @brief Erase already annotated node domain void erase_annot_domain(loco::Node *node); -- 2.7.4