[flang] Remove include of symbol.h from variable.h
authorTim Keith <tkeith@nvidia.com>
Wed, 7 Nov 2018 01:12:02 +0000 (17:12 -0800)
committerTim Keith <tkeith@nvidia.com>
Wed, 7 Nov 2018 01:12:02 +0000 (17:12 -0800)
This include will lead to circularities when semantics/type.h needs
include evaluate/expression.h. There will probably be a different
long-term solution.

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

flang/lib/evaluate/variable.cc
flang/lib/evaluate/variable.h

index fd94004..c78b7c0 100644 (file)
@@ -27,6 +27,12 @@ using namespace Fortran::parser::literals;
 
 namespace Fortran::evaluate {
 
+int GetSymbolRank(const Symbol *symbol) { return symbol->Rank(); }
+
+const parser::CharBlock &GetSymbolName(const Symbol *symbol) {
+  return symbol->name();
+}
+
 // Constructors, accessors, mutators
 
 Triplet::Triplet(std::optional<Expr<SubscriptInteger>> &&l,
index 217f93c..144b8d9 100644 (file)
 #include "type.h"
 #include "../common/idioms.h"
 #include "../common/template.h"
-#include "../semantics/symbol.h"
 #include <optional>
 #include <ostream>
 #include <variant>
 #include <vector>
 
+namespace Fortran::semantics {
+class Symbol;
+}
+
 namespace Fortran::evaluate {
 
 using semantics::Symbol;
@@ -45,6 +48,9 @@ template<typename A> struct Variable;
 using IndirectSubscriptIntegerExpr =
     CopyableIndirection<Expr<SubscriptInteger>>;
 
+int GetSymbolRank(const Symbol *);
+const parser::CharBlock &GetSymbolName(const Symbol *);
+
 // R913 structure-component & C920: Defined to be a multi-part
 // data-ref whose last part has no subscripts (or image-selector, although
 // that isn't explicit in the document).  Pointer and allocatable components
@@ -261,7 +267,7 @@ public:
 
   int Rank() const {
     return std::visit(
-        common::visitors{[](const Symbol *sym) { return sym->Rank(); },
+        common::visitors{[](const Symbol *sym) { return GetSymbolRank(sym); },
             [](const auto &x) { return x.Rank(); }},
         u);
   }
@@ -276,7 +282,7 @@ public:
 
   std::ostream &Dump(std::ostream &o) const {
     std::visit(common::visitors{[&](const Symbol *sym) {
-                                  o << sym->name().ToString();
+                                  o << GetSymbolName(sym).ToString();
                                 },
                    [&](const auto &x) { x.Dump(o); }},
         u);