Index: llvm/lib/IR/Attributes.cpp =================================================================== --- llvm/lib/IR/Attributes.cpp +++ llvm/lib/IR/Attributes.cpp @@ -618,7 +618,7 @@ return *this; AttrBuilder B(AS); - for (const auto I : *this) + for (const auto &I : *this) B.addAttribute(I); return get(C, B); @@ -725,7 +725,7 @@ sizeof(AvailableAttrs) * CHAR_BIT, "Too many attributes"); - for (const auto I : *this) { + for (const auto &I : *this) { if (!I.isStringAttribute()) { Attribute::AttrKind Kind = I.getKindAsEnum(); AvailableAttrs[Kind / 8] |= 1ULL << (Kind % 8); @@ -745,7 +745,7 @@ SmallVector SortedAttrs(Attrs.begin(), Attrs.end()); llvm::sort(SortedAttrs); - for (const auto Attr : SortedAttrs) + for (const auto &Attr : SortedAttrs) Attr.Profile(ID); void *InsertPoint; @@ -813,7 +813,7 @@ } bool AttributeSetNode::hasAttribute(StringRef Kind) const { - for (const auto I : *this) + for (const auto &I : *this) if (I.hasAttribute(Kind)) return true; return false; @@ -821,7 +821,7 @@ Attribute AttributeSetNode::getAttribute(Attribute::AttrKind Kind) const { if (hasAttribute(Kind)) { - for (const auto I : *this) + for (const auto &I : *this) if (I.hasAttribute(Kind)) return I; } @@ -829,42 +829,42 @@ } Attribute AttributeSetNode::getAttribute(StringRef Kind) const { - for (const auto I : *this) + for (const auto &I : *this) if (I.hasAttribute(Kind)) return I; return {}; } MaybeAlign AttributeSetNode::getAlignment() const { - for (const auto I : *this) + for (const auto &I : *this) if (I.hasAttribute(Attribute::Alignment)) return I.getAlignment(); return None; } MaybeAlign AttributeSetNode::getStackAlignment() const { - for (const auto I : *this) + for (const auto &I : *this) if (I.hasAttribute(Attribute::StackAlignment)) return I.getStackAlignment(); return None; } Type *AttributeSetNode::getByValType() const { - for (const auto I : *this) + for (const auto &I : *this) if (I.hasAttribute(Attribute::ByVal)) return I.getValueAsType(); return 0; } uint64_t AttributeSetNode::getDereferenceableBytes() const { - for (const auto I : *this) + for (const auto &I : *this) if (I.hasAttribute(Attribute::Dereferenceable)) return I.getDereferenceableBytes(); return 0; } uint64_t AttributeSetNode::getDereferenceableOrNullBytes() const { - for (const auto I : *this) + for (const auto &I : *this) if (I.hasAttribute(Attribute::DereferenceableOrNull)) return I.getDereferenceableOrNullBytes(); return 0; @@ -872,7 +872,7 @@ std::pair> AttributeSetNode::getAllocSizeArgs() const { - for (const auto I : *this) + for (const auto &I : *this) if (I.hasAttribute(Attribute::AllocSize)) return I.getAllocSizeArgs(); return std::make_pair(0, 0); @@ -914,7 +914,7 @@ "Too many attributes"); static_assert(attrIdxToArrayIdx(AttributeList::FunctionIndex) == 0U, "function should be stored in slot 0"); - for (const auto I : Sets[0]) { + for (const auto &I : Sets[0]) { if (!I.isStringAttribute()) { Attribute::AttrKind Kind = I.getKindAsEnum(); AvailableFunctionAttrs[Kind / 8] |= 1ULL << (Kind % 8); @@ -1030,7 +1030,7 @@ MaxIndex = Attrs[Attrs.size() - 2].first; SmallVector AttrVec(attrIdxToArrayIdx(MaxIndex) + 1); - for (const auto Pair : Attrs) + for (const auto &Pair : Attrs) AttrVec[attrIdxToArrayIdx(Pair.first)] = Pair.second; return getImpl(C, AttrVec); @@ -1098,7 +1098,7 @@ AttributeList AttributeList::get(LLVMContext &C, unsigned Index, ArrayRef Kinds) { SmallVector, 8> Attrs; - for (const auto K : Kinds) + for (const auto &K : Kinds) Attrs.emplace_back(Index, Attribute::get(C, K)); return get(C, Attrs); } @@ -1111,7 +1111,7 @@ return Attrs[0]; unsigned MaxSize = 0; - for (const auto List : Attrs) + for (const auto &List : Attrs) MaxSize = std::max(MaxSize, List.getNumAttrSets()); // If every list was empty, there is no point in merging the lists. @@ -1121,7 +1121,7 @@ SmallVector NewAttrSets(MaxSize); for (unsigned I = 0; I < MaxSize; ++I) { AttrBuilder CurBuilder; - for (const auto List : Attrs) + for (const auto &List : Attrs) CurBuilder.merge(List.getAttributes(I - 1)); NewAttrSets[I] = AttributeSet::get(C, CurBuilder); } @@ -1659,7 +1659,7 @@ bool AttrBuilder::hasAttributes(AttributeList AL, uint64_t Index) const { AttributeSet AS = AL.getAttributes(Index); - for (const auto Attr : AS) { + for (const auto &Attr : AS) { if (Attr.isEnumAttribute() || Attr.isIntAttribute()) { if (contains(Attr.getKindAsEnum())) return true; Index: llvm/lib/IR/ModuleSummaryIndex.cpp =================================================================== --- llvm/lib/IR/ModuleSummaryIndex.cpp +++ llvm/lib/IR/ModuleSummaryIndex.cpp @@ -236,7 +236,7 @@ !I.isAtEnd(); ++I) { O << "SCC (" << utostr(I->size()) << " node" << (I->size() == 1 ? "" : "s") << ") {\n"; - for (const ValueInfo V : *I) { + for (const ValueInfo &V : *I) { FunctionSummary *F = nullptr; if (V.getSummaryList().size()) F = cast(V.getSummaryList().front().get());