forked from OSchip/llvm-project
[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:
parent
475d72f8e6
commit
dd9b7fda3e
|
@ -196,8 +196,7 @@ void ModFileWriter::PutDerivedType(const Symbol &typeSymbol) {
|
|||
auto &details{typeSymbol.get<DerivedTypeDetails>()};
|
||||
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()};
|
||||
|
|
|
@ -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<ObjectEntityDetails>()};
|
||||
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<SourceName> 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<ObjectEntityDetails>().type()->AsDerived()};
|
||||
symbol.get<ObjectEntityDetails>().type()->derivedTypeSpec()};
|
||||
result = spec.typeSymbol().get<DerivedTypeDetails>().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};
|
||||
|
|
|
@ -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<SourceName> components_;
|
||||
std::list<SourceName> componentNames_;
|
||||
bool sequence_{false};
|
||||
friend std::ostream &operator<<(std::ostream &, const DerivedTypeDetails &);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue