]> granicus.if.org Git - llvm/commitdiff
Use 'auto' to avoid implicit copies.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 12 Jun 2016 19:02:34 +0000 (19:02 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 12 Jun 2016 19:02:34 +0000 (19:02 +0000)
td_type is std::pair<std::string, std::string>, but the map returns
elements of std::pair<const std::string, std::string>. In well-designed
languages like C++ that yields an implicit copy perfectly hidden by
constref's lifetime extension. Just use auto, the typedef obscured the
real type anyways.

Found with a little help from clang-tidy's
performance-implicit-cast-in-loop.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272519 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Attributes.cpp

index 0b775337be5f1935d2baec74529f9965ac466fed..8d2dc5ef671a8d3b1a69e45ecd7a1268f8ea6de3 100644 (file)
@@ -792,7 +792,7 @@ AttributeSet AttributeSet::get(LLVMContext &C, unsigned Index,
   }
 
   // Add target-dependent (string) attributes.
-  for (const AttrBuilder::td_type &TDA : B.td_attrs())
+  for (const auto &TDA : B.td_attrs())
     Attrs.push_back(
         std::make_pair(Index, Attribute::get(C, TDA.first, TDA.second)));