hanchenye-llvm-project/clang-tools-extra/clang-tidy
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
..
android [clang-tidy] Kill marco. No functionality change. 2018-02-02 13:39:07 +00:00
boost
bugprone Update header guard. 2018-01-31 13:31:51 +00:00
cert [clang-tidy] Fix link error in clang-tidy after the recent check renames. 2017-11-27 15:17:13 +00:00
cppcoreguidelines Removed Unicode BOM. 2018-01-25 15:09:33 +00:00
fuchsia [clang-tidy] Adding Fuchsia checker for multiple inheritance 2018-01-19 23:59:59 +00:00
google [clang-tidy] Function-scoped static variables should not trigger google-objc-global-variable-declaration 2018-01-05 23:26:06 +00:00
hicpp [clang-tidy] implement check for goto 2018-01-17 10:27:41 +00:00
llvm [clang-tidy] Unify the way IncludeStyle and HeaderFileExtesions options are used 2017-07-20 12:02:03 +00:00
misc [clang-tidy] Widen anonymous namespace. 2018-02-02 13:39:00 +00:00
modernize [clang-tidy] Kill marco. No functionality change. 2018-02-02 13:39:07 +00:00
mpi
objc add prefix with '_' support for property name. Corresponding apple dev doc: https://developer.apple.com/library/content/qa/qa1908/_index.html 2018-01-30 01:44:00 +00:00
performance [clang-tidy] ObjC ARC objects should not trigger performance-unnecessary-value-param 2018-02-02 15:34:33 +00:00
plugin [clang-tidy ObjC] [1/3] New module `objc` for Objective-C checks 2017-10-26 08:23:20 +00:00
readability clang-tidy/rename_check.py misc-string-compare readability-string-compare 2018-01-30 14:55:50 +00:00
tool [clang-tidy] Add -vfsoverlay flag 2018-01-23 12:31:06 +00:00
utils [clang-tidy] ObjC ARC objects should not trigger performance-unnecessary-value-param 2018-02-02 15:34:33 +00:00
CMakeLists.txt Add a new clang-tidy module for Fuchsia as an umbrella to diagnose issues with the Fuschia and Zircon coding guidelines (https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md). Adds the first of such checkers, which detects when default arguments are declared in a function declaration or when default arguments are used at call sites. 2017-11-28 21:09:25 +00:00
ClangTidy.cpp [clang-tidy] Add -vfsoverlay flag 2018-01-23 12:31:06 +00:00
ClangTidy.h [clang-tidy] Add -vfsoverlay flag 2018-01-23 12:31:06 +00:00
ClangTidyDiagnosticConsumer.cpp Add support for NOLINT and NOLINTNEXTLINE comments mentioning specific check names. 2017-12-14 16:13:57 +00:00
ClangTidyDiagnosticConsumer.h
ClangTidyModule.cpp
ClangTidyModule.h
ClangTidyModuleRegistry.h
ClangTidyOptions.cpp Fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR 2017-06-30 20:57:16 +00:00
ClangTidyOptions.h
add_new_check.py [clang-tidy] New argument --language to add_new_check.py 2018-01-31 21:52:39 +00:00
rename_check.py [clang-tidy] Use a more specific regex 2018-01-30 14:55:39 +00:00