[flang-commits] [flang] [flang] Fix broken shared library build (PR #112444)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Tue Oct 15 15:10:13 PDT 2024
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/112444
I just introduced a dependency from the Evaluate library to the Semantics library, which is circular in a shared library build. Rearrange the code a little to ensure that the dependence is only on a header.
>From 9c1c991115538024e06a179098db041b7e6d7fe4 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Tue, 15 Oct 2024 15:08:09 -0700
Subject: [PATCH] [flang] Fix broken shared library build
I just introduced a dependency from the Evaluate library to the
Semantics library, which is circular in a shared library build.
Rearrange the code a little to ensure that the dependence is
only on a header.
---
flang/include/flang/Semantics/type.h | 13 ++++++++++++-
flang/lib/Semantics/type.cpp | 6 ------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/flang/include/flang/Semantics/type.h b/flang/include/flang/Semantics/type.h
index 1292c381b65f72..35221915020595 100644
--- a/flang/include/flang/Semantics/type.h
+++ b/flang/include/flang/Semantics/type.h
@@ -29,6 +29,13 @@ namespace Fortran::parser {
struct Keyword;
}
+namespace Fortran::evaluate { // avoid including all of Evaluate/tools.h
+template <typename T>
+std::optional<bool> AreEquivalentInInterface(const Expr<T> &, const Expr<T> &);
+extern template std::optional<bool> AreEquivalentInInterface<SomeInteger>(
+ const Expr<SomeInteger> &, const Expr<SomeInteger> &);
+} // namespace Fortran::evaluate
+
namespace Fortran::semantics {
class Scope;
@@ -110,7 +117,11 @@ class ParamValue {
return category_ == that.category_ && expr_ == that.expr_;
}
bool operator!=(const ParamValue &that) const { return !(*this == that); }
- bool IsEquivalentInInterface(const ParamValue &) const;
+ bool IsEquivalentInInterface(const ParamValue &that) const {
+ return (category_ == that.category_ &&
+ expr_.has_value() == that.expr_.has_value() &&
+ (!expr_ || evaluate::AreEquivalentInInterface(*expr_, *that.expr_)));
+ }
std::string AsFortran() const;
private:
diff --git a/flang/lib/Semantics/type.cpp b/flang/lib/Semantics/type.cpp
index 7f5f4e98a7d6c1..e867d7ad6e2536 100644
--- a/flang/lib/Semantics/type.cpp
+++ b/flang/lib/Semantics/type.cpp
@@ -758,12 +758,6 @@ void ParamValue::SetExplicit(SomeIntExpr &&x) {
expr_ = std::move(x);
}
-bool ParamValue::IsEquivalentInInterface(const ParamValue &that) const {
- return (category_ == that.category_ &&
- expr_.has_value() == that.expr_.has_value() &&
- (!expr_ || evaluate::AreEquivalentInInterface(*expr_, *that.expr_)));
-}
-
std::string ParamValue::AsFortran() const {
switch (category_) {
SWITCH_COVERS_ALL_CASES
More information about the flang-commits
mailing list