Skip to content

Commit 6efae05

Browse files
authored
Review usage of auto in Lower/Mangler.cpp (#1301)
1 parent 0ee6c0f commit 6efae05

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

flang/lib/Lower/Mangler.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ static void moduleNames(const Fortran::semantics::Scope &scope,
2929
}
3030
moduleNames(scope.parent(), result);
3131
if (scope.kind() == Fortran::semantics::Scope::Kind::Module)
32-
if (auto *symbol = scope.symbol())
32+
if (const Fortran::semantics::Symbol *symbol = scope.symbol())
3333
result.emplace_back(toStringRef(symbol->name()));
3434
}
3535

3636
static llvm::SmallVector<llvm::StringRef>
3737
moduleNames(const Fortran::semantics::Symbol &symbol) {
38-
const auto &scope = symbol.owner();
38+
const Fortran::semantics::Scope &scope = symbol.owner();
3939
llvm::SmallVector<llvm::StringRef> result;
4040
moduleNames(scope, result);
4141
return result;
4242
}
4343

4444
static llvm::Optional<llvm::StringRef>
4545
hostName(const Fortran::semantics::Symbol &symbol) {
46-
const auto &scope = symbol.owner();
46+
const Fortran::semantics::Scope &scope = symbol.owner();
4747
if (scope.kind() == Fortran::semantics::Scope::Kind::Subprogram) {
4848
assert(scope.symbol() && "subprogram scope must have a symbol");
4949
return toStringRef(scope.symbol()->name());
@@ -59,12 +59,12 @@ hostName(const Fortran::semantics::Symbol &symbol) {
5959

6060
static const Fortran::semantics::Symbol *
6161
findInterfaceIfSeperateMP(const Fortran::semantics::Symbol &symbol) {
62-
const auto &scope = symbol.owner();
62+
const Fortran::semantics::Scope &scope = symbol.owner();
6363
if (symbol.attrs().test(Fortran::semantics::Attr::MODULE) &&
6464
scope.IsSubmodule()) {
6565
// FIXME symbol from MpSubprogramStmt do not seem to have
6666
// Attr::MODULE set.
67-
const auto *iface = scope.parent().FindSymbol(symbol.name());
67+
const Fortran::semantics::Symbol *iface = scope.parent().FindSymbol(symbol.name());
6868
assert(iface && "Separate module procedure must be declared");
6969
return iface;
7070
}
@@ -77,8 +77,8 @@ std::string
7777
Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
7878
bool keepExternalInScope) {
7979
// Resolve host and module association before mangling
80-
const auto &ultimateSymbol = symbol.GetUltimate();
81-
auto symbolName = toStringRef(ultimateSymbol.name());
80+
const Fortran::semantics::Symbol &ultimateSymbol = symbol.GetUltimate();
81+
llvm::StringRef symbolName = toStringRef(ultimateSymbol.name());
8282

8383
return std::visit(
8484
Fortran::common::visitors{
@@ -94,10 +94,10 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
9494
// Separate module subprograms must be mangled according to the
9595
// scope where they were declared (the symbol we have is the
9696
// definition).
97-
const auto *interface = &ultimateSymbol;
97+
const Fortran::semantics::Symbol *interface = &ultimateSymbol;
9898
if (const auto *mpIface = findInterfaceIfSeperateMP(ultimateSymbol))
9999
interface = mpIface;
100-
auto modNames = moduleNames(*interface);
100+
llvm::SmallVector<llvm::StringRef> modNames = moduleNames(*interface);
101101
return fir::NameUniquer::doProcedure(modNames, hostName(*interface),
102102
symbolName);
103103
},
@@ -115,16 +115,16 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
115115
symbolName);
116116
},
117117
[&](const Fortran::semantics::ObjectEntityDetails &) {
118-
auto modNames = moduleNames(ultimateSymbol);
119-
auto optHost = hostName(ultimateSymbol);
118+
llvm::SmallVector<llvm::StringRef> modNames = moduleNames(ultimateSymbol);
119+
llvm::Optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
120120
if (Fortran::semantics::IsNamedConstant(ultimateSymbol))
121121
return fir::NameUniquer::doConstant(modNames, optHost,
122122
symbolName);
123123
return fir::NameUniquer::doVariable(modNames, optHost, symbolName);
124124
},
125125
[&](const Fortran::semantics::NamelistDetails &) {
126-
auto modNames = moduleNames(ultimateSymbol);
127-
auto optHost = hostName(ultimateSymbol);
126+
llvm::SmallVector<llvm::StringRef> modNames = moduleNames(ultimateSymbol);
127+
llvm::Optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
128128
return fir::NameUniquer::doNamelistGroup(modNames, optHost,
129129
symbolName);
130130
},
@@ -145,21 +145,21 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
145145
std::string Fortran::lower::mangle::mangleName(
146146
const Fortran::semantics::DerivedTypeSpec &derivedType) {
147147
// Resolve host and module association before mangling
148-
const auto &ultimateSymbol = derivedType.typeSymbol().GetUltimate();
149-
auto symbolName = toStringRef(ultimateSymbol.name());
150-
auto modNames = moduleNames(ultimateSymbol);
151-
auto optHost = hostName(ultimateSymbol);
148+
const Fortran::semantics::Symbol &ultimateSymbol = derivedType.typeSymbol().GetUltimate();
149+
llvm::StringRef symbolName = toStringRef(ultimateSymbol.name());
150+
llvm::SmallVector<llvm::StringRef> modNames = moduleNames(ultimateSymbol);
151+
llvm::Optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
152152
llvm::SmallVector<std::int64_t> kinds;
153153
for (const auto &param :
154154
Fortran::semantics::OrderParameterDeclarations(ultimateSymbol)) {
155155
const auto &paramDetails =
156156
param->get<Fortran::semantics::TypeParamDetails>();
157157
if (paramDetails.attr() == Fortran::common::TypeParamAttr::Kind) {
158-
const auto *paramValue = derivedType.FindParameter(param->name());
158+
const Fortran::semantics::ParamValue *paramValue = derivedType.FindParameter(param->name());
159159
assert(paramValue && "derived type kind parameter value not found");
160-
auto paramExpr = paramValue->GetExplicit();
160+
const Fortran::semantics::MaybeIntExpr paramExpr = paramValue->GetExplicit();
161161
assert(paramExpr && "derived type kind param not explicit");
162-
auto init = Fortran::evaluate::ToInt64(paramValue->GetExplicit());
162+
std::optional<int64_t> init = Fortran::evaluate::ToInt64(paramValue->GetExplicit());
163163
assert(init && "derived type kind param is not constant");
164164
kinds.emplace_back(*init);
165165
}
@@ -201,12 +201,12 @@ std::string Fortran::lower::mangle::mangleArrayLiteral(
201201
Fortran::common::TypeCategory cat, int kind,
202202
Fortran::common::ConstantSubscript charLen) {
203203
std::string typeId = "";
204-
for (auto extent : shape)
204+
for (Fortran::evaluate::ConstantSubscript extent : shape)
205205
typeId.append(std::to_string(extent)).append("x");
206206
if (charLen >= 0)
207207
typeId.append(std::to_string(charLen)).append("x");
208208
typeId.append(typeToString(cat, kind));
209-
auto name = fir::NameUniquer::doGenerated("ro."s.append(typeId).append("."));
209+
std::string name = fir::NameUniquer::doGenerated("ro."s.append(typeId).append("."));
210210
if (!size)
211211
return name += "null";
212212
llvm::MD5 hashValue{};
@@ -258,7 +258,7 @@ std::string fir::mangleIntrinsicProcedure(llvm::StringRef intrinsic,
258258
name.append(intrinsic.str()).append(".");
259259
assert(funTy.getNumResults() == 1 && "only function mangling supported");
260260
name.append(typeToString(funTy.getResult(0)));
261-
auto e = funTy.getNumInputs();
261+
unsigned e = funTy.getNumInputs();
262262
for (decltype(e) i = 0; i < e; ++i)
263263
name.append(".").append(typeToString(funTy.getInput(i)));
264264
return name;

0 commit comments

Comments
 (0)