[flang][NFC] Switch CollectBindings return to SymbolVector

As suggested on D138129, switching rteurn of CollectBindings
function to SymbolVector.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D138419
This commit is contained in:
Valentin Clement 2022-11-22 15:13:18 +01:00
parent ac84798570
commit d38735e601
No known key found for this signature in database
GPG Key ID: 086D54783C928776
3 changed files with 16 additions and 12 deletions

View File

@ -14,6 +14,7 @@
#ifndef FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
#define FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
#include "flang/Common/reference.h"
#include <set>
#include <string>
#include <vector>
@ -27,6 +28,9 @@ class Scope;
class SemanticsContext;
class Symbol;
using SymbolRef = common::Reference<const Symbol>;
using SymbolVector = std::vector<SymbolRef>;
struct RuntimeDerivedTypeTables {
Scope *schemata{nullptr};
std::set<std::string> names;
@ -38,7 +42,7 @@ RuntimeDerivedTypeTables BuildRuntimeDerivedTypeTables(SemanticsContext &);
/// to describe other derived types at runtime in flang descriptor.
constexpr char typeInfoBuiltinModule[]{"__fortran_type_info"};
std::vector<const Symbol *> CollectBindings(const Scope &dtScope);
SymbolVector CollectBindings(const Scope &dtScope);
} // namespace Fortran::semantics
#endif // FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_

View File

@ -223,21 +223,21 @@ public:
parent ? Fortran::lower::mangle::mangleName(*parent) : "");
auto insertPt = builder.saveInsertionPoint();
std::vector<const Fortran::semantics::Symbol *> bindings =
Fortran::semantics::SymbolVector bindings =
Fortran::semantics::CollectBindings(*info.typeSpec->scope());
if (!bindings.empty())
builder.createBlock(&dt.getRegion());
for (const Fortran::semantics::Symbol *binding : bindings) {
for (const Fortran::semantics::SymbolRef &binding : bindings) {
const auto *details =
binding->detailsIf<Fortran::semantics::ProcBindingDetails>();
binding.get().detailsIf<Fortran::semantics::ProcBindingDetails>();
std::string bindingName =
Fortran::lower::mangle::mangleName(details->symbol());
builder.create<fir::DTEntryOp>(
info.loc,
mlir::StringAttr::get(builder.getContext(),
binding->name().ToString()),
binding.get().name().ToString()),
mlir::SymbolRefAttr::get(builder.getContext(), bindingName));
}
if (!bindings.empty())

View File

@ -940,8 +940,8 @@ SomeExpr RuntimeTableBuilder::PackageIntValueExpr(
return StructureExpr(PackageIntValue(genre, n));
}
std::vector<const Symbol *> CollectBindings(const Scope &dtScope) {
std::vector<const Symbol *> result;
SymbolVector CollectBindings(const Scope &dtScope) {
SymbolVector result;
std::map<SourceName, const Symbol *> localBindings;
// Collect local bindings
for (auto pair : dtScope) {
@ -957,14 +957,14 @@ std::vector<const Symbol *> CollectBindings(const Scope &dtScope) {
const Symbol &symbol{**iter};
auto overridden{localBindings.find(symbol.name())};
if (overridden != localBindings.end()) {
*iter = overridden->second;
*iter = *overridden->second;
localBindings.erase(overridden);
}
}
}
// Add remaining (non-overriding) local bindings in name order to the result
for (auto pair : localBindings) {
result.push_back(pair.second);
result.push_back(*pair.second);
}
return result;
}
@ -972,13 +972,13 @@ std::vector<const Symbol *> CollectBindings(const Scope &dtScope) {
std::vector<evaluate::StructureConstructor>
RuntimeTableBuilder::DescribeBindings(const Scope &dtScope, Scope &scope) {
std::vector<evaluate::StructureConstructor> result;
for (const Symbol *symbol : CollectBindings(dtScope)) {
for (const SymbolRef &ref : CollectBindings(dtScope)) {
evaluate::StructureConstructorValues values;
AddValue(values, bindingSchema_, "proc"s,
SomeExpr{evaluate::ProcedureDesignator{
symbol->get<ProcBindingDetails>().symbol()}});
ref.get().get<ProcBindingDetails>().symbol()}});
AddValue(values, bindingSchema_, "name"s,
SaveNameAsPointerTarget(scope, symbol->name().ToString()));
SaveNameAsPointerTarget(scope, ref.get().name().ToString()));
result.emplace_back(DEREF(bindingSchema_.AsDerived()), std::move(values));
}
return result;