From 66d27050251a3a89c874a488dbf76fada4aeccd9 Mon Sep 17 00:00:00 2001 From: Tim Keith Date: Wed, 7 Nov 2018 12:41:52 -0800 Subject: [PATCH] [flang] Address review comments Change `const Symbol *` to `const Symbol &`. Simplify expression for `Assumed()` and `Deferred()` in `ParamValue`. Original-commit: flang-compiler/f18@b3e76706ca72b5d324c96bee4db8efae34e3135e Reviewed-on: https://github.com/flang-compiler/f18/pull/223 --- flang/lib/evaluate/variable.cc | 6 +++--- flang/lib/evaluate/variable.h | 8 ++++---- flang/lib/semantics/type.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/flang/lib/evaluate/variable.cc b/flang/lib/evaluate/variable.cc index c78b7c078e48..7a1be3e35952 100644 --- a/flang/lib/evaluate/variable.cc +++ b/flang/lib/evaluate/variable.cc @@ -27,10 +27,10 @@ using namespace Fortran::parser::literals; namespace Fortran::evaluate { -int GetSymbolRank(const Symbol *symbol) { return symbol->Rank(); } +int GetSymbolRank(const Symbol &symbol) { return symbol.Rank(); } -const parser::CharBlock &GetSymbolName(const Symbol *symbol) { - return symbol->name(); +const parser::CharBlock &GetSymbolName(const Symbol &symbol) { + return symbol.name(); } // Constructors, accessors, mutators diff --git a/flang/lib/evaluate/variable.h b/flang/lib/evaluate/variable.h index 144b8d9a986f..52e365cbfc00 100644 --- a/flang/lib/evaluate/variable.h +++ b/flang/lib/evaluate/variable.h @@ -48,8 +48,8 @@ template struct Variable; using IndirectSubscriptIntegerExpr = CopyableIndirection>; -int GetSymbolRank(const Symbol *); -const parser::CharBlock &GetSymbolName(const Symbol *); +int GetSymbolRank(const Symbol &); +const parser::CharBlock &GetSymbolName(const Symbol &); // R913 structure-component & C920: Defined to be a multi-part // data-ref whose last part has no subscripts (or image-selector, although @@ -267,7 +267,7 @@ public: int Rank() const { return std::visit( - common::visitors{[](const Symbol *sym) { return GetSymbolRank(sym); }, + common::visitors{[](const Symbol *sym) { return GetSymbolRank(*sym); }, [](const auto &x) { return x.Rank(); }}, u); } @@ -282,7 +282,7 @@ public: std::ostream &Dump(std::ostream &o) const { std::visit(common::visitors{[&](const Symbol *sym) { - o << GetSymbolName(sym).ToString(); + o << GetSymbolName(*sym).ToString(); }, [&](const auto &x) { x.Dump(o); }}, u); diff --git a/flang/lib/semantics/type.h b/flang/lib/semantics/type.h index 6d79ef5b8d8d..164132d810c0 100644 --- a/flang/lib/semantics/type.h +++ b/flang/lib/semantics/type.h @@ -228,8 +228,8 @@ private: // A type parameter value: integer expression or assumed or deferred. class ParamValue { public: - static const ParamValue Assumed() { return ParamValue(Category::Assumed); } - static const ParamValue Deferred() { return ParamValue(Category::Deferred); } + static const ParamValue Assumed() { return Category::Assumed; } + static const ParamValue Deferred() { return Category::Deferred; } ParamValue(const parser::Expr &); bool isExplicit() const { return category_ == Category::Explicit; } bool isAssumed() const { return category_ == Category::Assumed; }