Normally endless recursion should not happen in ExceptionSpecAnalyzer,
but if AST would be malformed (missing include), this could cause crash.
I run into this issue when due to missing include constructor argument
were parsed as FieldDecl.
As checking for recursion cost nothing, why not to do this in check just
in case.
Fixes#111436
This PR add diagnostics for 3-parameter `std::basic_string(const char*
t, size_type pos, size_type count)` constructor in
bugprone-string-constructor check:
```cpp
std::string r1("test", 1, 0); // constructor creating an empty string
std::string r2("test", 0, -4); // negative value used as length parameter
// more examples in test file
```
Fixes false-positives reported in https://github.com/llvm/llvm-project/issues/123198.
This patch addresses situations when misc-redundant-expression checker
provides excessive diagnostics for situations with different macros
having the same value. In particular it addresses situations described
in the initial report of
https://github.com/llvm/llvm-project/issues/118885 are addressed. The
situations which are popped inside discussion like if (A + B == B + A)
for macros are not properly addressed by this patch.
Those changes are also mentioned in Release Notes.
---------
Co-authored-by: Vladislav Aranov <vladislav.aranov@ericsson.com>
Co-authored-by: EugeneZelenko <eugene.zelenko@gmail.com>
Before, C++ member functions in the format of ``Class instance;
instance.memberfn();`` were unable to be matched.
This PR adds support for this type of call, and it is matched in exactly
the same format as other functions (eg. ``::Class::memberfn`` qualified
name).
Similarly to https://github.com/llvm/llvm-project/pull/122918, leading
comments are currently not being moved.
```
struct Foo {
// This one is the cool field.
int a;
int b;
};
```
becomes:
```
struct Foo {
// This one is the cool field.
int b;
int a;
};
```
but should be:
```
struct Foo {
int b;
// This one is the cool field.
int a;
};
```
We have two copies of the same code in clang-tidy and
clang-reorder-fields, and those are extremenly similar to
`Lexer::findNextToken`, so just add an extra agument to the latter.
---------
Co-authored-by: cor3ntin <corentinjabot@gmail.com>
A change list may include files that are not part of the compile
database, which can cause clang-tidy to fail (e.g., due to missing
included headers). To prevent false negatives, we should allow to skip
processing these files.
This checks that classes/structs inheriting from
``std::enable_shared_from_this`` does so with public inheritance, so it
prevents crashes due to ``std::make_shared`` and ``shared_from_this()``
getting called when the internal weak pointer was not initialized (e.g.
due to private inheritance).
When comparing with integer literal, integer promote will happen to
promote type which has less bit width than int to int or unsigned int.
It will let auto-fix provide correct but out of expected fix.
e.g.
```c++
short a;
if ( a > 10 )
a = 10;
```
will be
```c++
short a;
if ( (int)a > 10 )
a = (short)10;
```
which will be fixed as
```c++
short a;
a = std::max<int>(a, 10);
```
but actually it can be
```c++
short a;
a = std::max<short>(a, 10);
```
Fixed: #121676
Exclude CXXParenListInitExpr from RedundantCastingCheck because there
are false positive cases. Currently, we can't think of positive cases
for CXXParenListInitExpr. This can be improved by following the
initListExpr method if we can come up with some positive cases.
Fixes#108846
Current implement will cache `OptionsSource` for each path, it will
create lots of copy of `OptionsSource` when project has deep nested
folder structure.
New implement use vector to store `OptionsSource` and only cache the
index. It can reduce memory usage and avoid meaningless copy.
Don't suggest to comment-out the parameter name if the parameter has an
attribute that's spelled after the parameter name.
This prevents the parameter's attributes from being wrongly applied to
the parameter's type.
This fixes#122191.
This reverts commit 81fc3add1e627c23b7270fe2739cdacc09063e54.
This breaks some LLDB tests, e.g.
SymbolFile/DWARF/x86/no_unique_address-with-bitfields.cpp:
lldb: ../llvm-project/clang/lib/AST/Decl.cpp:4604: unsigned int clang::FieldDecl::getBitWidthValue() const: Assertion `isa<ConstantExpr>(getBitWidth())' failed.
Save the bitwidth value as a `ConstantExpr` with the value set. Remove
the `ASTContext` parameter from `getBitWidthValue()`, so the latter
simply returns the value from the `ConstantExpr` instead of
constant-evaluating the bitwidth expression every time it is called.
We plan to depercate `StrictMode` and `IgnoreMacros` global options
after 2 major versions and support local options only for them.
This patch introduces the depercation warning.
According to #116591.
> Coding guidelines should "cherry-pick" (and posddsibly
configure/harden/make more strict) base checks.
We should move narrowing conversion to bugprone and keep alias in
cppcoreguidelines
As given in the issue #36323 , I added two new options in the
clang-tools-extra/clan-tidy/readibility/ImplicitBoolConversionCheck.cpp
and header file.
I have also written new test cases to test these new options in
test/readibility directory.
Previously, the implementation used the printed type, which contains
expanded
macro arguments, deletes comments, and removes function argument names
from the alias declaration. Instead, this check can be more surgical and
use the
actual written type verbatim.
Fixes#33760Fixes#37846Fixes#41685Fixes#83568Fixes#95716Fixes#97009