[cfe-dev] False positives in clang-tidy performance-unnecessary-copy-initialization

Stephan Bergmann via cfe-dev cfe-dev at lists.llvm.org
Thu Nov 17 05:57:37 PST 2016


On 11/17/2016 02:40 PM, Malcolm Parsons wrote:
> On 17 November 2016 at 11:00, Stephan Bergmann via cfe-dev
> <cfe-dev at lists.llvm.org> wrote:
>> The
>> above is a stripped-down version of a bug introduced in LibreOffice when
>> such a clang-tidy recommendation had been taken at face value, see
>> <https://cgit.freedesktop.org/libreoffice/core/commit/?id=36a329b6395257d7df2013d23ba4205a5ef72f4d>
>> "Fix regression in bubbleSortVersion".
>
> That's a strange way to perform a swap.
[...]
> Or it could just use std::swap(cur, next).

Both true, for sure; but not relevant here.

 > There's no warning for this:
 > rtl::Reference<VendorBase> less = next;
 > next = cur;
 > cur = less;

...because UnnecessaryCopyInitialization now sees that 
!isOnlyUsedAsConst(OldVar,...)



More information about the cfe-dev mailing list