[flang] Address review comments

Original-commit: flang-compiler/f18@7662121287
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
This commit is contained in:
peter klausler 2019-02-18 13:47:34 -08:00
parent 475d72f8e6
commit dd9b7fda3e
3 changed files with 11 additions and 14 deletions

View File

@ -196,8 +196,7 @@ void ModFileWriter::PutDerivedType(const Symbol &typeSymbol) {
auto &details{typeSymbol.get<DerivedTypeDetails>()}; auto &details{typeSymbol.get<DerivedTypeDetails>()};
PutAttrs(decls_ << "type", typeSymbol.attrs(), ","s, ""s); PutAttrs(decls_ << "type", typeSymbol.attrs(), ","s, ""s);
if (const DerivedTypeSpec * extends{typeSymbol.GetParentTypeSpec()}) { if (const DerivedTypeSpec * extends{typeSymbol.GetParentTypeSpec()}) {
PutLower(decls_ << ",extends(", extends->typeSymbol().name().ToString()) PutLower(decls_ << ",extends(", extends->typeSymbol()) << ')';
<< ')';
} }
PutLower(decls_ << "::", typeSymbol); PutLower(decls_ << "::", typeSymbol);
auto &typeScope{*typeSymbol.scope()}; auto &typeScope{*typeSymbol.scope()};

View File

@ -295,9 +295,9 @@ std::ostream &operator<<(std::ostream &os, const DerivedTypeDetails &x) {
if (x.sequence_) { if (x.sequence_) {
os << " sequence"; os << " sequence";
} }
if (!x.components_.empty()) { if (!x.componentNames_.empty()) {
os << " components:"; os << " components:";
for (auto name : x.components_) { for (auto name : x.componentNames_) {
os << ' ' << name.ToString(); os << ' ' << name.ToString();
} }
} }
@ -589,9 +589,7 @@ const Symbol *Symbol::GetParentComponent(const Scope *scope) const {
const DerivedTypeSpec *Symbol::GetParentTypeSpec(const Scope *scope) const { const DerivedTypeSpec *Symbol::GetParentTypeSpec(const Scope *scope) const {
if (const Symbol * parentComponent{GetParentComponent(scope)}) { if (const Symbol * parentComponent{GetParentComponent(scope)}) {
const auto &object{parentComponent->get<ObjectEntityDetails>()}; const auto &object{parentComponent->get<ObjectEntityDetails>()};
const DerivedTypeSpec *spec{object.type()->AsDerived()}; return &object.type()->derivedTypeSpec();
CHECK(spec != nullptr);
return spec;
} else { } else {
return nullptr; return nullptr;
} }
@ -599,9 +597,9 @@ const DerivedTypeSpec *Symbol::GetParentTypeSpec(const Scope *scope) const {
void DerivedTypeDetails::add_component(const Symbol &symbol) { void DerivedTypeDetails::add_component(const Symbol &symbol) {
if (symbol.test(Symbol::Flag::ParentComp)) { if (symbol.test(Symbol::Flag::ParentComp)) {
CHECK(components_.empty()); CHECK(componentNames_.empty());
} }
components_.push_back(symbol.name()); componentNames_.push_back(symbol.name());
} }
std::list<SourceName> DerivedTypeDetails::OrderParameterNames( std::list<SourceName> DerivedTypeDetails::OrderParameterNames(
@ -634,14 +632,14 @@ SymbolList DerivedTypeDetails::OrderParameterDeclarations(
SymbolList DerivedTypeDetails::OrderComponents(const Scope &scope) const { SymbolList DerivedTypeDetails::OrderComponents(const Scope &scope) const {
SymbolList result; SymbolList result;
for (SourceName name : components_) { for (SourceName name : componentNames_) {
auto iter{scope.find(name)}; auto iter{scope.find(name)};
if (iter != scope.cend()) { if (iter != scope.cend()) {
const Symbol &symbol{*iter->second}; const Symbol &symbol{*iter->second};
if (symbol.test(Symbol::Flag::ParentComp)) { if (symbol.test(Symbol::Flag::ParentComp)) {
CHECK(result.empty()); CHECK(result.empty());
const DerivedTypeSpec &spec{ const DerivedTypeSpec &spec{
*symbol.get<ObjectEntityDetails>().type()->AsDerived()}; symbol.get<ObjectEntityDetails>().type()->derivedTypeSpec()};
result = spec.typeSymbol().get<DerivedTypeDetails>().OrderComponents( result = spec.typeSymbol().get<DerivedTypeDetails>().OrderComponents(
*spec.scope()); *spec.scope());
} }
@ -652,8 +650,8 @@ SymbolList DerivedTypeDetails::OrderComponents(const Scope &scope) const {
} }
const Symbol *DerivedTypeDetails::GetParentComponent(const Scope &scope) const { const Symbol *DerivedTypeDetails::GetParentComponent(const Scope &scope) const {
if (!components_.empty()) { if (!componentNames_.empty()) {
SourceName extends{components_.front()}; SourceName extends{componentNames_.front()};
auto iter{scope.find(extends)}; auto iter{scope.find(extends)};
if (iter != scope.cend()) { if (iter != scope.cend()) {
const Symbol &symbol{*iter->second}; const Symbol &symbol{*iter->second};

View File

@ -232,7 +232,7 @@ private:
SymbolList paramDecls_; SymbolList paramDecls_;
// These are the names of the derived type's components in component // These are the names of the derived type's components in component
// order. A parent component, if any, appears first in this list. // order. A parent component, if any, appears first in this list.
std::list<SourceName> components_; std::list<SourceName> componentNames_;
bool sequence_{false}; bool sequence_{false};
friend std::ostream &operator<<(std::ostream &, const DerivedTypeDetails &); friend std::ostream &operator<<(std::ostream &, const DerivedTypeDetails &);
}; };