[flang] Address review comments
authorpeter klausler <pklausler@nvidia.com>
Mon, 18 Feb 2019 21:47:34 +0000 (13:47 -0800)
committerpeter klausler <pklausler@nvidia.com>
Mon, 18 Feb 2019 21:47:34 +0000 (13:47 -0800)
Original-commit: flang-compiler/f18@7662121287a4317e1090e3ca360e2e214d3698cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/287

flang/lib/semantics/mod-file.cc
flang/lib/semantics/symbol.cc
flang/lib/semantics/symbol.h

index e79e785..7023c96 100644 (file)
@@ -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()};
index 932e84b..9e8b084 100644 (file)
@@ -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};
index 9a96518..9dc89fd 100644 (file)
@@ -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 &);
 };