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
llvm-svn: 286424
-Start using argparse instead of mimicking CLI parsing.
-PEPify the code.
-Decrease the number of imports by slightly cleaning up the script.
Reviewers: alexfh
Differential Revision: https://reviews.llvm.org/D25074
llvm-svn: 286228
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
llvm-svn: 286186
Summary: IsExpensiveToCopy can return false positives for incomplete types, so ignore them.
All existing ClangTidy tests that depend on this function still pass as the types are complete.
Reviewers: alexfh, aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D26195
llvm-svn: 286008
Summary:
Fix generated by this check changed program semantics
in the case where 'if' was a part (direct child) of other statement.
Fixes PR30652.
Patch by Paweł Żukowski.
Reviewers: malcolm.parsons, alexfh, djasper
Subscribers: mgehre, omtcyfz, cfe-commits
Differential Revision: https://reviews.llvm.org/D26125
llvm-svn: 285999
Summary: This change ensures that forward declarations of classes are not considered for identifier naming checks within a translation unit.
Reviewers: alexfh, aaron.ballman
Subscribers: mgehre
Differential Revision: https://reviews.llvm.org/D22571
llvm-svn: 285907
Summary:
std::string::data() and std::string::c_str() are equivalent.
Enhance the readability-redundant-string-cstr check to also handle
calls to data().
Reviewers: etienneb, alexfh, aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D26279
llvm-svn: 285901
Summary:
As a unique_ptr or shared_ptr that has been moved from is guaranteed to be null,
we only warn if the pointer is dereferenced.
Reviewers: hokein, alexfh, aaron.ballman
Subscribers: Prazek, cfe-commits
Differential Revision: https://reviews.llvm.org/D26041
llvm-svn: 285842
Finds redundant variable and function declarations.
extern int X;
extern int X; // <- redundant
Differential Revision: https://reviews.llvm.org/D24656
llvm-svn: 285689
Summary:
Aaron modified cert-err58-cpp to include all exceptions thrown before main()
Update the check to match.
Reviewers: aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25925
llvm-svn: 285653
Summary:
Extend modernize-use-auto to cases when a variable is assigned with a cast.
e.g.
Type *Ptr1 = dynamic_cast<Type*>(Ptr2);
http://llvm.org/PR25499
Reviewers: angelgarcia, aaron.ballman, klimek, Prazek, alexfh
Subscribers: Prazek, Eugene.Zelenko, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D25316
llvm-svn: 285579
Summary:
clang-tidy should fix identifier naming even when the identifier is
referenced inside a macro expansion, provided that the identifier enters
the macro expansion completely within a macro argument.
For example, this will allow fixes to the naming of the identifier
'global' when it is declared and used as follows:
int global;
#define USE_IN_MACRO(m) auto use_##m = m
USE_IN_MACRO(global);
Reviewers: alexfh
Subscribers: jlebar, cfe-commits
Differential Revision: https://reviews.llvm.org/D25450
llvm-svn: 284992
Summary:
This doesn't work after converting SmallSetVector to use DenseSet.
Instead we can just use a SmallVector.
Reviewers: timshen
Subscribers: nemanjai, cfe-commits
Differential Revision: https://reviews.llvm.org/D25647
llvm-svn: 284873
Summary: The check emits a warning if a member-initializer calls the member's default constructor with no arguments.
Reviewers: sbenza, alexfh, aaron.ballman
Subscribers: modocache, mgorny, Eugene.Zelenko, etienneb, Prazek, hokein, cfe-commits, beanz
Differential Revision: https://reviews.llvm.org/D24339
llvm-svn: 284742
Summary:
clang-tidy now cleans up after replacements, so leave colon and comma
removal to that.
Reviewers: angelgarcia, alexfh, aaron.ballman, djasper, ioeric
Subscribers: djasper, cfe-commits
Differential Revision: https://reviews.llvm.org/D25769
llvm-svn: 284735
Summary:
The matcher for matching "class with default constructor" still match
some classes without default constructor, which trigger an assert at
Line 307. This patch makes the matcher more strict.
Reviewers: aaron.ballman
Subscribers: nemanjai, cfe-commits
Differential Revision: https://reviews.llvm.org/D25747
llvm-svn: 284727
Hello, i would like to suggest a fix for one of the checks in clang-tidy and i should hope this one is the correct mailing list.
The check is modernize-avoid-bind.
Consider the following:
void bar(int x, int y);
namespace N {
void bar(int x, int y);
}
void foo(){
auto Test = std::bind(N::bar,1,1);
}
clang-tidy’s modernize-avoid-bind check suggests writing:
void foo(){
auto Test =[] {return bar(1,1);};
}
instead of:
void foo(){
auto Test = [] {return N::bar(1,1);};
}
So clang-tidy has proposed an incorrect Fix.
Patch by IdrissRio!
Reviewers: alexfh, hokein, aaron.ballman
Subscriber: cfe-commits
llvm-svn: 284719
Summary: This adds cert-err09-cpp alias for completeness, similar to cert-err61-cpp.
Reviewers: alexfh, hokein
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25770
llvm-svn: 284596
Summary:
Remove empty namespaces and initializer list commas / colons in
affected ranges. Initial patch: proper options for enabling the cleanup and
specifying the format style are needed.
Reviewers: hokein, ioeric
Subscribers: beanz, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D24572
llvm-svn: 284399
Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring)
Patch by Julian Bangert!
Reviewers: alexfh, hokein
Subscribers: beanz, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D24997
llvm-svn: 284368
Summary:
This adds a diagnostic to the misc-use-after-move check that is output when the
use happens on a later loop iteration than the move, for example:
A a;
for (int i = 0; i < 10; ++i) {
a.foo();
std::move(a);
}
This situation can be confusing to users because, in terms of source code
location, the use is above the move. This can make it look as if the warning
is a false positive, particularly if the loop is long but the use and move are
close together.
In cases like these, misc-use-after-move will now output an additional
diagnostic:
a.cpp:393:7: note: the use happens in a later loop iteration than the move
Reviewers: hokein
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25612
llvm-svn: 284235
Summary:
This fixes a false-positive e.g. when string literals are returned from if statement.
This patch includes as well a small fix to includes and renames of the test suite that collided with the name of the check.
Reviewers: alexfh, hokein
Subscribers: hokein
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D25558
llvm-svn: 284212
Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring)
Patch by Julian Bangert!
Reviewers: alexfh, hokein
Subscribers: cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D24997
llvm-svn: 283981
Summary:
* Fix a false postive when an using class is used in an explicit template instantiation.
* Fix a false postive when an using template class is used as template argument.
Reviewers: aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25437
llvm-svn: 283879
Summary:
Only member initializers that are written should prevent
using '= default' on a default constructor.
Reviewers: klimek, sbenza, aaron.ballman, alexfh
Subscribers: Eugene.Zelenko, alexfh, klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D24444
llvm-svn: 283869
Classes with virtual methods or virtual bases are not trivially default constructible, so their members and bases need to be initialized.
Patch by Malcolm Parsons.
llvm-svn: 283224
Summary:
This fixes https://llvm.org/bugs/show_bug.cgi?id=30487 where
```
warning: uninitialized record type: 's' [cppcoreguidelines-pro-type-member-init]
```
is emitted on
```
struct MyStruct
{
int a = 5;
int b = 7;
};
int main()
{
MyStruct s;
}
```
Reviewers: alexfh, aaron.ballman
Subscribers: nemanjai, cfe-commits
Differential Revision: https://reviews.llvm.org/D24848
llvm-svn: 282625