Index accessing checks are not performed for derived classes of
of `std::array`, as only `std::array` itself and its aliases
seems to be checked.
This patch aims to extend it for derived classes such as:
```
template<class T, size_t N>
class DerivedArray : public std::array<T, N> {};
```
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D156624
Ignore false positives related to matching parameters of non
coroutine functions and increase issue detection for cases
involving type aliases with references.
Fixes: #64915
Reviewed By: ccotter
Differential Revision: https://reviews.llvm.org/D158665
cast PredefinedExpr such as `__func__` to const char* should be accpetted.
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D158244
As proposed by check fix would result in compilation error,
lets exclude delegate constructors from being checked.
Fixes: #52818
Reviewed By: ccotter
Differential Revision: https://reviews.llvm.org/D157242
Looks like somewere in clang-16 this alias were removed,
even that is mention in clang-tidy 15 release notes.
Fixes: #64342
Reviewed By: carlosgalvezp
Differential Revision: https://reviews.llvm.org/D157181
Ignore static variables declared within the scope of class/struct.
Those variables should be covered by I.3 rule.
Fixes: #47384
Reviewed By: carlosgalvezp
Differential Revision: https://reviews.llvm.org/D157180
The modules build trips over this frequently because there is no textual
include of the tablegen output, but the module includes it.
Differential revision: https://reviews.llvm.org/D157119
Add getCheckTraversalKind to the check in order
to ignore some implicit casts when matching
expresions.
Fixes: #63994
Reviewed By: carlosgalvezp
Differential Revision: https://reviews.llvm.org/D156031
Index accessing checks are not performed for aliases
of `std::array`, as only `std::array` itself seems to be checked.
This patch aims to extend it for aliases such as:
`using MyArray = std::array<int, 10>;`
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D154297
Added new checks
- `performance-noexcept-destructor`
- `performance-noexcept-swap`
Also added cppcoreguidlines aliases for the 2 new checks as well as `performance-noexcept-move-constructor`
This fixes llvm#62154
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D148697
Warns when a function accepting a forwarding reference does anything besides
forwarding (with std::forward) the parameter in the body of the function.
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D146921
From now on check will use value from cppcoreguidelines-prefer-member-initializer
and fallback to modernize-use-default-member-init.UseAssignment if not specified.
Fixes: #55616.
Reviewed By: carlosgalvezp
Differential Revision: https://reviews.llvm.org/D147929
Fix https://llvm.org/PR49498.
The check notices 2 sides of a conditional operator have types with a different constness and so tries to examine the implicit cast.
As one side is infinity, the float narrowing detection sees when its casted to a double(which it already was) it thinks the result is out of range.
I've fixed this by just disregarding expressions where the builtin type(without quals) match as no conversion would take place.
However this has opened a can of worms. Currenty `float a = std::numeric_limits<double>::infinity();` is marked as narrowing.
Whats more suspicious is `double a = std::numeric_limits<float>::infinity();` is also marked as narrowing.
It could be argued `double inf -> float inf` is narrowing, but `float inf -> double inf` definitely isnt.
Reviewed By: carlosgalvezp
Differential Revision: https://reviews.llvm.org/D98416
The rule exists primarily for when using capture default
by copy "[=]", since member variables will be captured by
reference, which is against developer expectations.
However when the capture default is by reference, then there
is no doubt: everything will be captured by reference. Add
an option to allow just that.
Note: Release Notes do not need update since this check
has been introduced in the current WIP release.
A ticket has been opened at the C++ Core Guidelines repo
to consider updating the rule such that this behavior
is the default one:
https://github.com/isocpp/CppCoreGuidelines/issues/2060
Differential Revision: https://reviews.llvm.org/D147062
Ignore unevaluated expressions in rvalue-reference-param-not-moved
check since they are not actual uses of a move().
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D146929
Warn when an rvalue reference function paramter is never moved
from within the function body.
Reviewed By: carlosgalvezp
Differential Revision: https://reviews.llvm.org/D141569
This commit implements check for CP.51 C++ Core Guidelines
Depends on D137514
Reviewed By: ChuanqiXu
Differential Revision: https://reviews.llvm.org/D145720
A somewhat common code-pattern is to default a destructor in the source file and not in the header.
For example, this is the way to use smart pointers with forward-declared classes:
```c++
struct Impl;
struct A {
~A(); // Can't be defaulted in the header.
private:
std::unique_ptr<Impl> impl;
};
```
To be able to use this check with this pattern, I modified the behavior with `AllowSoleDefaultDtor`
to not trigger on destructors if they aren't defined yet.
Since a declared destructor should still be defined somewhere in the program, this
won't miss bad classes, just diagnose on less translation units.
Reviewed By: carlosgalvezp
Differential Revision: https://reviews.llvm.org/D143851
Warn when a lambda specifies a default capture and captures
``this``. Offer FixIts to correct the code.
Reviewed By: njames93, carlosgalvezp
Differential Revision: https://reviews.llvm.org/D141133
We forgot to apply the change to headers in the previous patch,
due to missing "-header-filter" in the run-clang-tidy invocation.
Differential Revision: https://reviews.llvm.org/D142307
Implement CppCoreGuideline CP.53 to warn when a coroutine accepts
references parameters. Although the guideline mentions that it is safe
to access a reference parameter before suspension points, the guideline
recommends flagging all coroutine parameter references.
Reviewed By: carlosgalvezp
Differential Revision: https://reviews.llvm.org/D140793
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated. The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.
This is part of an effort to migrate from llvm::Optional to
std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Sometimes in the AST we can have an ArraySubscriptExpr,
where the index is an ArrayInitIndexExpr.
ArrayInitIndexExpr is not a constant, so
ProBoundsConstantArrayIndexCheck reports a warning when
it sees such expression. This expression can only be
implicitly generated, and always appears inside an
ArrayInitLoopExpr, so we shouldn't report a warning.
Differential Revision: https://reviews.llvm.org/D132654