[llvm] r272519 - Use 'auto' to avoid implicit copies.

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 12 12:02:35 PDT 2016


Author: d0k
Date: Sun Jun 12 14:02:34 2016
New Revision: 272519

URL: http://llvm.org/viewvc/llvm-project?rev=272519&view=rev
Log:
Use 'auto' to avoid implicit copies.

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.

Modified:
    llvm/trunk/lib/IR/Attributes.cpp

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=272519&r1=272518&r2=272519&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Sun Jun 12 14:02:34 2016
@@ -792,7 +792,7 @@ AttributeSet AttributeSet::get(LLVMConte
   }
 
   // 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)));
 




More information about the llvm-commits mailing list