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

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 13 08:30:00 PDT 2016


Hmm - I thought we had an actual warning for this? Am I remembering
correctly? Could we turn it on for LLVM's build?

On Sun, Jun 12, 2016 at 12:02 PM, Benjamin Kramer via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> 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)));
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160613/f8f6d4c0/attachment.html>


More information about the llvm-commits mailing list