llvm-project/clang-tools-extra/clang-tidy/performance
Ben Hamilton b4ab4b6317 [clang-tidy] ObjC ARC objects should not trigger performance-unnecessary-value-param
Summary:
The following Objective-C code currently incorrectly triggers
clang-tidy's performance-unnecessary-value-param check:

```
% cat /tmp/performance-unnecessary-value-param-arc.m
void foo(id object) { }

clang-tidy /tmp/performance-unnecessary-value-param-arc.m
-checks=-\*,performance-unnecessary-value-param -- -xobjective-c
-fobjc-abi-version=2 -fobjc-arc
1 warning generated.
/src/llvm/tools/clang/tools/extra/test/clang-tidy/performance-unnecessary-value-param-arc.m:10:13:
warning: the parameter 'object' is copied for each invocation but only
used as a const reference; consider making it a const reference
[performance-unnecessary-value-param]
void foo(id object) { }
         ~~ ^
         const &
```

This is wrong for a few reasons:

1) Objective-C doesn't have references, so `const &` is not going to help
2) ARC heavily optimizes the "expensive" copy which triggers the warning

This fixes the issue by disabling the warning for non-C++, as well as
disabling it for objects under ARC memory management for
Objective-C++.

Fixes https://bugs.llvm.org/show_bug.cgi?id=32075

Test Plan: New tests added. Ran tests with `make -j12 check-clang-tools`.

Reviewers: alexfh, hokein

Reviewed By: hokein

Subscribers: stephanemoore, klimek, xazax.hun, cfe-commits, Wizard

Differential Revision: https://reviews.llvm.org/D42812

llvm-svn: 324097
2018-02-02 15:34:33 +00:00
..
CMakeLists.txt [clang-tidy] Move more checks from misc- to performance- 2017-11-28 16:41:03 +00:00
FasterStringFindCheck.cpp Adapt clang-tidy checks to changing semantics of hasDeclaration. 2017-08-02 13:13:11 +00:00
FasterStringFindCheck.h [clang-tidy] Add check performance-faster-string-find 2016-02-12 19:28:14 +00:00
ForRangeCopyCheck.cpp [clang-tidy] Cleanup namespace in utils folder. 2016-05-03 02:54:05 +00:00
ForRangeCopyCheck.h [clang-tidy] ForRangeCopyCheck that warns on and fixes unnecessary copies of loop variables. 2016-01-29 15:54:26 +00:00
ImplicitConversionInLoopCheck.cpp [clang-tidy] 'implicit cast' -> 'implicit conversion' 2017-08-08 14:53:52 +00:00
ImplicitConversionInLoopCheck.h [clang-tidy] 'implicit cast' -> 'implicit conversion' 2017-08-08 14:53:52 +00:00
InefficientAlgorithmCheck.cpp [clang-tidy] Move checks from misc- to performance- 2017-11-27 13:06:28 +00:00
InefficientAlgorithmCheck.h [clang-tidy] Move checks from misc- to performance- 2017-11-27 13:06:28 +00:00
InefficientStringConcatenationCheck.cpp Adapt clang-tidy checks to changing semantics of hasDeclaration. 2017-08-02 13:13:11 +00:00
InefficientStringConcatenationCheck.h [clang-tidy] Inefficient string operation 2016-08-03 23:06:03 +00:00
InefficientVectorOperationCheck.cpp [clang-tidy] Add "emplace_back" detection in inefficient-vector-operation. 2017-05-16 10:39:55 +00:00
InefficientVectorOperationCheck.h [clang-tidy] Support detecting for-range loop in inefficient-vector-operation check. 2017-04-26 18:13:05 +00:00
MoveConstArgCheck.cpp [clang-tidy] Move more checks from misc- to performance- 2017-11-28 16:41:03 +00:00
MoveConstArgCheck.h [clang-tidy] Move more checks from misc- to performance- 2017-11-28 16:41:03 +00:00
MoveConstructorInitCheck.cpp [clang-tidy] Move checks from misc- to performance- 2017-11-27 13:06:28 +00:00
MoveConstructorInitCheck.h [clang-tidy] Move checks from misc- to performance- 2017-11-27 13:06:28 +00:00
NoexceptMoveConstructorCheck.cpp [clang-tidy] Move more checks from misc- to performance- 2017-11-28 16:41:03 +00:00
NoexceptMoveConstructorCheck.h [clang-tidy] Move more checks from misc- to performance- 2017-11-28 16:41:03 +00:00
PerformanceTidyModule.cpp [clang-tidy] Move more checks from misc- to performance- 2017-11-28 16:41:03 +00:00
TypePromotionInMathFnCheck.cpp [clang-tidy] Unify the way IncludeStyle and HeaderFileExtesions options are used 2017-07-20 12:02:03 +00:00
TypePromotionInMathFnCheck.h [clang-tidy] Suggest including <cmath> if necessary in type-promotion-in-math-fn-check. 2016-12-14 06:52:23 +00:00
UnnecessaryCopyInitialization.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
UnnecessaryCopyInitialization.h [clang-tidy] UnnecessaryCopyInitialization - Extend to trigger on non-const "this" object argument if it is not modified. 2016-05-31 00:25:57 +00:00
UnnecessaryValueParamCheck.cpp [clang-tidy] ObjC ARC objects should not trigger performance-unnecessary-value-param 2018-02-02 15:34:33 +00:00
UnnecessaryValueParamCheck.h [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved. 2016-07-01 20:12:15 +00:00