While rebuilding the list of checks in add_new_check.py,
check is a file is a subdirectory before traversing it.
Test plan: Ran `./add_new_check.py --update-docs` and confirmed the list.rst file was unchanged.
Reviewed By: carlosgalvezp
Differential Revision: https://reviews.llvm.org/D140772
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
Using decls in header files are special, usually as part of the
public API, the check should not emit warnings on these.
The check already detects unused using-decls which are in the current main
file, but if the main file happens to be a header file, we still
emit warnings, this patch suppresses that.
Differential Revision: https://reviews.llvm.org/D140894
Previously we were matching constructor calls for std::string and
llvm::StringRef and this change extends this set with including
std::string_view as well.
Reviewed By: njames93, carlosgalvezp
Differential Revision: https://reviews.llvm.org/D140018
- Do not analyze header files, since we don't want to promote
using anonymous namespaces there.
- Do not warn about const/constexpr variables, those are implicitly
static in C++ and they don't need to be moved to an anonymous
namespace. Warning about redundant static in general could be
implemented as a standalone check, moving away some of the
functionality from this check.
This check has been introduced in the current release, thus
no mention of this change is needed in the Release Notes.
Differential Revision: https://reviews.llvm.org/D139113
Adds a clang-tidy check for the incorrect use of `empty()` on a
container when the result of the call is ignored.
Authored-by: Abraham Corea Diaz <abrahamcd@google.com>
Co-authored-by: Denis Nikitin <denik@google.com>
Reviewed By: cjdb
Differential Revision: https://reviews.llvm.org/D128372
The same functionality is already implemented in the
readability-static-definition-in-anonymous-namespace
check, including automatic fixes.
Differential Revision: https://reviews.llvm.org/D139197
The google-objc-avoid-throwing-exception check enforces the Google
Objective-C Style Guide's prohibition on throwing exceptions in user
code but the check incorrectly triggers findings for code emitted from
system headers. This commit suppresses any findings that do not have
valid locations or are emitted from macros in system headers.
Avoid Throwing Exceptions, Google Objective-C Style Guide:
https://github.com/google/styleguide/blob/gh-pages/objcguide.md#avoid-throwing-exceptions
Test Notes:
Ran clang-tidy lit tests.
Reviewed By: gribozavr2
Differential Revision: https://reviews.llvm.org/D137738
In confusable-identifiers.rst the description refers to wrong Unicode code point.
The shown code point is U+1D41F, not U+1234.
Updated the code point and it's description.
Fixes#58934
Differential Revision: https://reviews.llvm.org/D138838
Overrides are constrained by the signature of the overridden method, so a
warning on an override is frequently unactionable.
Differential Revision: https://reviews.llvm.org/D137968
Skip template ctors in modernize-use-equals-default,
such constructors may be enabled/disabled via SFINAE,
it is not safe to make them "= default".
Test plan: ninja check-all
Differential revision: https://reviews.llvm.org/D136797
Update links to googletest documentation
No automatic tests, but local manual test: i click it, it opens the googletest documentation.
Reviewed By: sylvestre.ledru
Differential Revision: https://reviews.llvm.org/D136424
For c++17 (i.e. before c++20) making a private default ctor explicitly defaulted
might expose the previously intentionally disallowed initializations, e.g.
class Tag { Tag() {} friend class Widget; }; is not equivalent to
class Tag { Tag() = default; friend class Widget; };
since in the latter case Tag is treated as an aggregate despite having a declaration
of the default constructor. This diff makes modernize-use-equals-default skip
in-class empty nonpublic default ctors to avoid code breakages.
Test plan: ninja check-all
Differential revision: https://reviews.llvm.org/D136224
The `readability-braces-around-statements` check tries to look at the
closing parens of the if condition to determine where to insert braces,
however, "consteval if" statements don't have a condition, and always
have braces regardless, so the skip can be checked.
The `readability-simplify-boolean-expr` check looks at the condition
of the if statement to determine what could be simplified, but as
"consteval if" statements do not have a condition that could be
simplified, they can also be skipped here.
There may still be more checks that try to look at the conditions of
`if`s that aren't included here
Fixes https://github.com/llvm/llvm-project/issues/57568
Reviewed By: njames93, aaron.ballman
Differential Revision: https://reviews.llvm.org/D133413
Add a check to detect usages of `realloc` where the result is assigned
to the same variable (or field) as passed to the first argument.
Reviewed By: steakhal, martong
Differential Revision: https://reviews.llvm.org/D133119
readability-avoid-const-params-in-decls.IgnoreMacros is enabled by default to be consistent with most other checks.
Reviewed By: ymandel
Differential Revision: https://reviews.llvm.org/D130130
Skip unions/union-like classes since in this case constructors
with empty bodies behave differently in comparison with regular
structs/classes.
Test plan: ninja check-clang-tools
Differential revision: https://reviews.llvm.org/D132713
Skip copy assignment operators with nonstandard return types
since they cannot be defaulted.
Test plan: ninja check-clang-tools
Differential revision: https://reviews.llvm.org/D133006
Improve the documentation for 'misc-const-correctness' to:
- include better examples
- improve the english
- fix links to other checks that were broken due to the directory-layout changes
- mention the limitation that the check does not run on `C` code.
Addresses #56749, #56958
Reviewed By: njames93
Differential Revision: https://reviews.llvm.org/D132244
Fixed a false positive where a lambda expression in the condition which contained an assignement would trigger a warning.
Fixes#56729
Reviewed By: gribozavr2
Differential Revision: https://reviews.llvm.org/D132786
For unions constructors with empty bodies behave differently
(in comparison with structs/classes) and clang-tidy's fix
might break the code. This diff adjusts the check to skip unions
for now (it seems to be a relatively rare case).
Test plan: ninja check-all
Differential revision: https://reviews.llvm.org/D132290
This patch improves the modernize-use-emplace check by adding support for
detecting inefficient invocations of the `push` and `push_front` methods on
STL-style containers and replacing them with their `emplace`-style equivalent.
Fixes#56996.
Reviewed By: njames93
Differential Revision: https://reviews.llvm.org/D131623
Check `bugprone-signal-handler` is improved to check for
C++-specific constructs in signal handlers. This check is
valid until C++17.
Reviewed By: whisperity
Differential Revision: https://reviews.llvm.org/D118996
Flags uses of const-qualified and reference data members in structs.
Implements rule C.12 of C++ Core Guidelines.
Differential Revision: https://reviews.llvm.org/D126880
Check `bugprone-signal-handler` is improved to check for
C++-specific constructs in signal handlers. This check is
valid until C++17.
Reviewed By: whisperity
Differential Revision: https://reviews.llvm.org/D118996
Without the "found declaration" it is later not possible to know where the operator declaration
was brought into the scope calling it.
The initial motivation for this fix came from #55095. However, this also has an influence on
`clang -ast-dump` which now prints a `UsingShadow` attribute for operators only visible through
`using` statements. Also, clangd now correctly references the `using` statement instead of the
operator directly.
Reviewed By: shafik
Differential Revision: https://reviews.llvm.org/D129973