[flang] Add missing #include for MSVC (#161437)
I moved a function to Evaluate/tools.cpp in an attempt to dodge some
MSVC compiler issue but didn't add an include directive for
Evaluate/tools.h to Evaluate/constant.cpp.
diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h
index f9d74db..d8d0956 100644
--- a/flang/include/flang/Evaluate/tools.h
+++ b/flang/include/flang/Evaluate/tools.h
@@ -1522,7 +1522,7 @@
std::optional<Expr<SomeType>> GetConvertInput(const Expr<SomeType> &x);
// How many ancestors does have a derived type have?
-std::optional<int> DerivedTypeDepth(const semantics::Scope &);
+std::optional<int> CountDerivedTypeAncestors(const semantics::Scope &);
} // namespace Fortran::evaluate
diff --git a/flang/lib/Evaluate/constant.cpp b/flang/lib/Evaluate/constant.cpp
index f57dd82..7fe0008 100644
--- a/flang/lib/Evaluate/constant.cpp
+++ b/flang/lib/Evaluate/constant.cpp
@@ -9,6 +9,7 @@
#include "flang/Evaluate/constant.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/shape.h"
+#include "flang/Evaluate/tools.h"
#include "flang/Evaluate/type.h"
#include <string>
@@ -392,8 +393,8 @@
bool ComponentCompare::operator()(SymbolRef x, SymbolRef y) const {
if (&x->owner() != &y->owner()) {
// Not components of the same derived type; put ancestors' components first.
- if (auto xDepth{DerivedTypeDepth(x->owner())}) {
- if (auto yDepth{DerivedTypeDepth(y->owner())}) {
+ if (auto xDepth{CountDerivedTypeAncestors(x->owner())}) {
+ if (auto yDepth{CountDerivedTypeAncestors(y->owner())}) {
if (*xDepth != *yDepth) {
return *xDepth < *yDepth;
}
diff --git a/flang/lib/Evaluate/tools.cpp b/flang/lib/Evaluate/tools.cpp
index 6d0da63..3cfad03 100644
--- a/flang/lib/Evaluate/tools.cpp
+++ b/flang/lib/Evaluate/tools.cpp
@@ -1950,7 +1950,7 @@
return VariableFinder{sub}(super);
}
-std::optional<int> DerivedTypeDepth(const semantics::Scope &scope) {
+std::optional<int> CountDerivedTypeAncestors(const semantics::Scope &scope) {
if (scope.IsDerivedType()) {
for (auto iter{scope.cbegin()}; iter != scope.cend(); ++iter) {
const Symbol &symbol{*iter->second};
@@ -1962,7 +1962,7 @@
parent = derived->typeSymbol().scope();
}
if (parent) {
- if (auto parentDepth{DerivedTypeDepth(*parent)}) {
+ if (auto parentDepth{CountDerivedTypeAncestors(*parent)}) {
return 1 + *parentDepth;
}
}