Skip to content

Commit 6557794

Browse files
[NFC] Get rid of -Wrange-loop-analysis warnings. (swiftlang#31324)
1 parent 7ae3d38 commit 6557794

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
@@ -5508,7 +5508,7 @@ GenericSignatureBuilder::finalize(SourceLoc loc,
55085508
for (const auto gp : getGenericParams())
55095509
depth = std::max(depth, gp->getDepth());
55105510

5511-
for (const auto pa : Impl->PotentialArchetypes) {
5511+
for (const auto &pa : Impl->PotentialArchetypes) {
55125512
auto rep = pa->getRepresentative();
55135513

55145514
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
@@ -2160,7 +2160,7 @@ InheritedProtocolsRequest::evaluate(Evaluator &evaluator,
21602160
SmallPtrSet<const ProtocolDecl *, 2> known;
21612161
known.insert(PD);
21622162
bool anyObject = false;
2163-
for (const auto found : getDirectlyInheritedNominalTypeDecls(PD, anyObject)) {
2163+
for (const auto &found : getDirectlyInheritedNominalTypeDecls(PD, anyObject)) {
21642164
if (auto proto = dyn_cast<ProtocolDecl>(found.Item)) {
21652165
if (known.insert(proto).second)
21662166
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

0 commit comments

Comments
 (0)