From 0b39c0f14b22353a8d10a908361d2d0727d9b0f8 Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Wed, 22 Feb 2017 06:34:04 +0000 Subject: [PATCH] Use const-ref in range-loop for to avoid copying pairs of std::string No reason to create temporaries. Differential Revision: https://reviews.llvm.org/D29871 Patch by sergio.martins! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295807 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/Attributes.cpp | 2 +- lib/Transforms/Utils/CodeExtractor.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index 92cb6dee631..3d4245983d0 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -1380,7 +1380,7 @@ bool AttrBuilder::overlaps(const AttrBuilder &B) const { return true; // Then check if any target dependent ones do. - for (auto I : td_attrs()) + for (const auto &I : td_attrs()) if (B.contains(I.first)) return true; diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index c514c9c9cd4..176d80d608f 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -364,7 +364,7 @@ Function *CodeExtractor::constructFunction(const ValueSet &inputs, // attribute can not be inherited. AttributeSet OldFnAttrs = oldFunction->getAttributes().getFnAttributes(); AttrBuilder AB(OldFnAttrs, AttributeSet::FunctionIndex); - for (auto Attr : AB.td_attrs()) + for (const auto &Attr : AB.td_attrs()) newFunction->addFnAttr(Attr.first, Attr.second); newFunction->getBasicBlockList().push_back(newRootNode); -- 2.50.1