Summary:
Using CaseType::CT_AnyCase for selected identifier results in inheriting case style setting from more basic identifier type.
This patch changes CT_AnyCase behavior to ignore case style of specified identifier. If case style was not set, llvm::Optional will be used for keeping this information (llvm::Optional<>::hasVal), thus CT_AnyCase will no longer mean more general identifier style should be used.
This eliminates false-positives when naming convention is not clear for specific areas of code (legacy, third party) or for selected types.
Reviewers: berenm, alexfh
Reviewed By: alexfh
Subscribers: cfe-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D30931
llvm-svn: 298499
Summary:
Add an option to function-size to warn about high parameter counts.
This might be relevant for cppcoreguidelines and the safety module as well. Since the safety module is not landed in master already, i did not create an alias, but that can be done later as well.
Reviewers: sbenza, alexfh, hokein
Reviewed By: alexfh, hokein
Subscribers: JDevlieghere
Patch by Jonas Toth!
Differential Revision: https://reviews.llvm.org/D29561
llvm-svn: 296599
I have made a small fix for readability-delete-null-pointer check so it also checks for class members.
Example of case that it fixes
```
struct A {
void foo() {
if(mp)
delete mp;
}
int *mp;
};
```
Reviewers: JDevlieghere, aaron.ballman, alexfh, malcolm.parsons
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D29726
llvm-svn: 294912
This check detects and fixes redundant null checks before deletes.
Patch by: Gergely Angeli!
Differential Revision: https://reviews.llvm.org/D21298
llvm-svn: 290784
Summary:
This patch adds handling for member initializers in a constructors initializer list. Previously we only handled base-class and delegating initializers, which are transformed by the `TypeLoc` matcher. For Example:
```
// Style options: All identifiers should start with an upper case letter.
struct base { ... };
struct der : base {
int field; // FIXES: int Field;
der() : der(42) {} // FIXES: Der() : Der(42) {}
der(int X) : base(), field(X) {} // FIXES: Der(int X) : Base(), field(X)
// Note that `field` doesn't get replaced
};
```
Reviewers: alexfh, hokein, aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D26744
llvm-svn: 287153
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
Finds redundant variable and function declarations.
extern int X;
extern int X; // <- redundant
Differential Revision: https://reviews.llvm.org/D24656
llvm-svn: 285689
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: 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:
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
This patch extends clang-tidy's readability-redundant-smartptr-get to produce
warnings for previously unsupported cases:
```
std::unique_ptr<void> ptr;
if (ptr.get())
if (ptr.get() == NULL)
if (ptr.get() != NULL)
```
This is intended to fix https://llvm.org/bugs/show_bug.cgi?id=25804, a bug
report opened by @Eugene.Zelenko.
However, there still are cases not detected by the check. They can be found in
`void Negative()` function defined in
test/clang-tidy/readability-redundant-smartptr-get.cpp.
Reviewers: alexfh
Differential Revision: https://reviews.llvm.org/D24893
llvm-svn: 282386
This patch extends clang-tidy's readability-redundant-smartptr-get to produce
warnings for previously unsupported cases:
```
std::unique_ptr<void> ptr;
if (ptr.get())
if (ptr.get() == NULL)
if (ptr.get() != NULL)
```
This is intended to fix https://llvm.org/bugs/show_bug.cgi?id=25804, a bug
report opened by @Eugene.Zelenko.
However, there still are cases not detected by the check. They can be found in
`void Negative()` function defined in
test/clang-tidy/readability-redundant-smartptr-get.cpp.
llvm-svn: 282382
This check did not create FixItHints when the statement before the redundant
control flow was not followed by a semicolon.
Patch by Malcolm Parsons!
Reviewers: alexfh
Differential Revision: https://reviews.llvm.org/D24500
llvm-svn: 281713
This patch extends readability-container-size-empty check allowing it to produce
warnings not only for STL containers, but also for containers, which provide two
functions matching following signatures:
* `size_type size() const;`
* `bool empty() const;`
Where `size_type` can be any kind of integer type.
This functionality was proposed in https://llvm.org/bugs/show_bug.cgi?id=26823
by Eugene Zelenko.
Approval: alexfh
Reviewers: alexfh, aaron.ballman, Eugene.Zelenko
Subscribers: etienneb, Prazek, hokein, xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D24349
llvm-svn: 281307
The check will warn when the constness will make the function interface safer.
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D15332
llvm-svn: 279507
`readability-else-after-return` only warns about `return` calls, but LLVM Coding
Standars stat that `throw`, `continue`, `goto`, etc after `return` calls are
bad, too.
Reviwers: alexfh, aaron.ballman
Differential Revision: https://reviews.llvm.org/D23265
llvm-svn: 278257
Summary:
Previously, the added test cases crashed because the passed a null Decl
to addUsage().
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D22188
llvm-svn: 274985
We match on the generated FunctionDecl of the lambda and try to fix it.
This causes a crash.
The right behavior is to ignore lambdas, because they are a definition.
llvm-svn: 274019
Summary: This is a fix for the new ExprWithCleanups introduced by clang's temporary variable lifetime marks change.
Reviewers: bkramer, sbenza, angelgarcia, alexth
Subscribers: rsmith, cfe-commits
Differential Revision: http://reviews.llvm.org/D21243
llvm-svn: 273310
Summary:
Added support for macro definitions.
--
1. Added a pre-processor callback to catch macro definitions
2. Changed the type of the failure map so that macros and declarations can share the same map
3. Added extra tests to ensure fix-ups work using the new map
4. Added fix-ups for type aliases in variable and function declarations as part of adding the new tests
Reviewers: alexfh
Subscribers: Eugene.Zelenko, cfe-commits
Patch by James Reynolds!
Differential Revision: http://reviews.llvm.org/D21020
llvm-svn: 272993