[flang-commits] [flang] [flang] Move DumpEvaluateExpr from Lower to Semantics (PR #128723)

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Wed Feb 26 06:08:03 PST 2025


https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/128723

>From 36aad22173abc0ef577c18d52fde98b0b5587eb2 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Thu, 9 Jan 2025 12:50:47 -0600
Subject: [PATCH 1/7] [flang] Move DumpEvaluateExpr from Lower to Semantics

Since evaluate::Expr can show up in the parse tree in the semantic
analysis step, make it possible to dump its structure in the Semantics
module.

The Lower module depends on Semantics, so the code is still accessible
in it.
---
 .../dump-expr.h}                              | 13 ++-
 flang/lib/Lower/CMakeLists.txt                |  1 -
 flang/lib/Lower/ConvertExpr.cpp               |  6 +-
 flang/lib/Semantics/CMakeLists.txt            |  1 +
 .../dump-expr.cpp}                            | 81 ++++++++++---------
 5 files changed, 51 insertions(+), 51 deletions(-)
 rename flang/include/flang/{Lower/DumpEvaluateExpr.h => Semantics/dump-expr.h} (95%)
 rename flang/lib/{Lower/DumpEvaluateExpr.cpp => Semantics/dump-expr.cpp} (70%)

diff --git a/flang/include/flang/Lower/DumpEvaluateExpr.h b/flang/include/flang/Semantics/dump-expr.h
similarity index 95%
rename from flang/include/flang/Lower/DumpEvaluateExpr.h
rename to flang/include/flang/Semantics/dump-expr.h
index 88f53e96a81c2..d51cb6539d29b 100644
--- a/flang/include/flang/Lower/DumpEvaluateExpr.h
+++ b/flang/include/flang/Semantics/dump-expr.h
@@ -1,4 +1,4 @@
-//===-- Lower/DumpEvaluateExpr.h --------------------------------*- C++ -*-===//
+//===-- Semantics/DumpEvaluateExpr.h ----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,15 +6,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_LOWER_DUMPEVALUATEEXPR_H
-#define FORTRAN_LOWER_DUMPEVALUATEEXPR_H
+#ifndef FORTRAN_SEMANTICS_DUMPEVALUATEEXPR_H
+#define FORTRAN_SEMANTICS_DUMPEVALUATEEXPR_H
 
 #include "flang/Evaluate/tools.h"
-#include "flang/Lower/Support/Utils.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 
-namespace Fortran::lower {
+namespace Fortran::semantics {
 
 /// Class to dump Fortran::evaluate::Expr trees out in a user readable way.
 ///
@@ -207,6 +206,6 @@ LLVM_DUMP_METHOD void dumpEvExpr(
     const Fortran::evaluate::Designator<
         Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x);
 
-} // namespace Fortran::lower
+} // namespace Fortran::semantics
 
-#endif // FORTRAN_LOWER_DUMPEVALUATEEXPR_H
+#endif // FORTRAN_SEMANTICS_DUMPEVALUATEEXPR_H
diff --git a/flang/lib/Lower/CMakeLists.txt b/flang/lib/Lower/CMakeLists.txt
index 87dc2a052796a..0bd9a47cd040f 100644
--- a/flang/lib/Lower/CMakeLists.txt
+++ b/flang/lib/Lower/CMakeLists.txt
@@ -16,7 +16,6 @@ add_flang_library(FortranLower
   ConvertType.cpp
   ConvertVariable.cpp
   CustomIntrinsicCall.cpp
-  DumpEvaluateExpr.cpp
   HlfirIntrinsics.cpp
   HostAssociations.cpp
   IO.cpp
diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index b33baf90582b8..41b9ab52c52b0 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -27,7 +27,6 @@
 #include "flang/Lower/ConvertType.h"
 #include "flang/Lower/ConvertVariable.h"
 #include "flang/Lower/CustomIntrinsicCall.h"
-#include "flang/Lower/DumpEvaluateExpr.h"
 #include "flang/Lower/Mangler.h"
 #include "flang/Lower/Runtime.h"
 #include "flang/Lower/Support/Utils.h"
@@ -47,6 +46,7 @@
 #include "flang/Optimizer/Dialect/FIROpsSupport.h"
 #include "flang/Optimizer/Support/FatalError.h"
 #include "flang/Runtime/support.h"
+#include "flang/Semantics/dump-expr.h"
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
@@ -3925,7 +3925,7 @@ class ArrayExprLowering {
   /// determine the actual number of iterations when slicing triples are
   /// present. Lower these expressions here.
   bool determineShapeWithSlice(const Fortran::lower::SomeExpr &lhs) {
-    LLVM_DEBUG(Fortran::lower::DumpEvaluateExpr::dump(
+    LLVM_DEBUG(Fortran::semantics::DumpEvaluateExpr::dump(
         llvm::dbgs() << "determine shape of:\n", lhs));
     // FIXME: We may not want to use ExtractDataRef here since it doesn't deal
     // with substrings, etc.
@@ -5073,7 +5073,7 @@ class ArrayExprLowering {
 
   template <typename A>
   CC genarr(const Fortran::evaluate::Expr<A> &x) {
-    LLVM_DEBUG(Fortran::lower::DumpEvaluateExpr::dump(llvm::dbgs(), x));
+    LLVM_DEBUG(Fortran::semantics::DumpEvaluateExpr::dump(llvm::dbgs(), x));
     if (isArray(x) || (explicitSpaceIsActive() && isLeftHandSide()) ||
         isElementalProcWithArrayArgs(x))
       return Fortran::common::visit([&](const auto &e) { return genarr(e); },
diff --git a/flang/lib/Semantics/CMakeLists.txt b/flang/lib/Semantics/CMakeLists.txt
index 00108dde49dbd..93bf0c7c5facd 100644
--- a/flang/lib/Semantics/CMakeLists.txt
+++ b/flang/lib/Semantics/CMakeLists.txt
@@ -29,6 +29,7 @@ add_flang_library(FortranSemantics
   compute-offsets.cpp
   data-to-inits.cpp
   definable.cpp
+  dump-expr.cpp
   expression.cpp
   mod-file.cpp
   openmp-modifiers.cpp
diff --git a/flang/lib/Lower/DumpEvaluateExpr.cpp b/flang/lib/Semantics/dump-expr.cpp
similarity index 70%
rename from flang/lib/Lower/DumpEvaluateExpr.cpp
rename to flang/lib/Semantics/dump-expr.cpp
index 9273e94d702f8..f0b0ecabf950a 100644
--- a/flang/lib/Lower/DumpEvaluateExpr.cpp
+++ b/flang/lib/Semantics/dump-expr.cpp
@@ -1,4 +1,4 @@
-//===-- Lower/DumpEvaluateExpr.cpp ----------------------------------------===//
+//===-- Semantics/DumpEvaluateExpr.cpp ------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,19 +6,20 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Lower/DumpEvaluateExpr.h"
+#include "flang/Semantics/dump-expr.h"
 #include <iostream>
 
 static constexpr char whiteSpacePadding[] =
     ">>                                               ";
 static constexpr auto whiteSize = sizeof(whiteSpacePadding) - 1;
 
-inline const char *Fortran::lower::DumpEvaluateExpr::getIndentString() const {
+inline const char *
+Fortran::semantics::DumpEvaluateExpr::getIndentString() const {
   auto count = (level * 2 >= whiteSize) ? whiteSize : level * 2;
   return whiteSpacePadding + whiteSize - count;
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::CoarrayRef &x) {
   indent("coarray ref");
   show(x.base());
@@ -29,20 +30,20 @@ void Fortran::lower::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::BOZLiteralConstant &) {
   print("BOZ literal constant");
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::NullPointer &) {
   print("null pointer");
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::semantics::Symbol &symbol) {
   const auto &ultimate{symbol.GetUltimate()};
-  print("symbol: "s + std::string(toStringRef(symbol.name())));
+  print("symbol: "s + symbol.name().ToString());
   if (const auto *assoc =
           ultimate.detailsIf<Fortran::semantics::AssocEntityDetails>()) {
     indent("assoc details");
@@ -51,23 +52,23 @@ void Fortran::lower::DumpEvaluateExpr::show(
   }
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::StaticDataObject &) {
   print("static data object");
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::ImpliedDoIndex &) {
   print("implied do index");
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::BaseObject &x) {
   indent("base object");
   show(x.u);
   outdent();
 }
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::Component &x) {
   indent("component");
   show(x.base());
@@ -75,7 +76,7 @@ void Fortran::lower::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::NamedEntity &x) {
   indent("named entity");
   if (const auto *component = x.UnwrapComponent())
@@ -85,14 +86,14 @@ void Fortran::lower::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::TypeParamInquiry &x) {
   indent("type inquiry");
   show(x.base());
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::Triplet &x) {
   indent("triplet");
   show(x.lower());
@@ -101,14 +102,14 @@ void Fortran::lower::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::Subscript &x) {
   indent("subscript");
   show(x.u);
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::ArrayRef &x) {
   indent("array ref");
   show(x.base());
@@ -116,14 +117,14 @@ void Fortran::lower::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::DataRef &x) {
   indent("data ref");
   show(x.u);
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::Substring &x) {
   indent("substring");
   show(x.parent());
@@ -132,20 +133,20 @@ void Fortran::lower::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::semantics::ParamValue &x) {
   indent("param value");
   show(x.GetExplicit());
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::semantics::DerivedTypeSpec::ParameterMapType::value_type
         &x) {
   show(x.second);
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::semantics::DerivedTypeSpec &x) {
   indent("derived type spec");
   for (auto &v : x.parameters())
@@ -153,12 +154,12 @@ void Fortran::lower::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::StructureConstructorValues::value_type &x) {
   show(x.second);
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::StructureConstructor &x) {
   indent("structure constructor");
   show(x.derivedTypeSpec());
@@ -167,21 +168,21 @@ void Fortran::lower::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::Relational<Fortran::evaluate::SomeType> &x) {
   indent("expr some type");
   show(x.u);
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::ComplexPart &x) {
   indent("complex part");
   show(x.complex());
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::ActualArgument &x) {
   indent("actual argument");
   if (const auto *symbol = x.GetAssumedTypeDummy())
@@ -191,7 +192,7 @@ void Fortran::lower::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::ProcedureDesignator &x) {
   indent("procedure designator");
   if (const auto *component = x.GetComponent())
@@ -203,28 +204,28 @@ void Fortran::lower::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::SpecificIntrinsic &) {
   print("specific intrinsic");
 }
 
-void Fortran::lower::DumpEvaluateExpr::show(
+void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::DescriptorInquiry &x) {
   indent("descriptor inquiry");
   show(x.base());
   outdent();
 }
 
-void Fortran::lower::DumpEvaluateExpr::print(llvm::Twine twine) {
+void Fortran::semantics::DumpEvaluateExpr::print(llvm::Twine twine) {
   outs << getIndentString() << twine << '\n';
 }
 
-void Fortran::lower::DumpEvaluateExpr::indent(llvm::StringRef s) {
+void Fortran::semantics::DumpEvaluateExpr::indent(llvm::StringRef s) {
   print(s + " {");
   level++;
 }
 
-void Fortran::lower::DumpEvaluateExpr::outdent() {
+void Fortran::semantics::DumpEvaluateExpr::outdent() {
   if (level)
     level--;
   print("}");
@@ -234,37 +235,37 @@ void Fortran::lower::DumpEvaluateExpr::outdent() {
 // Boilerplate entry points that the debugger can find.
 //===----------------------------------------------------------------------===//
 
-void Fortran::lower::dumpEvExpr(const Fortran::semantics::SomeExpr &x) {
+void Fortran::semantics::dumpEvExpr(const Fortran::semantics::SomeExpr &x) {
   DumpEvaluateExpr::dump(x);
 }
 
-void Fortran::lower::dumpEvExpr(
+void Fortran::semantics::dumpEvExpr(
     const Fortran::evaluate::Expr<
         Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>>
         &x) {
   DumpEvaluateExpr::dump(x);
 }
 
-void Fortran::lower::dumpEvExpr(
+void Fortran::semantics::dumpEvExpr(
     const Fortran::evaluate::Expr<
         Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 8>>
         &x) {
   DumpEvaluateExpr::dump(x);
 }
 
-void Fortran::lower::dumpEvExpr(const Fortran::evaluate::ArrayRef &x) {
+void Fortran::semantics::dumpEvExpr(const Fortran::evaluate::ArrayRef &x) {
   DumpEvaluateExpr::dump(x);
 }
 
-void Fortran::lower::dumpEvExpr(const Fortran::evaluate::DataRef &x) {
+void Fortran::semantics::dumpEvExpr(const Fortran::evaluate::DataRef &x) {
   DumpEvaluateExpr::dump(x);
 }
 
-void Fortran::lower::dumpEvExpr(const Fortran::evaluate::Substring &x) {
+void Fortran::semantics::dumpEvExpr(const Fortran::evaluate::Substring &x) {
   DumpEvaluateExpr::dump(x);
 }
 
-void Fortran::lower::dumpEvExpr(
+void Fortran::semantics::dumpEvExpr(
     const Fortran::evaluate::Designator<
         Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>>
         &x) {

>From 613af069ff0cf778d135ecb1d63b8f464068293b Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Tue, 25 Feb 2025 09:15:10 -0600
Subject: [PATCH 2/7] Remove unused header

---
 flang/lib/Lower/ConvertExprToHLFIR.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/flang/lib/Lower/ConvertExprToHLFIR.cpp b/flang/lib/Lower/ConvertExprToHLFIR.cpp
index 91daa6f0ad6ea..dc00e0b13f583 100644
--- a/flang/lib/Lower/ConvertExprToHLFIR.cpp
+++ b/flang/lib/Lower/ConvertExprToHLFIR.cpp
@@ -21,7 +21,6 @@
 #include "flang/Lower/ConvertProcedureDesignator.h"
 #include "flang/Lower/ConvertType.h"
 #include "flang/Lower/ConvertVariable.h"
-#include "flang/Lower/DumpEvaluateExpr.h"
 #include "flang/Lower/StatementContext.h"
 #include "flang/Lower/SymbolMap.h"
 #include "flang/Optimizer/Builder/Complex.h"

>From 6c0d52e4576c0ed1a95f54dac065bd68b55f06ee Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Tue, 25 Feb 2025 09:15:15 -0600
Subject: [PATCH 3/7] format

---
 flang/include/flang/Semantics/dump-expr.h | 69 +++++++++--------------
 flang/lib/Semantics/dump-expr.cpp         | 18 ++----
 2 files changed, 32 insertions(+), 55 deletions(-)

diff --git a/flang/include/flang/Semantics/dump-expr.h b/flang/include/flang/Semantics/dump-expr.h
index d51cb6539d29b..86c8f3fda28bc 100644
--- a/flang/include/flang/Semantics/dump-expr.h
+++ b/flang/include/flang/Semantics/dump-expr.h
@@ -23,8 +23,7 @@ class DumpEvaluateExpr {
   DumpEvaluateExpr() : outs(llvm::errs()) {}
   DumpEvaluateExpr(llvm::raw_ostream &str) : outs(str) {}
 
-  template <typename A>
-  static void dump(const A &x) {
+  template <typename A> static void dump(const A &x) {
     DumpEvaluateExpr{}.show(x);
   }
   template <typename A>
@@ -37,40 +36,33 @@ class DumpEvaluateExpr {
   void show(const Fortran::common::Indirection<A, C> &x) {
     show(x.value());
   }
-  template <typename A>
-  void show(const Fortran::semantics::SymbolRef x) {
+  template <typename A> void show(const Fortran::semantics::SymbolRef x) {
     show(*x);
   }
-  template <typename A>
-  void show(const std::unique_ptr<A> &x) {
+  template <typename A> void show(const std::unique_ptr<A> &x) {
     show(x.get());
   }
-  template <typename A>
-  void show(const std::shared_ptr<A> &x) {
+  template <typename A> void show(const std::shared_ptr<A> &x) {
     show(x.get());
   }
-  template <typename A>
-  void show(const A *x) {
+  template <typename A> void show(const A *x) {
     if (x) {
       show(*x);
       return;
     }
     print("nullptr");
   }
-  template <typename A>
-  void show(const std::optional<A> &x) {
+  template <typename A> void show(const std::optional<A> &x) {
     if (x) {
       show(*x);
       return;
     }
     print("None");
   }
-  template <typename... A>
-  void show(const std::variant<A...> &u) {
+  template <typename... A> void show(const std::variant<A...> &u) {
     Fortran::common::visit([&](const auto &v) { show(v); }, u);
   }
-  template <typename A>
-  void show(const std::vector<A> &x) {
+  template <typename A> void show(const std::vector<A> &x) {
     indent("vector");
     for (const auto &v : x)
       show(v);
@@ -78,8 +70,7 @@ class DumpEvaluateExpr {
   }
   void show(const Fortran::evaluate::BOZLiteralConstant &);
   void show(const Fortran::evaluate::NullPointer &);
-  template <typename T>
-  void show(const Fortran::evaluate::Constant<T> &x) {
+  template <typename T> void show(const Fortran::evaluate::Constant<T> &x) {
     if constexpr (T::category == Fortran::common::TypeCategory::Derived) {
       indent("derived constant");
       for (const auto &map : x.values())
@@ -104,14 +95,12 @@ class DumpEvaluateExpr {
   void show(const Fortran::evaluate::DataRef &x);
   void show(const Fortran::evaluate::Substring &x);
   void show(const Fortran::evaluate::ComplexPart &x);
-  template <typename T>
-  void show(const Fortran::evaluate::Designator<T> &x) {
+  template <typename T> void show(const Fortran::evaluate::Designator<T> &x) {
     indent("designator");
     show(x.u);
     outdent();
   }
-  template <typename T>
-  void show(const Fortran::evaluate::Variable<T> &x) {
+  template <typename T> void show(const Fortran::evaluate::Variable<T> &x) {
     indent("variable");
     show(x.u);
     outdent();
@@ -126,8 +115,7 @@ class DumpEvaluateExpr {
     show(x.arguments());
     outdent();
   }
-  template <typename T>
-  void show(const Fortran::evaluate::FunctionRef<T> &x) {
+  template <typename T> void show(const Fortran::evaluate::FunctionRef<T> &x) {
     indent("function ref");
     show(x.proc());
     show(x.arguments());
@@ -144,8 +132,7 @@ class DumpEvaluateExpr {
       show(v);
     outdent();
   }
-  template <typename T>
-  void show(const Fortran::evaluate::ImpliedDo<T> &x) {
+  template <typename T> void show(const Fortran::evaluate::ImpliedDo<T> &x) {
     indent("implied do");
     show(x.lower());
     show(x.upper());
@@ -154,9 +141,9 @@ class DumpEvaluateExpr {
     outdent();
   }
   void show(const Fortran::semantics::ParamValue &x);
-  void
-  show(const Fortran::semantics::DerivedTypeSpec::ParameterMapType::value_type
-           &x);
+  void show(
+      const Fortran::semantics::DerivedTypeSpec::ParameterMapType::value_type
+          &x);
   void show(const Fortran::semantics::DerivedTypeSpec &x);
   void show(const Fortran::evaluate::StructureConstructorValues::value_type &x);
   void show(const Fortran::evaluate::StructureConstructor &x);
@@ -173,10 +160,9 @@ class DumpEvaluateExpr {
     show(op.right());
     outdent();
   }
-  void
-  show(const Fortran::evaluate::Relational<Fortran::evaluate::SomeType> &x);
-  template <typename T>
-  void show(const Fortran::evaluate::Expr<T> &x) {
+  void show(
+      const Fortran::evaluate::Relational<Fortran::evaluate::SomeType> &x);
+  template <typename T> void show(const Fortran::evaluate::Expr<T> &x) {
     indent("expr T");
     show(x.u);
     outdent();
@@ -191,20 +177,17 @@ class DumpEvaluateExpr {
   unsigned level = 0;
 };
 
-LLVM_DUMP_METHOD void
-dumpEvExpr(const Fortran::evaluate::Expr<Fortran::evaluate::SomeType> &x);
-LLVM_DUMP_METHOD void dumpEvExpr(
-    const Fortran::evaluate::Expr<
-        Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x);
 LLVM_DUMP_METHOD void dumpEvExpr(
-    const Fortran::evaluate::Expr<
-        Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 8>> &x);
+    const Fortran::evaluate::Expr<Fortran::evaluate::SomeType> &x);
+LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::Expr<
+    Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x);
+LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::Expr<
+    Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 8>> &x);
 LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::ArrayRef &x);
 LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::DataRef &x);
 LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::Substring &x);
-LLVM_DUMP_METHOD void dumpEvExpr(
-    const Fortran::evaluate::Designator<
-        Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x);
+LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::Designator<
+    Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x);
 
 } // namespace Fortran::semantics
 
diff --git a/flang/lib/Semantics/dump-expr.cpp b/flang/lib/Semantics/dump-expr.cpp
index f0b0ecabf950a..78afffa28be69 100644
--- a/flang/lib/Semantics/dump-expr.cpp
+++ b/flang/lib/Semantics/dump-expr.cpp
@@ -239,17 +239,13 @@ void Fortran::semantics::dumpEvExpr(const Fortran::semantics::SomeExpr &x) {
   DumpEvaluateExpr::dump(x);
 }
 
-void Fortran::semantics::dumpEvExpr(
-    const Fortran::evaluate::Expr<
-        Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>>
-        &x) {
+void Fortran::semantics::dumpEvExpr(const Fortran::evaluate::Expr<
+    Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x) {
   DumpEvaluateExpr::dump(x);
 }
 
-void Fortran::semantics::dumpEvExpr(
-    const Fortran::evaluate::Expr<
-        Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 8>>
-        &x) {
+void Fortran::semantics::dumpEvExpr(const Fortran::evaluate::Expr<
+    Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 8>> &x) {
   DumpEvaluateExpr::dump(x);
 }
 
@@ -265,9 +261,7 @@ void Fortran::semantics::dumpEvExpr(const Fortran::evaluate::Substring &x) {
   DumpEvaluateExpr::dump(x);
 }
 
-void Fortran::semantics::dumpEvExpr(
-    const Fortran::evaluate::Designator<
-        Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>>
-        &x) {
+void Fortran::semantics::dumpEvExpr(const Fortran::evaluate::Designator<
+    Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x) {
   DumpEvaluateExpr::dump(x);
 }

>From 8402e55ff0d581d4a8ccfe7fb7fae35bc93b7a87 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Wed, 26 Feb 2025 07:36:27 -0600
Subject: [PATCH 4/7] Use brace initialization

---
 flang/include/flang/Semantics/dump-expr.h |  7 ++++++-
 flang/lib/Semantics/dump-expr.cpp         | 21 ++++++++++-----------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/flang/include/flang/Semantics/dump-expr.h b/flang/include/flang/Semantics/dump-expr.h
index 86c8f3fda28bc..9355772b7eaf5 100644
--- a/flang/include/flang/Semantics/dump-expr.h
+++ b/flang/include/flang/Semantics/dump-expr.h
@@ -13,6 +13,11 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 
+#include <memory>
+#include <optional>
+#include <variant>
+#include <vector>
+
 namespace Fortran::semantics {
 
 /// Class to dump Fortran::evaluate::Expr trees out in a user readable way.
@@ -174,7 +179,7 @@ class DumpEvaluateExpr {
   void outdent();
 
   llvm::raw_ostream &outs;
-  unsigned level = 0;
+  unsigned level{0};
 };
 
 LLVM_DUMP_METHOD void dumpEvExpr(
diff --git a/flang/lib/Semantics/dump-expr.cpp b/flang/lib/Semantics/dump-expr.cpp
index 78afffa28be69..8c637e61105ed 100644
--- a/flang/lib/Semantics/dump-expr.cpp
+++ b/flang/lib/Semantics/dump-expr.cpp
@@ -7,15 +7,14 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Semantics/dump-expr.h"
-#include <iostream>
 
-static constexpr char whiteSpacePadding[] =
-    ">>                                               ";
-static constexpr auto whiteSize = sizeof(whiteSpacePadding) - 1;
+static constexpr char whiteSpacePadding[]{
+    ">>                                               "};
+static constexpr auto whiteSize{sizeof(whiteSpacePadding) - 1};
 
 inline const char *
 Fortran::semantics::DumpEvaluateExpr::getIndentString() const {
-  auto count = (level * 2 >= whiteSize) ? whiteSize : level * 2;
+  auto count{(level * 2 >= whiteSize) ? whiteSize : level * 2};
   return whiteSpacePadding + whiteSize - count;
 }
 
@@ -44,8 +43,8 @@ void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::semantics::Symbol &symbol) {
   const auto &ultimate{symbol.GetUltimate()};
   print("symbol: "s + symbol.name().ToString());
-  if (const auto *assoc =
-          ultimate.detailsIf<Fortran::semantics::AssocEntityDetails>()) {
+  if (const auto *assoc{
+          ultimate.detailsIf<Fortran::semantics::AssocEntityDetails>()}) {
     indent("assoc details");
     show(assoc->expr());
     outdent();
@@ -79,7 +78,7 @@ void Fortran::semantics::DumpEvaluateExpr::show(
 void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::NamedEntity &x) {
   indent("named entity");
-  if (const auto *component = x.UnwrapComponent())
+  if (const auto *component{x.UnwrapComponent()})
     show(*component);
   else
     show(x.GetFirstSymbol());
@@ -185,7 +184,7 @@ void Fortran::semantics::DumpEvaluateExpr::show(
 void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::ActualArgument &x) {
   indent("actual argument");
-  if (const auto *symbol = x.GetAssumedTypeDummy())
+  if (const auto *symbol{x.GetAssumedTypeDummy()})
     show(*symbol);
   else
     show(x.UnwrapExpr());
@@ -195,9 +194,9 @@ void Fortran::semantics::DumpEvaluateExpr::show(
 void Fortran::semantics::DumpEvaluateExpr::show(
     const Fortran::evaluate::ProcedureDesignator &x) {
   indent("procedure designator");
-  if (const auto *component = x.GetComponent())
+  if (const auto *component{x.GetComponent()})
     show(*component);
-  else if (const auto *symbol = x.GetSymbol())
+  else if (const auto *symbol{x.GetSymbol()})
     show(*symbol);
   else
     show(DEREF(x.GetSpecificIntrinsic()));

>From 2529d9a3be48837fd7108e2dfaf03d3fced8e13b Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Wed, 26 Feb 2025 08:02:31 -0600
Subject: [PATCH 5/7] Put definitions in namespace to avoid extra
 qualifications

---
 flang/include/flang/Semantics/dump-expr.h | 112 +++++++++----------
 flang/lib/Semantics/dump-expr.cpp         | 126 +++++++++-------------
 2 files changed, 101 insertions(+), 137 deletions(-)

diff --git a/flang/include/flang/Semantics/dump-expr.h b/flang/include/flang/Semantics/dump-expr.h
index 9355772b7eaf5..6568f0e68e2ab 100644
--- a/flang/include/flang/Semantics/dump-expr.h
+++ b/flang/include/flang/Semantics/dump-expr.h
@@ -10,6 +10,7 @@
 #define FORTRAN_SEMANTICS_DUMPEVALUATEEXPR_H
 
 #include "flang/Evaluate/tools.h"
+#include "flang/Semantics/symbol.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 
@@ -20,7 +21,7 @@
 
 namespace Fortran::semantics {
 
-/// Class to dump Fortran::evaluate::Expr trees out in a user readable way.
+/// Class to dump evaluate::Expr trees out in a user readable way.
 ///
 /// FIXME: This can be improved to dump more information in some cases.
 class DumpEvaluateExpr {
@@ -37,13 +38,10 @@ class DumpEvaluateExpr {
   }
 
 private:
-  template <typename A, bool C>
-  void show(const Fortran::common::Indirection<A, C> &x) {
+  template <typename A, bool C> void show(const common::Indirection<A, C> &x) {
     show(x.value());
   }
-  template <typename A> void show(const Fortran::semantics::SymbolRef x) {
-    show(*x);
-  }
+  template <typename A> void show(const SymbolRef x) { show(*x); }
   template <typename A> void show(const std::unique_ptr<A> &x) {
     show(x.get());
   }
@@ -65,7 +63,7 @@ class DumpEvaluateExpr {
     print("None");
   }
   template <typename... A> void show(const std::variant<A...> &u) {
-    Fortran::common::visit([&](const auto &v) { show(v); }, u);
+    common::visit([&](const auto &v) { show(v); }, u);
   }
   template <typename A> void show(const std::vector<A> &x) {
     indent("vector");
@@ -73,10 +71,10 @@ class DumpEvaluateExpr {
       show(v);
     outdent();
   }
-  void show(const Fortran::evaluate::BOZLiteralConstant &);
-  void show(const Fortran::evaluate::NullPointer &);
-  template <typename T> void show(const Fortran::evaluate::Constant<T> &x) {
-    if constexpr (T::category == Fortran::common::TypeCategory::Derived) {
+  void show(const evaluate::BOZLiteralConstant &);
+  void show(const evaluate::NullPointer &);
+  template <typename T> void show(const evaluate::Constant<T> &x) {
+    if constexpr (T::category == common::TypeCategory::Derived) {
       indent("derived constant");
       for (const auto &map : x.values())
         for (const auto &pair : map)
@@ -86,58 +84,57 @@ class DumpEvaluateExpr {
       print("constant");
     }
   }
-  void show(const Fortran::semantics::Symbol &symbol);
-  void show(const Fortran::evaluate::StaticDataObject &);
-  void show(const Fortran::evaluate::ImpliedDoIndex &);
-  void show(const Fortran::evaluate::BaseObject &x);
-  void show(const Fortran::evaluate::Component &x);
-  void show(const Fortran::evaluate::NamedEntity &x);
-  void show(const Fortran::evaluate::TypeParamInquiry &x);
-  void show(const Fortran::evaluate::Triplet &x);
-  void show(const Fortran::evaluate::Subscript &x);
-  void show(const Fortran::evaluate::ArrayRef &x);
-  void show(const Fortran::evaluate::CoarrayRef &x);
-  void show(const Fortran::evaluate::DataRef &x);
-  void show(const Fortran::evaluate::Substring &x);
-  void show(const Fortran::evaluate::ComplexPart &x);
-  template <typename T> void show(const Fortran::evaluate::Designator<T> &x) {
+  void show(const Symbol &symbol);
+  void show(const evaluate::StaticDataObject &);
+  void show(const evaluate::ImpliedDoIndex &);
+  void show(const evaluate::BaseObject &x);
+  void show(const evaluate::Component &x);
+  void show(const evaluate::NamedEntity &x);
+  void show(const evaluate::TypeParamInquiry &x);
+  void show(const evaluate::Triplet &x);
+  void show(const evaluate::Subscript &x);
+  void show(const evaluate::ArrayRef &x);
+  void show(const evaluate::CoarrayRef &x);
+  void show(const evaluate::DataRef &x);
+  void show(const evaluate::Substring &x);
+  void show(const evaluate::ComplexPart &x);
+  template <typename T> void show(const evaluate::Designator<T> &x) {
     indent("designator");
     show(x.u);
     outdent();
   }
-  template <typename T> void show(const Fortran::evaluate::Variable<T> &x) {
+  template <typename T> void show(const evaluate::Variable<T> &x) {
     indent("variable");
     show(x.u);
     outdent();
   }
-  void show(const Fortran::evaluate::DescriptorInquiry &x);
-  void show(const Fortran::evaluate::SpecificIntrinsic &);
-  void show(const Fortran::evaluate::ProcedureDesignator &x);
-  void show(const Fortran::evaluate::ActualArgument &x);
-  void show(const Fortran::evaluate::ProcedureRef &x) {
+  void show(const evaluate::DescriptorInquiry &x);
+  void show(const evaluate::SpecificIntrinsic &);
+  void show(const evaluate::ProcedureDesignator &x);
+  void show(const evaluate::ActualArgument &x);
+  void show(const evaluate::ProcedureRef &x) {
     indent("procedure ref");
     show(x.proc());
     show(x.arguments());
     outdent();
   }
-  template <typename T> void show(const Fortran::evaluate::FunctionRef<T> &x) {
+  template <typename T> void show(const evaluate::FunctionRef<T> &x) {
     indent("function ref");
     show(x.proc());
     show(x.arguments());
     outdent();
   }
-  template <typename T>
-  void show(const Fortran::evaluate::ArrayConstructorValue<T> &x) {
+  template <typename T> void show(const evaluate::ArrayConstructorValue<T> &x) {
     show(x.u);
   }
   template <typename T>
-  void show(const Fortran::evaluate::ArrayConstructorValues<T> &x) {
+  void show(const evaluate::ArrayConstructorValues<T> &x) {
     indent("array constructor value");
     for (auto &v : x)
       show(v);
     outdent();
   }
-  template <typename T> void show(const Fortran::evaluate::ImpliedDo<T> &x) {
+  template <typename T> void show(const evaluate::ImpliedDo<T> &x) {
     indent("implied do");
     show(x.lower());
     show(x.upper());
@@ -145,29 +142,26 @@ class DumpEvaluateExpr {
     show(x.values());
     outdent();
   }
-  void show(const Fortran::semantics::ParamValue &x);
-  void show(
-      const Fortran::semantics::DerivedTypeSpec::ParameterMapType::value_type
-          &x);
-  void show(const Fortran::semantics::DerivedTypeSpec &x);
-  void show(const Fortran::evaluate::StructureConstructorValues::value_type &x);
-  void show(const Fortran::evaluate::StructureConstructor &x);
+  void show(const ParamValue &x);
+  void show(const DerivedTypeSpec::ParameterMapType::value_type &x);
+  void show(const DerivedTypeSpec &x);
+  void show(const evaluate::StructureConstructorValues::value_type &x);
+  void show(const evaluate::StructureConstructor &x);
   template <typename D, typename R, typename O>
-  void show(const Fortran::evaluate::Operation<D, R, O> &op) {
+  void show(const evaluate::Operation<D, R, O> &op) {
     indent("unary op");
     show(op.left());
     outdent();
   }
   template <typename D, typename R, typename LO, typename RO>
-  void show(const Fortran::evaluate::Operation<D, R, LO, RO> &op) {
+  void show(const evaluate::Operation<D, R, LO, RO> &op) {
     indent("binary op");
     show(op.left());
     show(op.right());
     outdent();
   }
-  void show(
-      const Fortran::evaluate::Relational<Fortran::evaluate::SomeType> &x);
-  template <typename T> void show(const Fortran::evaluate::Expr<T> &x) {
+  void show(const evaluate::Relational<evaluate::SomeType> &x);
+  template <typename T> void show(const evaluate::Expr<T> &x) {
     indent("expr T");
     show(x.u);
     outdent();
@@ -182,17 +176,17 @@ class DumpEvaluateExpr {
   unsigned level{0};
 };
 
+LLVM_DUMP_METHOD void dumpEvExpr(const evaluate::Expr<evaluate::SomeType> &x);
+LLVM_DUMP_METHOD void dumpEvExpr(
+    const evaluate::Expr<evaluate::Type<common::TypeCategory::Integer, 4>> &x);
+LLVM_DUMP_METHOD void dumpEvExpr(
+    const evaluate::Expr<evaluate::Type<common::TypeCategory::Integer, 8>> &x);
+LLVM_DUMP_METHOD void dumpEvExpr(const evaluate::ArrayRef &x);
+LLVM_DUMP_METHOD void dumpEvExpr(const evaluate::DataRef &x);
+LLVM_DUMP_METHOD void dumpEvExpr(const evaluate::Substring &x);
 LLVM_DUMP_METHOD void dumpEvExpr(
-    const Fortran::evaluate::Expr<Fortran::evaluate::SomeType> &x);
-LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::Expr<
-    Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x);
-LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::Expr<
-    Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 8>> &x);
-LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::ArrayRef &x);
-LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::DataRef &x);
-LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::Substring &x);
-LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::Designator<
-    Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x);
+    const evaluate::Designator<evaluate::Type<common::TypeCategory::Integer, 4>>
+        &x);
 
 } // namespace Fortran::semantics
 
diff --git a/flang/lib/Semantics/dump-expr.cpp b/flang/lib/Semantics/dump-expr.cpp
index 8c637e61105ed..25a7fdbe0788f 100644
--- a/flang/lib/Semantics/dump-expr.cpp
+++ b/flang/lib/Semantics/dump-expr.cpp
@@ -8,18 +8,18 @@
 
 #include "flang/Semantics/dump-expr.h"
 
+namespace Fortran::semantics {
+
 static constexpr char whiteSpacePadding[]{
     ">>                                               "};
 static constexpr auto whiteSize{sizeof(whiteSpacePadding) - 1};
 
-inline const char *
-Fortran::semantics::DumpEvaluateExpr::getIndentString() const {
+inline const char *DumpEvaluateExpr::getIndentString() const {
   auto count{(level * 2 >= whiteSize) ? whiteSize : level * 2};
   return whiteSpacePadding + whiteSize - count;
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::CoarrayRef &x) {
+void DumpEvaluateExpr::show(const evaluate::CoarrayRef &x) {
   indent("coarray ref");
   show(x.base());
   show(x.subscript());
@@ -29,54 +29,45 @@ void Fortran::semantics::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::BOZLiteralConstant &) {
+void DumpEvaluateExpr::show(const evaluate::BOZLiteralConstant &) {
   print("BOZ literal constant");
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::NullPointer &) {
+void DumpEvaluateExpr::show(const evaluate::NullPointer &) {
   print("null pointer");
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::semantics::Symbol &symbol) {
+void DumpEvaluateExpr::show(const Symbol &symbol) {
   const auto &ultimate{symbol.GetUltimate()};
   print("symbol: "s + symbol.name().ToString());
-  if (const auto *assoc{
-          ultimate.detailsIf<Fortran::semantics::AssocEntityDetails>()}) {
+  if (const auto *assoc{ultimate.detailsIf<AssocEntityDetails>()}) {
     indent("assoc details");
     show(assoc->expr());
     outdent();
   }
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::StaticDataObject &) {
+void DumpEvaluateExpr::show(const evaluate::StaticDataObject &) {
   print("static data object");
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::ImpliedDoIndex &) {
+void DumpEvaluateExpr::show(const evaluate::ImpliedDoIndex &) {
   print("implied do index");
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::BaseObject &x) {
+void DumpEvaluateExpr::show(const evaluate::BaseObject &x) {
   indent("base object");
   show(x.u);
   outdent();
 }
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::Component &x) {
+void DumpEvaluateExpr::show(const evaluate::Component &x) {
   indent("component");
   show(x.base());
   show(x.GetLastSymbol());
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::NamedEntity &x) {
+void DumpEvaluateExpr::show(const evaluate::NamedEntity &x) {
   indent("named entity");
   if (const auto *component{x.UnwrapComponent()})
     show(*component);
@@ -85,15 +76,13 @@ void Fortran::semantics::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::TypeParamInquiry &x) {
+void DumpEvaluateExpr::show(const evaluate::TypeParamInquiry &x) {
   indent("type inquiry");
   show(x.base());
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::Triplet &x) {
+void DumpEvaluateExpr::show(const evaluate::Triplet &x) {
   indent("triplet");
   show(x.lower());
   show(x.upper());
@@ -101,30 +90,26 @@ void Fortran::semantics::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::Subscript &x) {
+void DumpEvaluateExpr::show(const evaluate::Subscript &x) {
   indent("subscript");
   show(x.u);
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::ArrayRef &x) {
+void DumpEvaluateExpr::show(const evaluate::ArrayRef &x) {
   indent("array ref");
   show(x.base());
   show(x.subscript());
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::DataRef &x) {
+void DumpEvaluateExpr::show(const evaluate::DataRef &x) {
   indent("data ref");
   show(x.u);
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::Substring &x) {
+void DumpEvaluateExpr::show(const evaluate::Substring &x) {
   indent("substring");
   show(x.parent());
   show(x.lower());
@@ -132,34 +117,30 @@ void Fortran::semantics::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::semantics::ParamValue &x) {
+void DumpEvaluateExpr::show(const ParamValue &x) {
   indent("param value");
   show(x.GetExplicit());
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::semantics::DerivedTypeSpec::ParameterMapType::value_type
-        &x) {
+void DumpEvaluateExpr::show(
+    const DerivedTypeSpec::ParameterMapType::value_type &x) {
   show(x.second);
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::semantics::DerivedTypeSpec &x) {
+void DumpEvaluateExpr::show(const DerivedTypeSpec &x) {
   indent("derived type spec");
   for (auto &v : x.parameters())
     show(v);
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::StructureConstructorValues::value_type &x) {
+void DumpEvaluateExpr::show(
+    const evaluate::StructureConstructorValues::value_type &x) {
   show(x.second);
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::StructureConstructor &x) {
+void DumpEvaluateExpr::show(const evaluate::StructureConstructor &x) {
   indent("structure constructor");
   show(x.derivedTypeSpec());
   for (auto &v : x)
@@ -167,22 +148,19 @@ void Fortran::semantics::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::Relational<Fortran::evaluate::SomeType> &x) {
+void DumpEvaluateExpr::show(const evaluate::Relational<evaluate::SomeType> &x) {
   indent("expr some type");
   show(x.u);
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::ComplexPart &x) {
+void DumpEvaluateExpr::show(const evaluate::ComplexPart &x) {
   indent("complex part");
   show(x.complex());
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::ActualArgument &x) {
+void DumpEvaluateExpr::show(const evaluate::ActualArgument &x) {
   indent("actual argument");
   if (const auto *symbol{x.GetAssumedTypeDummy()})
     show(*symbol);
@@ -191,8 +169,7 @@ void Fortran::semantics::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::ProcedureDesignator &x) {
+void DumpEvaluateExpr::show(const evaluate::ProcedureDesignator &x) {
   indent("procedure designator");
   if (const auto *component{x.GetComponent()})
     show(*component);
@@ -203,28 +180,26 @@ void Fortran::semantics::DumpEvaluateExpr::show(
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::SpecificIntrinsic &) {
+void DumpEvaluateExpr::show(const evaluate::SpecificIntrinsic &) {
   print("specific intrinsic");
 }
 
-void Fortran::semantics::DumpEvaluateExpr::show(
-    const Fortran::evaluate::DescriptorInquiry &x) {
+void DumpEvaluateExpr::show(const evaluate::DescriptorInquiry &x) {
   indent("descriptor inquiry");
   show(x.base());
   outdent();
 }
 
-void Fortran::semantics::DumpEvaluateExpr::print(llvm::Twine twine) {
+void DumpEvaluateExpr::print(llvm::Twine twine) {
   outs << getIndentString() << twine << '\n';
 }
 
-void Fortran::semantics::DumpEvaluateExpr::indent(llvm::StringRef s) {
+void DumpEvaluateExpr::indent(llvm::StringRef s) {
   print(s + " {");
   level++;
 }
 
-void Fortran::semantics::DumpEvaluateExpr::outdent() {
+void DumpEvaluateExpr::outdent() {
   if (level)
     level--;
   print("}");
@@ -234,33 +209,28 @@ void Fortran::semantics::DumpEvaluateExpr::outdent() {
 // Boilerplate entry points that the debugger can find.
 //===----------------------------------------------------------------------===//
 
-void Fortran::semantics::dumpEvExpr(const Fortran::semantics::SomeExpr &x) {
-  DumpEvaluateExpr::dump(x);
-}
+void dumpEvExpr(const SomeExpr &x) { DumpEvaluateExpr::dump(x); }
 
-void Fortran::semantics::dumpEvExpr(const Fortran::evaluate::Expr<
-    Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x) {
+void dumpEvExpr(
+    const evaluate::Expr<evaluate::Type<common::TypeCategory::Integer, 4>> &x) {
   DumpEvaluateExpr::dump(x);
 }
 
-void Fortran::semantics::dumpEvExpr(const Fortran::evaluate::Expr<
-    Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 8>> &x) {
+void dumpEvExpr(
+    const evaluate::Expr<evaluate::Type<common::TypeCategory::Integer, 8>> &x) {
   DumpEvaluateExpr::dump(x);
 }
 
-void Fortran::semantics::dumpEvExpr(const Fortran::evaluate::ArrayRef &x) {
-  DumpEvaluateExpr::dump(x);
-}
+void dumpEvExpr(const evaluate::ArrayRef &x) { DumpEvaluateExpr::dump(x); }
 
-void Fortran::semantics::dumpEvExpr(const Fortran::evaluate::DataRef &x) {
-  DumpEvaluateExpr::dump(x);
-}
+void dumpEvExpr(const evaluate::DataRef &x) { DumpEvaluateExpr::dump(x); }
 
-void Fortran::semantics::dumpEvExpr(const Fortran::evaluate::Substring &x) {
-  DumpEvaluateExpr::dump(x);
-}
+void dumpEvExpr(const evaluate::Substring &x) { DumpEvaluateExpr::dump(x); }
 
-void Fortran::semantics::dumpEvExpr(const Fortran::evaluate::Designator<
-    Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x) {
+void dumpEvExpr(
+    const evaluate::Designator<evaluate::Type<common::TypeCategory::Integer, 4>>
+        &x) {
   DumpEvaluateExpr::dump(x);
 }
+
+} // namespace Fortran::semantics

>From 7913072ec360c3e492d0c26f03ce0edf3dd74ff3 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Wed, 26 Feb 2025 08:06:03 -0600
Subject: [PATCH 6/7] Fix file name in comment

---
 flang/include/flang/Semantics/dump-expr.h | 2 +-
 flang/lib/Semantics/dump-expr.cpp         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/flang/include/flang/Semantics/dump-expr.h b/flang/include/flang/Semantics/dump-expr.h
index 6568f0e68e2ab..5c936862fc064 100644
--- a/flang/include/flang/Semantics/dump-expr.h
+++ b/flang/include/flang/Semantics/dump-expr.h
@@ -1,4 +1,4 @@
-//===-- Semantics/DumpEvaluateExpr.h ----------------------------*- C++ -*-===//
+//===-- Semantics/dump-expr.h -----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/lib/Semantics/dump-expr.cpp b/flang/lib/Semantics/dump-expr.cpp
index 25a7fdbe0788f..87100fa135914 100644
--- a/flang/lib/Semantics/dump-expr.cpp
+++ b/flang/lib/Semantics/dump-expr.cpp
@@ -1,4 +1,4 @@
-//===-- Semantics/DumpEvaluateExpr.cpp ------------------------------------===//
+//===-- Semantics/dump-expr.cpp -------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

>From fe0ebf9f6ac81f3350cb6086dfa854931e3b8004 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Wed, 26 Feb 2025 08:07:39 -0600
Subject: [PATCH 7/7] Fix name of include guard

---
 flang/include/flang/Semantics/dump-expr.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/flang/include/flang/Semantics/dump-expr.h b/flang/include/flang/Semantics/dump-expr.h
index 5c936862fc064..b3a006ba681a2 100644
--- a/flang/include/flang/Semantics/dump-expr.h
+++ b/flang/include/flang/Semantics/dump-expr.h
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_SEMANTICS_DUMPEVALUATEEXPR_H
-#define FORTRAN_SEMANTICS_DUMPEVALUATEEXPR_H
+#ifndef FORTRAN_SEMANTICS_DUMPEXPR_H
+#define FORTRAN_SEMANTICS_DUMPEXPR_H
 
 #include "flang/Evaluate/tools.h"
 #include "flang/Semantics/symbol.h"
@@ -190,4 +190,4 @@ LLVM_DUMP_METHOD void dumpEvExpr(
 
 } // namespace Fortran::semantics
 
-#endif // FORTRAN_SEMANTICS_DUMPEVALUATEEXPR_H
+#endif // FORTRAN_SEMANTICS_DUMPEXPR_H



More information about the flang-commits mailing list