[flang] Dump function return attributes
authorTim Keith <tkeith@nvidia.com>
Wed, 20 Mar 2019 20:52:33 +0000 (13:52 -0700)
committerTim Keith <tkeith@nvidia.com>
Fri, 29 Mar 2019 16:08:18 +0000 (09:08 -0700)
Also, change SubprogramDetails::result_ from `std::optional<Symbol *>`
to `Symbol *`. We don't need two levels of optional-ness.

Original-commit: flang-compiler/f18@db3b874946dc9b139009d7e10832edb2a076a7bc
Reviewed-on: https://github.com/flang-compiler/f18/pull/368
Tree-same-pre-rewrite: false

flang/lib/semantics/symbol.cc
flang/lib/semantics/symbol.h

index 34189b2..eb748cf 100644 (file)
@@ -56,7 +56,10 @@ std::ostream &operator<<(std::ostream &os, const SubprogramDetails &x) {
     os << " bindName:" << x.bindName_;
   }
   if (x.result_) {
-    os << " result:" << x.result_.value()->name();
+    os << " result:" << x.result_->name();
+    if (!x.result_->attrs().empty()) {
+      os << ", " << x.result_->attrs();
+    }
   }
   if (x.dummyArgs_.empty()) {
     char sep{'('};
index 5abc104..1356605 100644 (file)
@@ -60,17 +60,17 @@ public:
   SubprogramDetails(const SubprogramDetails &that)
     : dummyArgs_{that.dummyArgs_}, result_{that.result_} {}
 
-  bool isFunction() const { return result_.has_value(); }
+  bool isFunction() const { return result_ != nullptr; }
   bool isInterface() const { return isInterface_; }
   void set_isInterface(bool value = true) { isInterface_ = value; }
   MaybeExpr bindName() const { return bindName_; }
   void set_bindName(MaybeExpr &&expr) { bindName_ = std::move(expr); }
   const Symbol &result() const {
     CHECK(isFunction());
-    return **result_;
+    return *result_;
   }
   void set_result(Symbol &result) {
-    CHECK(!result_.has_value());
+    CHECK(result_ == nullptr);
     result_ = &result;
   }
   const std::list<Symbol *> &dummyArgs() const { return dummyArgs_; }
@@ -80,7 +80,7 @@ private:
   bool isInterface_{false};  // true if this represents an interface-body
   MaybeExpr bindName_;
   std::list<Symbol *> dummyArgs_;
-  std::optional<Symbol *> result_;
+  Symbol *result_{nullptr};
   friend std::ostream &operator<<(std::ostream &, const SubprogramDetails &);
 };