[PATCH] D52360: [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
Fri Sep 21 07:18:00 PDT 2018


baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: alexfh, aaron.ballman, flx.
baloghadamsoftware added a project: clang-tools-extra.
baloghadamsoftware added a comment.

This is an alternative approach to https://reviews.llvm.org/D52315.


The three checks mentioned in the Title are two noisy if the code uses custom (e.g. smart) pointers or references. 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 excludes pointer types (e.g. smart pointers) by their name: if the name of the type ends on `Pointer`, `pointer`, `Ptr`, `ptr`, `Reference`, `reference`, `Ref` or `ref` the type is considered a pointer/reference type.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52360

Files:
  clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryValueParamCheck.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/performance-for-range-copy.cpp
  test/clang-tidy/performance-unnecessary-copy-initialization.cpp
  test/clang-tidy/performance-unnecessary-value-param.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52360.166478.patch
Type: text/x-patch
Size: 10415 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180921/9d4f4098/attachment.bin>


More information about the cfe-commits mailing list