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.
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
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
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.
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
Improved cppcoreguidelines-pro-type-const-cast check to ignore casts to
const type (controlled by option) and casts in implicitly invoked code.
Fixes#69319
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();
```
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
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.
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
…-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>
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
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
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
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
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
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
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
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
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