Skip to content

Commit 830df25

Browse files
[NFC] Get rid of -Wrange-loop-analysis warnings. (#31339)
1 parent 082a293 commit 830df25

19 files changed

+23
-23
lines changed

lib/AST/ASTScopeCreation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ class ScopeCreator final {
712712
}
713713
}
714714
}
715-
for (const auto dcAndScope : bogusDCs) {
715+
for (const auto &dcAndScope : bogusDCs) {
716716
llvm::errs() << "ASTScope tree confabulated: " << dcAndScope.getFirst()
717717
<< ":\n";
718718
dcAndScope.getFirst()->printContext(llvm::errs());

lib/AST/ASTScopeLookup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ bool isLocWithinAnInactiveClause(const SourceLoc loc, SourceFile *SF) {
817817
for (const auto &clause : ifc->getClauses()) {
818818
if (clause.isActive)
819819
continue;
820-
for (const auto n : clause.Elements) {
820+
for (const auto &n : clause.Elements) {
821821
SourceRange sr = n.getSourceRange();
822822
if (sr.isValid() && SM.rangeContainsTokenLoc(sr, loc)) {
823823
wasFoundWithinInactiveClause = true;

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1828,7 +1828,7 @@ static bool isDefaultInitializable(const TypeRepr *typeRepr, ASTContext &ctx) {
18281828
if (tuple->hasEllipsis())
18291829
return false;
18301830

1831-
for (const auto elt : tuple->getElements()) {
1831+
for (const auto &elt : tuple->getElements()) {
18321832
if (!isDefaultInitializable(elt.Type, ctx))
18331833
return false;
18341834
}

lib/AST/FrontendSourceFileDepGraphFactory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ void FrontendSourceFileDepGraphFactory::addAllDefinedDecls() {
539539
template <NodeKind kind, typename ContentsT>
540540
void FrontendSourceFileDepGraphFactory::addAllDefinedDeclsOfAGivenType(
541541
std::vector<ContentsT> &contentsVec) {
542-
for (const auto declOrPair : contentsVec) {
542+
for (const auto &declOrPair : contentsVec) {
543543
Optional<std::string> fp = getFingerprintIfAny(declOrPair);
544544
addADefinedDecl(
545545
DependencyKey::createForProvidedEntityInterface<kind>(declOrPair),

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5488,7 +5488,7 @@ GenericSignatureBuilder::finalize(SourceLoc loc,
54885488
for (const auto gp : getGenericParams())
54895489
depth = std::max(depth, gp->getDepth());
54905490

5491-
for (const auto pa : Impl->PotentialArchetypes) {
5491+
for (const auto &pa : Impl->PotentialArchetypes) {
54925492
auto rep = pa->getRepresentative();
54935493

54945494
if (pa->getRootGenericParamKey().Depth < depth)

lib/AST/IncrementalRanges.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ std::vector<CharSourceRange> SwiftRangesEmitter::coalesceSortedRanges(
261261
std::vector<SerializableSourceRange>
262262
SwiftRangesEmitter::serializeRanges(std::vector<CharSourceRange> ranges) const {
263263
std::vector<SerializableSourceRange> result;
264-
for (const auto r : ranges)
264+
for (const auto &r : ranges)
265265
result.push_back(SerializableSourceRange(r, sourceMgr));
266266
return result;
267267
}

lib/AST/NameLookup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,7 @@ InheritedProtocolsRequest::evaluate(Evaluator &evaluator,
22472247
SmallPtrSet<const ProtocolDecl *, 2> known;
22482248
known.insert(PD);
22492249
bool anyObject = false;
2250-
for (const auto found : getDirectlyInheritedNominalTypeDecls(PD, anyObject)) {
2250+
for (const auto &found : getDirectlyInheritedNominalTypeDecls(PD, anyObject)) {
22512251
if (auto proto = dyn_cast<ProtocolDecl>(found.Item)) {
22522252
if (known.insert(proto).second)
22532253
result.push_back(proto);

lib/Basic/OutputFileMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static void writeQuotedEscaped(llvm::raw_ostream &os,
116116

117117
void OutputFileMap::write(llvm::raw_ostream &os,
118118
ArrayRef<StringRef> inputs) const {
119-
for (const auto input : inputs) {
119+
for (const auto &input : inputs) {
120120
writeQuotedEscaped(os, input);
121121
os << ":";
122122

lib/Driver/Job.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ CommandOutput::dump() const {
327327

328328
void CommandOutput::writeOutputFileMap(llvm::raw_ostream &out) const {
329329
SmallVector<StringRef, 4> inputs;
330-
for (const CommandInputPair IP : Inputs) {
330+
for (const CommandInputPair &IP : Inputs) {
331331
assert(IP.Base == IP.Primary && !IP.Base.empty() &&
332332
"output file maps won't work if these differ");
333333
inputs.push_back(IP.Primary);

lib/IDE/CommentConversion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ struct CommentToXMLConverter {
247247

248248
void printTagFields(ArrayRef<StringRef> Tags) {
249249
OS << "<Tags>";
250-
for (const auto Tag : Tags) {
250+
for (const auto &Tag : Tags) {
251251
if (Tag.empty()) {
252252
continue;
253253
}
@@ -821,7 +821,7 @@ void ide::getDocumentationCommentAsDoxygen(const DocComment *DC,
821821
Converter.visit(N);
822822
}
823823

824-
for (const auto PF : DC->getParamFields()) {
824+
for (const auto &PF : DC->getParamFields()) {
825825
Converter.visit(PF);
826826
}
827827

lib/SILOptimizer/Mandatory/MandatoryInlining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ getCalleeFunction(SILFunction *F, FullApplySite AI, bool &IsThick,
596596
FullArgs.clear();
597597

598598
// First grab our basic arguments from our apply.
599-
for (const auto Arg : AI.getArguments())
599+
for (const auto &Arg : AI.getArguments())
600600
FullArgs.push_back(Arg);
601601

602602
// Then grab a first approximation of our apply by stripping off all copy

lib/SILOptimizer/UtilityPasses/SerializeSILPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static bool hasOpaqueArchetypeOperand(TypeExpansionContext context,
131131
static bool hasOpaqueArchetypeResult(TypeExpansionContext context,
132132
SILInstruction &inst) {
133133
// Check the results for opaque types.
134-
for (const auto res : inst.getResults())
134+
for (const auto &res : inst.getResults())
135135
if (opaqueArchetypeWouldChange(context, res->getType().getASTType()))
136136
return true;
137137
return false;

lib/Sema/ImportResolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ struct UnboundImport {
134134
NullablePtr<ModuleDecl> getTopLevelModule(ModuleDecl *M, SourceFile &SF);
135135

136136
/// Diagnose any errors concerning the \c @_exported, \c @_implementationOnly,
137-
/// \c @testable, or \c @_private attributes, including a
137+
/// \c \@testable, or \c @_private attributes, including a
138138
/// non-implementation-only import of a fragile library from a resilient one.
139139
void validateOptions(NullablePtr<ModuleDecl> topLevelModule, SourceFile &SF);
140140

lib/Sema/LookupVisibleDecls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ class OverrideFilteringConsumer : public VisibleDeclConsumer {
857857
removeShadowedDecls(Decls, DC);
858858

859859
size_t index = 0;
860-
for (const auto DeclAndReason : Results) {
860+
for (const auto &DeclAndReason : Results) {
861861
if (index >= Decls.size())
862862
break;
863863
if (DeclAndReason.D != Decls[index])

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ ProtocolRequiresClassRequest::evaluate(Evaluator &evaluator,
488488

489489
// Look through all of the inherited nominals for a superclass or a
490490
// class-bound protocol.
491-
for (const auto found : allInheritedNominals) {
491+
for (const auto &found : allInheritedNominals) {
492492
// Superclass bound.
493493
if (isa<ClassDecl>(found.Item))
494494
return true;

lib/Sema/TypeCheckType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ resolveTopLevelIdentTypeComponent(TypeResolution resolution,
13211321
TypeDecl *currentDecl = nullptr;
13221322
DeclContext *currentDC = nullptr;
13231323
bool isAmbiguous = false;
1324-
for (const auto entry : globals) {
1324+
for (const auto &entry : globals) {
13251325
auto *foundDC = entry.getDeclContext();
13261326
auto *typeDecl = cast<TypeDecl>(entry.getValueDecl());
13271327

lib/Serialization/SerializeSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,7 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) {
21452145
S.addTypeRef(KPI->getType().getASTType()),
21462146
(unsigned)KPI->getType().getCategory(),
21472147
ListOfValues);
2148-
for (const auto conf : serializeAfter) {
2148+
for (const auto &conf : serializeAfter) {
21492149
S.writeConformance(conf, SILAbbrCodes);
21502150
}
21512151
S.writeGenericRequirements(reqts, SILAbbrCodes);
@@ -2400,7 +2400,7 @@ void SILSerializer::writeSILProperty(const SILProperty &prop) {
24002400
prop.isSerialized(),
24012401
componentValues);
24022402

2403-
for (const auto conf : serializeAfter) {
2403+
for (const auto &conf : serializeAfter) {
24042404
S.writeConformance(conf, SILAbbrCodes);
24052405
}
24062406
}

lib/SymbolGraphGen/SymbolGraph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,13 +490,13 @@ void SymbolGraph::serialize(llvm::json::OStream &OS) {
490490
}
491491

492492
OS.attributeArray("symbols", [&](){
493-
for (const auto S: Nodes) {
493+
for (const auto &S: Nodes) {
494494
S.serialize(OS);
495495
}
496496
});
497497

498498
OS.attributeArray("relationships", [&](){
499-
for (const auto Relationship : Edges) {
499+
for (const auto &Relationship : Edges) {
500500
Relationship.serialize(OS);
501501
}
502502
});

lib/SymbolGraphGen/SymbolGraphASTWalker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ bool SymbolGraphASTWalker::walkToDeclPre(Decl *D, CharSourceRange Range) {
136136
}
137137
};
138138

139-
for (const auto InheritedLoc : Extension->getInherited()) {
139+
for (const auto &InheritedLoc : Extension->getInherited()) {
140140
auto InheritedTy = InheritedLoc.getType();
141141
if (!InheritedTy) {
142142
continue;
@@ -146,7 +146,7 @@ bool SymbolGraphASTWalker::walkToDeclPre(Decl *D, CharSourceRange Range) {
146146

147147
while (!UnexpandedCompositions.empty()) {
148148
const auto *Comp = UnexpandedCompositions.pop_back_val();
149-
for (const auto Member : Comp->getMembers()) {
149+
for (const auto &Member : Comp->getMembers()) {
150150
HandleProtocolOrComposition(Member);
151151
}
152152
}

0 commit comments

Comments
 (0)