[PATCH] D52315: [clang-tidy] Fix for performance-unnecessary-value-param, performance-unnecessary-copy-initialization and performance-for-range-copy

Balogh, Ádám via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 20 10:09:23 PDT 2018


baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: alexfh, aaron.ballman, flx.

The three checks mentioned in the Title are two noisy if the code uses intrusive smart (reference counting) pointers. LLVM/Clang is such a code, it has lots of such types, e.g. StringRef, SymbolRef or ProgramStateRef, all of them based llvm::IntrusiveRefCntPtr. Every time such a type is passed as parameter, used for initialization or in a range-based for loop a false positive warning is issued together with an (unnecessary) fix.

This patch changes the term "expensive to copy" to also regard the size of the type so it disables warnings and fixes if the type is not greater than a pointer. This removes false positives for intrusive smart pointers. False positives for non-intrusive smart pointers are not addressed in this patch.


https://reviews.llvm.org/D52315

Files:
  clang-tidy/utils/TypeTraits.cpp
  docs/clang-tidy/checks/performance-for-range-copy.rst
  docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst
  docs/clang-tidy/checks/performance-unnecessary-value-param.rst
  test/clang-tidy/Inputs/performance-unnecessary-value-param/header-fixed.h
  test/clang-tidy/Inputs/performance-unnecessary-value-param/header.h
  test/clang-tidy/performance-for-range-copy-warn-on-all-auto-copies.cpp
  test/clang-tidy/performance-for-range-copy.cpp
  test/clang-tidy/performance-unnecessary-copy-initialization.cpp
  test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
  test/clang-tidy/performance-unnecessary-value-param.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52315.166316.patch
Type: text/x-patch
Size: 11807 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180920/1ab48d67/attachment-0001.bin>


More information about the cfe-commits mailing list