1194 Commits

Author SHA1 Message Date
Utkarsh Saxena
c94444390f
[clangtidy] Allow safe suspensions in coroutine-hostile-raii check (#72954)
Certain `awaitable` types could be safe to `co_await` on even when we
have suspension-hostile RAII objects in scope.
This PR adds a way for users to mark such safe `awaitable` and silence
false positive warnings in `co_await` expressions involving such an
`awaitable`.

`co_await`-ing an expression of `awaitable` type is considered safe if
the type is part of `SafeAwaiatablesList` check option. RAII objects
persisting across such a `co_await` expression are
considered safe and hence are not flagged.
2023-11-27 16:21:07 +01:00
Björn Svensson
12bdbe2792
[clang-tidy][NFC][DOC] Add missing HICPP rule id's (#72553)
Add HICPP rule identities to the documentation for
`hicpp-avoid-c-arrays` and `hicpp-no-assembler`.

Includes an update of `hicpp-avoid-goto` to look like other aliased
checks.

References:
* avoid-c-arrays 
  Commit: 2634bd599567842385e11d1fd70f5486c166f935
2023-11-17 22:37:42 +01:00
Nicolas van Kempen
2aec86683c [clang-tidy][abseil-string-find-startswith] Add string_view to default string-like classes (#72283)
As per title. A small improvement to this check, `string_view` should
work out of the box.
2023-11-14 22:25:23 +00:00
nvartolomei
6fdb1bfbc7
[clang-tidy] readability-identifier-naming: add support for concepts (#71586)
Added support for C++20 ``concept`` declarations.
2023-11-09 18:18:40 +01:00
Piotr Zegar
3716b5b4ba
[clang-tidy] Improve performance-enum-size to exclude empty enums (#71640)
Enums without enumerators (empty) are now excluded from analysis as it's
not possible to peroperly determinate new narrowed type, and such enums
can be used in diffrent way, like as strong-types.

Closes #71544
2023-11-08 11:22:31 +01:00
michaelrj-google
c92cf315c6
[clang-tidy][libc] Ignore implicit function inline (#71095)
This patch adjusts the inline function decl check for LLVM libc to
ignore implicit functions. For the moment the plan is to ignore these
and mark the class with a macro so that it can be given the appropriate
properties without explicitly defining all its ctors/dtors.
2023-11-03 14:57:03 -07:00
Piotr Zegar
543f9e7810
[clang-tidy] Improve bugprone-unused-return-value check (#66573)
Improve diagnostic message to be more straight forward, fix handling of 
casting to non-void and add new option AllowCastToVoid to control
casting
to void behavior.

Closes #66570
2023-10-26 22:58:20 +02:00
Piotr Zegar
c02b2ab8ab
[clang-tidy] Add StrictMode to cppcoreguidelines-pro-type-static-cast-downcast (#69529)
Add StrictMode option that controls behavior whatever
warnings are emitted for casts on non-polymorphic types.

Fixes: #69414
2023-10-26 21:06:19 +02:00
Piotr Zegar
af07d7ba88
[clang-tidy] Improved cppcoreguidelines-pro-type-const-cast (#69501)
Improved cppcoreguidelines-pro-type-const-cast check to ignore casts to
const type (controlled by option) and casts in implicitly invoked code.

Fixes #69319
2023-10-26 07:11:01 +02:00
Piotr Zegar
9322216021 [clang-tidy][DOC] Fix 'table cell spanning'
Change current tables to avoid cell spanning.
2023-10-21 10:30:06 +00:00
Congcong Cai
9a5c6f1760
[clang-tidy]Add new check bugprone-casting-through-void (#69465)
This check detects usage of ``static_cast`` pointer to the other pointer
throght `static_cast` to `void *` in C++ code.
Fixes: #68532
2023-10-20 09:29:06 -05:00
Piotr Zegar
fea55db233 [clang-tidy][DOC] Fix syntax in coroutine-hostile-raii.rst
Fix 'Bullet list ends without a blank line; unexpected unindent.
2023-10-18 17:34:40 +00:00
Piotr Zegar
1891d21312 [clang-tidy][DOC] Fix syntax in coroutine-hostile-raii.rst
Fix ':4:Title underline too short.'
2023-10-18 16:30:18 +00:00
Piotr Zegar
598712315b [clang-tidy][DOC] Fix list.rst
Fix micro bug in list.rst.
2023-10-18 16:26:08 +00:00
Utkarsh Saxena
31512811b8
[clang-tidy] Add check to diagnose coroutine-hostile RAII objects (#68738)
This check detects **hostile-RAII** objects which should not **persist
across a suspension point in a coroutine**.

Some objects require that they be destroyed on the same thread that
created them. Traditionally this requirement was often phrased as "must
be a local variable", under the assumption that local variables always
work this way. However this is incorrect with **C++20 coroutines**,
since an intervening `co_await` may cause the coroutine to suspend and
later be resumed on another thread.

The lifetime of an object that requires being destroyed on the same
thread must not encompass a `co_await` or `co_yield` point. If you
create/destroy an object, you must do so without allowing the coroutine
to suspend in the meantime.

The check considers the following type as hostile:

- **Scoped-lockable types**: A scoped-lockable object persisting across
a suspension point is problematic as the lock held by this object could
be unlocked by a different thread. This would be undefined behaviour.

 - Types belonging to a configurable **denylist**.

```cpp
  // Call some async API while holding a lock.
const my::MutexLock l(&mu_);

// Oops! The async Bar function may finish on a different
// thread from the one that created the MutexLock object and therefore called
// Mutex::Lock -- now Mutex::Unlock will be called on the wrong thread.
co_await Bar();
```
2023-10-17 20:46:01 +02:00
Piotr Zegar
c5b617c5e5 [clang-tidy][NFC] Clarify documentation for misc-definitions-in-headers
Add information about what fixes are provided by
the check, and how to enable them.

Issue: #55093
2023-10-16 20:50:38 +00:00
AMS21
bb6a98c8d2
[clang-tidy] Ignore unused parameters in rvalue-reference-param-not-moved check (#69045)
With this patch we no longer issue a warning for unused parameters which
are marked as such.

This fixes #68209
2023-10-14 22:51:50 +02:00
Piotr Zegar
135f57d179 [clang-tidy][Doc][NFC] Regenerate list.rst & clang-analyzer doc
Update documentation.
2023-10-10 18:37:35 +00:00
Felix
7a73da4c85 [clang-tidy] Add support for optional parameters in config.
If a parameter value is either 'none', 'null', 'false', '-1'
or '', we will in that case use the default value.

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D159436
2023-10-09 19:58:44 +00:00
michaelrj-google
daca97216c
[clang-tidy][libc] Fix namespace check with macro (#68134)
The name of the namespace for LLVM's libc is now provided by a macro.
The ImplementationNamespaceCheck was updated to handle this, but the
CalleeNamespaceCheck was missed. This patch updates the
CalleeNamespaceCheck to handle the macro.
2023-10-06 14:06:22 -07:00
Guillaume Chatelet
774116b8f6
[clang-tidy] Update llvmlibc-implementation-in-namespace to new rules (#66504)
This is the implementation of step 3 of

https://discourse.llvm.org/t/rfc-customizable-namespace-to-allow-testing-the-libc-when-the-system-libc-is-also-llvms-libc/73079.
2023-09-21 17:05:47 +02:00
Piotr Zegar
5eaa5312e7 [clang-tidy][NFC] Update documentation for bugprone-undefined-memory-manipulation
Add example and more information to check documentation.
2023-09-20 21:01:34 +00:00
Aaron Ballman
e8b1af9a55 Fix clang-tidy sphinx docs
This addresses issues found by:
https://lab.llvm.org/buildbot/#/builders/115/builds/53446
2023-09-15 10:11:10 -04:00
Congcong Cai
72d4d4e3b9
[clang-tidy]add new check bugprone-compare-pointer-to-member-virtual-function (#66055) 2023-09-15 20:59:12 +08:00
Piotr Zegar
01c11569fc [clang-tidy] Add IgnoreTypes option to modernize-use-nullptr
New option added and configured in a way, so types
related to std::strong_ordering would be ignored.

Fixes: #63478

Reviewed By: ccotter

Differential Revision: https://reviews.llvm.org/D158928
2023-09-10 12:22:53 +00:00
Piotr Zegar
93f9f63b2d [clang-tidy][NFC] Update documentation for fuchsia-statically-constructed-objects
Fix compile errors in example provided in
documentation.

Fixes: #65118
2023-09-06 18:06:59 +00:00
Carlos Galvez
fdb6e8b792
[clang-tidy][NFC][doc] Improve documentation for modernize-use-equals… (#65231)
…-delete

So the purpose of the check is more clear. Update examples code to show
compliant code.

Fixes #65221

---------

Co-authored-by: Carlos Gálvez <carlos.galvez@zenseact.com>
2023-09-04 11:45:04 +02:00
Piotr Zegar
efebb4e0fa [clang-tidy] readability-container-size-empty handle std::string length()
Extends readability-container-size-empty to check std::string length() similar to size().

Fixes: #37603

Co-authored-by: Dmitry Venikov <quolyk@gmail.com>

Reviewed By: carlosgalvezp

Differential Revision: https://reviews.llvm.org/D56644
2023-08-31 19:56:07 +00:00
Piotr Zegar
c6fa07ca96 [clang-tidy][NFC][DOC] Update links to HICPP standard
Old links pointed out to old domain, and then redirected to correct
one, but to wrong pages. Changed links from old to new domain and page.

Fixes: #65064
2023-08-30 18:02:34 +00:00
MasterCopy8GB
f0e2a5e260 [clang-tidy][readability] add Leading_upper_snake_case
Add Leading_upper_snake_case to IdentifierNamingCheck naming convention.

Fixes: #42451

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D158787
2023-08-28 19:53:09 +00:00
Kazu Hirata
3a14993fa4 Fix typos in documentation 2023-08-27 00:18:14 -07:00
Chris Cotter
a7bdaff7ca [clang-tidy] Implement bugprone-incorrect-enable-if
Detects incorrect usages of std::enable_if that don't name the
nested 'type' type.

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D157239
2023-08-21 17:38:30 +00:00
Piotr Zegar
8407e8a80d
[clang-tidy][NFC][DOC] Use internal references instead of external
Use internal references instead of external links to
navigate between checks. This allow to generate proper
hyperlinks when documentation is generated in other
format than html, for example: latex or pdf
2023-08-21 17:02:44 +00:00
Kazu Hirata
11e2975810 Fx typos in documentation 2023-08-18 23:36:04 -07:00
Felix
a94c44cc0a [clang-tidy] Added a new option to lambda-function-name to ignore warnings in macro expansion
Improved check lambda-function-name with option IgnoreMacros to ignore warnings in macro expansion.
Relates to #62857 (https://github.com/llvm/llvm-project/issues/62857)

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D157829
2023-08-16 15:02:56 +00:00
Chris Cotter
32870da3ba Fix typos in documentation 2023-08-13 23:46:44 -07:00
Piotr Zegar
887bece66c [clang-tidy][NFC] Update clang-analyzer-cplusplus.PlacementNew doc
Re-generate documentation for cplusplus.PlacementNew
using gen-static-analyzer-docs.py
2023-08-11 16:06:45 +00:00
Piotr Zegar
cd9e92309d [clang-tidy][NFC] Update add_new_check.py to handle more proper list.rst
Update script to generate list.rst in format that is
in-sync with gen-static-analyzer-docs.py.
Re-generate list.rst.
2023-08-11 11:02:28 +00:00
Piotr Zegar
d9cd7b0e5f [clang-tidy][NFC] Update documentation for Clang Static Analyzer aliases
Update documentation by using gen-static-analyzer-docs.py.
All  Clang Static Analyzer checks are now listed as aliases.
Check without documentation wont have a link.

Fixes: #41439
2023-08-11 10:36:46 +00:00
Piotr Zegar
5568f28c86 [clang-tidy][NFC] Update gen-static-analyzer-docs.py
Update gen-static-analyzer-docs.py to generate more proper documentation
for Clang Static Analyzer checkers.

Fixes: #43715
2023-08-11 10:36:45 +00:00
Chris Cotter
a563ced78b [clang-tidy] Implement cppcoreguidelines CP.52
Flag code that suspends a coroutine while a lock is held.

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D157057
2023-08-11 07:13:59 +00:00
Piotr Zegar
7f29f14d02 [clang-tidy] Ignore unevaluated context in cppcoreguidelines-pro-type-vararg
Ignore decltype, sizeof, alignof in this check.

Fixes: #30542

Reviewed By: ccotter

Differential Revision: https://reviews.llvm.org/D157376
2023-08-10 19:51:09 +00:00
Kadir Cetinkaya
724b40a137
[clang-tidy][Docs] Update docs per post-commit review 2023-08-08 16:16:51 +02:00
Kadir Cetinkaya
89d0a76be6
[clang-tidy][include-cleaner] Add option to control deduplication of findings per symbol
We received some user feedback around this being disruptful rather than
useful in certain workflows so add an option to control the output behaviour.

Differential Revision: https://reviews.llvm.org/D157390
2023-08-08 16:01:33 +02:00
Piotr Zegar
3d80103638 [clang-tidy][NFC] Fix link in documentation
Fix link to cppcoreguidelines-avoid-goto in doc.
2023-08-06 05:16:22 +00:00
Chris Cotter
6a1f8ef8a7 [clang-tidy] Support begin/end free functions in modernize-loop-convert
The modernize-loop-convert check will now match iterator based loops
that call the free functions 'begin'/'end', as well as matching the
free function 'size' on containers.

Test plan: Added unit test cases matching free function calls on
containers, and a single negative test case for length() which is not
supported.

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D140760
2023-08-05 20:55:48 +00:00
Piotr Zegar
ee2b765cdd [clang-tidy][NFC] Update documentation for hicpp-avoid-goto
Add info in check list that hicpp-avoid-goto is actually
a alias to cppcoreguidelines-avoid-goto.

Fixes: #64337

Reviewed By: carlosgalvezp

Differential Revision: https://reviews.llvm.org/D157182
2023-08-05 16:47:49 +00:00
Piotr Zegar
575900d0d9
[clang-tidy] Add bugprone-optional-value-conversion check
Detects potentially unintentional and redundant conversions where a value is
extracted from an optional-like type and then used to create a new instance of
the same optional-like type.

Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D147357
2023-07-31 06:22:39 +00:00
Chris Cotter
893d53d11c [clang-tidy] Implement modernize-use-constraints
Add new check to replace enable_if with C++20 constraints

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D141892
2023-07-30 20:43:18 +00:00
Piotr Zegar
f27f22b345
[clang-tidy] Added bugprone-inc-dec-in-conditions check
Detects when a variable is both incremented/decremented and referenced inside a
complex condition and suggests moving them outside to avoid ambiguity in the
variable's value.

Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D149015
2023-07-30 13:19:51 +00:00