From d67415ffb213a67a0cc2faab9c7cf8955f75b0fc 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, 24 Jun 2019 16:49:29 +0900 Subject: [PATCH] [locop] Use const loco::Node * (if possible) (#3946) This commit rewrites some code that takes loco::Node * as input to take const loco::Node * instead. This is a preliminary step to use loco visitor. Signed-off-by: Jonghyun Park --- contrib/locop/src/FormattedGraph.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contrib/locop/src/FormattedGraph.cpp b/contrib/locop/src/FormattedGraph.cpp index 1a07b7e..ab39307 100644 --- a/contrib/locop/src/FormattedGraph.cpp +++ b/contrib/locop/src/FormattedGraph.cpp @@ -13,9 +13,9 @@ namespace { -using SymbolTable = std::map; +using SymbolTable = std::map; -std::string symbol_lookup(const SymbolTable &tbl, loco::Node *node) +std::string symbol_lookup(const SymbolTable &tbl, const loco::Node *node) { if (node == nullptr) { @@ -33,11 +33,11 @@ namespace /** * @brief Return the opname as "." */ -std::string opname(loco::Node *node) +std::string opname(const loco::Node *node) { if (node->dialect() == loco::CanonicalDialect::get()) { - auto canonical_node = dynamic_cast(node); + auto canonical_node = dynamic_cast(node); assert(canonical_node != nullptr); @@ -141,7 +141,7 @@ std::ostream &operator<<(std::ostream &os, const NodeDesc &d) return os; } -NodeDesc default_node_desc(const SymbolTable &tbl, loco::Node *node) +NodeDesc default_node_desc(const SymbolTable &tbl, const loco::Node *node) { NodeDesc res{opname(node)}; @@ -154,7 +154,7 @@ NodeDesc default_node_desc(const SymbolTable &tbl, loco::Node *node) return res; } -NodeDesc node_desc(const SymbolTable &tbl, loco::Node *node) +NodeDesc node_desc(const SymbolTable &tbl, const loco::Node *node) { if (node->dialect() == loco::CanonicalDialect::get()) { @@ -185,7 +185,7 @@ void FormattedGraphImpl::dump(std::ostream &os) const { SymbolTable symbols; - auto symbol = [&symbols](loco::Node *node) { return symbol_lookup(symbols, node); }; + auto symbol = [&symbols](const loco::Node *node) { return symbol_lookup(symbols, node); }; for (uint32_t n = 0; n < _graph->nodes()->size(); ++n) { -- 2.7.4