Age | Commit message (Collapse) | Author |
|
Removed the uses of the allOf() matcher inside node matchers that are implicit
allOf(). Replaced uses of allOf() with the explicit node matcher where it makes
matchers more readable. Replace anyOf(hasName(), hasName(), ...) with the more
efficient and readable hasAnyName().
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@347520 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@346461 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
performance-unnecessary-copy-initialization and performance-for-range-copy
New option added to these three checks to be able to silence false positives on
types that are intentionally passed by value or copied. Such types are e.g.
intrusive reference counting pointer types like llvm::IntrusiveRefCntPtr. The
new option is named WhiteListTypes and can contain a semicolon-separated list of
names of these types. Regular expressions are allowed. Default is empty.
Differential Revision: https://reviews.llvm.org/D52727
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@344340 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
FunctionParmMutationAnalyzer instead.
Reviewers: alexfh, JonasToth, george.karpenkov
Subscribers: xazax.hun, kristof.beyls, chrib, a.sidorin, Szelethus, cfe-commits
Differential Revision: https://reviews.llvm.org/D52158
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@342403 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@342012 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
This is 2/2 of moving ExprMutationAnalyzer from clangtidy to clang/Analysis.
ExprMutationAnalyzer is moved to clang/Analysis in D51948.
This diff migrates existing usages within clangtidy to point to the new
location and remove the old copy of ExprMutationAnalyzer.
Reviewers: george.karpenkov, JonasToth
Reviewed By: george.karpenkov
Subscribers: mgorny, a.sidorin, Szelethus, cfe-commits
Differential Revision: https://reviews.llvm.org/D51950
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@342006 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
I have hit this the rough way, while trying to use this in D51870.
There is no particular point in storing the pointers, and moreover
the pointers are assumed to be non-null, and that assumption is not
enforced. If they are null, it won't be able to do anything good
with them anyway.
Initially i thought about simply adding asserts() that they are
not null, but taking/storing references looks like even cleaner solution?
Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=38888 | PR38888 ]]
Reviewers: JonasToth, shuaiwang, alexfh, george.karpenkov
Reviewed By: shuaiwang
Subscribers: xazax.hun, a.sidorin, Szelethus, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D51884
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@341854 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
performance-for-range-copy check.
Summary:
The upstream change r336737 make the check too smart to fix the case
where loop variable could be used as `const auto&`.
But for the case below, changing to `const auto _` will introduce
an unused complier warning.
```
for (auto _ : state) {
// no references for _.
}
```
This patch omit this case, and it is safe to do it as the case is very rare.
Reviewers: ilya-biryukov, alexfh
Subscribers: xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D50447
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@339415 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Subscribers: nemanjai, ioeric, kbarton, cfe-commits
Differential Revision: https://reviews.llvm.org/D50355
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@339401 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Reviewers: javed.absar
Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits
Differential Revision: https://reviews.llvm.org/D50354
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@339400 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
This yields better recall as ExprMutationAnalyzer is more accurate.
One common pattern this check is now able to catch is:
```
void foo(std::vector<X> v) {
for (const auto& elm : v) {
// ...
}
}
```
Reviewers: george.karpenkov
Subscribers: a.sidorin, cfe-commits
Differential Revision: https://reviews.llvm.org/D50102
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@338903 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
This gives better coverage to the check as ExprMutationAnalyzer is more
accurate comparing to isOnlyUsedAsConst.
Majority of wins come from const usage of member field, e.g.:
for (auto widget : container) { // copy of loop variable
if (widget.type == BUTTON) { // const usage only recognized by ExprMutationAnalyzer
// ...
}
}
Reviewers: george.karpenkov
Subscribers: a.sidorin, cfe-commits
Differential Revision: https://reviews.llvm.org/D48854
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@336737 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
Add support for arrays (and structure that use naked pointers for their iterator, like std::array) in performance-implicit-conversion-in-loop
Reviewers: alexfh
Reviewed By: alexfh
Subscribers: cfe-commits
Patch by Alex Pilkiewicz.
Differential Revision: https://reviews.llvm.org/D47945
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@334400 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@331429 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@324097 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
rename_check.py misc-move-const-arg performance-move-const-arg
rename_check.py misc-noexcept-move-constructor performance-noexcept-move-constructor
Reviewers: hokein, xazax.hun
Reviewed By: xazax.hun
Subscribers: rnkovacs, klimek, mgorny, xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D40507
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@319183 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
rename_check.py misc-move-constructor-init performance-move-constructor-init
rename_check.py misc-inefficient-algorithm performance-inefficient-algorithm
Reviewers: hokein, aaron.ballman
Reviewed By: hokein, aaron.ballman
Subscribers: aaron.ballman, mgorny, xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D40487
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@319023 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
This patch renames checks, check options and changes messages to use correct
term "implicit conversion" instead of "implicit cast" (which has been in use in
Clang AST since ~10 years, but it's still technically incorrect w.r.t. C++
standard).
* performance-implicit-cast-in-loop -> performance-implicit-conversion-in-loop
* readability-implicit-bool-cast -> readability-implicit-bool-conversion
- readability-implicit-bool-cast.AllowConditionalIntegerCasts ->
readability-implicit-bool-conversion.AllowIntegerConditions
- readability-implicit-bool-cast.AllowConditionalPointerCasts ->
readability-implicit-bool-conversion.AllowPointerConditions
Reviewers: hokein, jdennett
Reviewed By: hokein
Subscribers: mgorny, JDevlieghere, xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D36456
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@310366 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Differential Revision: https://reviews.llvm.org/D36154
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@309810 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
Do not issue fixit in UnnecessaryValueParamCheck if the function is an explicit template specialization as this could cause build breakages.
Reviewers: alexfh
Subscribers: JDevlieghere, xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D35718
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@309067 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@308605 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@304154 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Moved slower matchers closer to the end. The total speed up on a large file I
was interested in is not huge, just about 10%, since the check seems to be doing
a lot in the check() method.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@303191 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Reviewers: alexfh, aaron.ballman
Reviewed By: alexfh
Subscribers: cfe-commits, Prazek, malcolm.parsons, xazax.hun
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D33209
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@303157 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@303095 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
inefficient-vector-operation check.
Summary:
Also add an option "VectorLikeClasses" allowing user specify customized
vectors.
Reviewers: alexfh, aaron.ballman
Reviewed By: alexfh
Subscribers: Eugene.Zelenko, cfe-commits
Differential Revision: https://reviews.llvm.org/D32436
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@301440 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
NFC
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@301188 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@300588 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
The "performance-inefficient-vector-operation" check finds vector oprations in
for-loop statements which may cause multiple memory reallocations.
This is the first version, only detects typical for-loop:
```
std::vector<int> v;
for (int i = 0; i < n; ++i) {
v.push_back(i);
}
// or
for (int i = 0; i < v2.size(); ++i) {
v.push_back(v2[i]);
}
```
We can extend it to handle more cases like for-range loop in the future.
Reviewers: alexfh, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: zaks.anna, Eugene.Zelenko, mgorny, cfe-commits, djasper
Differential Revision: https://reviews.llvm.org/D31757
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@300534 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
The performance-unnecessary-value-param check mangled inherited
constructors, as the constructors' parameters do not have useful source
locations. Fix this by ignoring implicit functions.
Fixes PR31684.
Reviewers: flx, alexfh, aaron.ballman
Subscribers: madsravn, JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D29018
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@292786 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
modernize-pass-by-value doesn't warn about value parameters that
cannot be moved, so performance-unnecessary-value-param should.
Reviewers: aaron.ballman, flx, alexfh
Subscribers: JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D28022
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@290883 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
An addition to the move-constructor-init check was duplicating the
modernize-pass-by-value check.
Remove the additional check and UseCERTSemantics option.
Run the move-constructor-init test with both checks enabled.
Fix modernize-pass-by-value false-positive when initializing a base
class.
Add option to modernize-pass-by-value to only warn about parameters
that are already values.
Reviewers: alexfh, flx, aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D26453
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@290051 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary: This fixes a bug where the performance-unnecessary-value-param check suggests a fix to move the parameter inside of a loop which could be invoked multiple times.
Reviewers: sbenza, aaron.ballman, alexfh
Subscribers: JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D27187
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@289912 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
type-promotion-in-math-fn-check.
Reviewers: alexfh
Subscribers: JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D27748
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@289637 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
This checks for calls to double-precision math.h with single-precision
arguments. For example, it suggests replacing ::sin(0.f) with
::sinf(0.f).
Subscribers: mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D27284
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@289627 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
as final
Summary: Virtual method overrides of dependent types cannot be recognized unless
they are marked as override or final.
Exclude methods marked as final from check and add test.
Reviewers: sbenza, hokein, alexfh
Subscribers: malcolm.parsons, JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D27248
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@288502 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
callExpr
Summary: Suppress fixes for functions that are referenced within the
compilation unit outside of a call expression as the signature change
could break the code referencing the function.
We still issue a warning in this case so that users can decide to
manually change the function signature.
Reviewers: alexfh, sbenza, aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D26203
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@286424 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
Ran clang-format on all .c/.cpp/.h files in clang-tools-extra.
Excluded the test, unittests, clang-reorder-fields, include-fixer, modularize and pptrace directories.
Reviewers: klimek, alexfh
Subscribers: nemanjai
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D26329
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@286221 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
peformance-unnecessary-copy-initialization.
Summary:
This will prevent the check warning the variables which have been
implicitly added by compiler, like the following case (in for-range loop):
the variable '__end' is copy-constructed from a const reference...
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25911
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@286186 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
current parameter is not already const qualified
Reviewers: alexfh, sbenza, aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D26207
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@286010 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Patch by Bittner Barni!
Differential revision: https://reviews.llvm.org/D20196
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@277677 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@277340 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
As changing virtual methods could break method overrides disable applying the fix and just warn.
Reviewers: alexfh, sbenza
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D21936
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@274552 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
value parameter can be moved.
Summary:
Make check more useful in the following two cases:
The parameter is passed by non-const value, has a non-deleted move constructor and is only referenced once in the function as argument to the type's copy constructor.
The parameter is passed by non-const value, has a non-deleted move assignment operator and is only referenced once in the function as argument of the the type's copy assignment operator.
In this case suggest a fix to move the parameter which avoids the unnecessary copy and is closest to what the user might have intended.
Reviewers: alexfh, sbenza
Subscribers: cfe-commits, Prazek
Differential Revision: http://reviews.llvm.org/D20277
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@274380 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
"this" object argument if it is not modified.
Summary:
Also trigger the check in the following case:
void foo() {
ExpensiveToCopy Obj;
const auto UnnecessaryCopy = Obj.constReference();
Obj.onlyUsedAsConst();
}
i.e. when the object the method is called on is not const but is never
modified.
Reviewers: alexfh, fowles
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D20010
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@271239 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
This patch is lifting matchers used by more than one checkers
to the common namespace.
Reviewers: aaron.ballman, alexfh
Subscribers: aaron.ballman, cfe-commits
Differential Revision: http://reviews.llvm.org/D19841
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@269804 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
decl stmts with single VarDecl.
Summary: This fixes bug: https://llvm.org/bugs/show_bug.cgi?id=27325
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D19865
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@269389 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
Lift some common code used by multiple checkers.
This function is also used by checkers that are coming.
It is quite common for a checker to parse a list of names.
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D19846
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@269065 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
This is a step forward cleaning up the namespaces in clang-tidy/utils.
There is no behavior change.
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D19819
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@268356 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
The goal of the patch is to bring checkers in their appropriate namespace.
This path doesn't change any behavior.
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D19811
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@268264 91177308-0d34-0410-b5e6-96231b3b80d8
|