Skip to content

Conversation

@klausler
Copy link
Contributor

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.

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.
@klausler klausler requested a review from clementval October 15, 2024 22:10
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Oct 15, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 15, 2024

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/112444.diff

2 Files Affected:

  • (modified) flang/include/flang/Semantics/type.h (+12-1)
  • (modified) flang/lib/Semantics/type.cpp (-6)
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

@klausler klausler merged commit 7cbb365 into llvm:main Oct 15, 2024
8 of 10 checks passed
@klausler klausler deleted the fix branch October 15, 2024 22:11
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:semantics flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants