From dd9b7fda3e188b959c8ce1f8be6b3c3fb32a70b4 Mon Sep 17 00:00:00 2001 From: peter klausler Date: Mon, 18 Feb 2019 13:47:34 -0800 Subject: [PATCH] [flang] Address review comments Original-commit: flang-compiler/f18@7662121287a4317e1090e3ca360e2e214d3698cd Reviewed-on: https://github.com/flang-compiler/f18/pull/287 --- flang/lib/semantics/mod-file.cc | 3 +-- flang/lib/semantics/symbol.cc | 20 +++++++++----------- flang/lib/semantics/symbol.h | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/flang/lib/semantics/mod-file.cc b/flang/lib/semantics/mod-file.cc index e79e785..7023c96 100644 --- a/flang/lib/semantics/mod-file.cc +++ b/flang/lib/semantics/mod-file.cc @@ -196,8 +196,7 @@ void ModFileWriter::PutDerivedType(const Symbol &typeSymbol) { auto &details{typeSymbol.get()}; PutAttrs(decls_ << "type", typeSymbol.attrs(), ","s, ""s); if (const DerivedTypeSpec * extends{typeSymbol.GetParentTypeSpec()}) { - PutLower(decls_ << ",extends(", extends->typeSymbol().name().ToString()) - << ')'; + PutLower(decls_ << ",extends(", extends->typeSymbol()) << ')'; } PutLower(decls_ << "::", typeSymbol); auto &typeScope{*typeSymbol.scope()}; diff --git a/flang/lib/semantics/symbol.cc b/flang/lib/semantics/symbol.cc index 932e84b..9e8b084 100644 --- a/flang/lib/semantics/symbol.cc +++ b/flang/lib/semantics/symbol.cc @@ -295,9 +295,9 @@ std::ostream &operator<<(std::ostream &os, const DerivedTypeDetails &x) { if (x.sequence_) { os << " sequence"; } - if (!x.components_.empty()) { + if (!x.componentNames_.empty()) { os << " components:"; - for (auto name : x.components_) { + for (auto name : x.componentNames_) { os << ' ' << name.ToString(); } } @@ -589,9 +589,7 @@ const Symbol *Symbol::GetParentComponent(const Scope *scope) const { const DerivedTypeSpec *Symbol::GetParentTypeSpec(const Scope *scope) const { if (const Symbol * parentComponent{GetParentComponent(scope)}) { const auto &object{parentComponent->get()}; - const DerivedTypeSpec *spec{object.type()->AsDerived()}; - CHECK(spec != nullptr); - return spec; + return &object.type()->derivedTypeSpec(); } else { return nullptr; } @@ -599,9 +597,9 @@ const DerivedTypeSpec *Symbol::GetParentTypeSpec(const Scope *scope) const { void DerivedTypeDetails::add_component(const Symbol &symbol) { if (symbol.test(Symbol::Flag::ParentComp)) { - CHECK(components_.empty()); + CHECK(componentNames_.empty()); } - components_.push_back(symbol.name()); + componentNames_.push_back(symbol.name()); } std::list DerivedTypeDetails::OrderParameterNames( @@ -634,14 +632,14 @@ SymbolList DerivedTypeDetails::OrderParameterDeclarations( SymbolList DerivedTypeDetails::OrderComponents(const Scope &scope) const { SymbolList result; - for (SourceName name : components_) { + for (SourceName name : componentNames_) { auto iter{scope.find(name)}; if (iter != scope.cend()) { const Symbol &symbol{*iter->second}; if (symbol.test(Symbol::Flag::ParentComp)) { CHECK(result.empty()); const DerivedTypeSpec &spec{ - *symbol.get().type()->AsDerived()}; + symbol.get().type()->derivedTypeSpec()}; result = spec.typeSymbol().get().OrderComponents( *spec.scope()); } @@ -652,8 +650,8 @@ SymbolList DerivedTypeDetails::OrderComponents(const Scope &scope) const { } const Symbol *DerivedTypeDetails::GetParentComponent(const Scope &scope) const { - if (!components_.empty()) { - SourceName extends{components_.front()}; + if (!componentNames_.empty()) { + SourceName extends{componentNames_.front()}; auto iter{scope.find(extends)}; if (iter != scope.cend()) { const Symbol &symbol{*iter->second}; diff --git a/flang/lib/semantics/symbol.h b/flang/lib/semantics/symbol.h index 9a96518..9dc89fd 100644 --- a/flang/lib/semantics/symbol.h +++ b/flang/lib/semantics/symbol.h @@ -232,7 +232,7 @@ private: SymbolList paramDecls_; // These are the names of the derived type's components in component // order. A parent component, if any, appears first in this list. - std::list components_; + std::list componentNames_; bool sequence_{false}; friend std::ostream &operator<<(std::ostream &, const DerivedTypeDetails &); }; -- 2.7.4