Skip to content

Commit

Permalink
[flang] Fix broken shared library build (#112444)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
klausler authored Oct 15, 2024
1 parent 4c89473 commit 7cbb365
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 12 additions & 1 deletion flang/include/flang/Semantics/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 0 additions & 6 deletions flang/lib/Semantics/type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7cbb365

Please sign in to comment.