Age | Commit message (Collapse) | Author | Files | Lines |
|
(#95580)
This checks if the layout of `std::initializer_list` is something Clang
can handle much earlier and deduplicates the checks in
CodeGen/CGExprAgg.cpp and AST/ExprConstant.cpp
Also now diagnose `union initializer_list` (Fixes #95495), bit-field for
the size (Fixes a crash that would happen during codegen if it were
unnamed), base classes (that wouldn't be initialized) and polymorphic
classes (whose vtable pointer wouldn't be initialized).
|
|
The Legacy PM was deprecated for the optimization pipeline in LLVM 14
[1] (the support was removed altogether in the following release). This
patch removes the original Hello example that was introduced to
illustrate the Legacy PM. The Hello example no longer works and hence is
deleted. The corresponding documentation is also removed.
Note, Hello example for the new PM is located in
* llvm/lib/Transforms/Utils/HelloWorld.cpp
and documented in
* WritingAnLLVMNewPMPass.rst.
[1]
https://releases.llvm.org/14.0.0/docs/ReleaseNotes.html#changes-to-the-llvm-ir
|
|
name as standard library functions in misc-include-cleaner (#94923)"
This reverts commit 1bae10879d9183c5edfb709c36b55086ebc772f0. Also add
some test cases to prevent further regressions.
|
|
performance-inefficient-vector-operation (#95667)
Fixes: #95596
Avoid false negatives caused by different variable definition type and
variable initial value type in loop initialization expression.
|
|
rvalue for performance-move-const-arg (#95633)
Fixes: #86404
---------
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
|
|
bugprone-return-const-ref-from-parameter (#95434)
Fixes: #90274
|
|
cppcoreguidelines-macro-usage (#95265)
`#` and `##` preprocessing tokens cannot be replaced by constexpr
function. It should be ignored in check.
|
|
standard library functions in misc-include-cleaner (#94923)
Fixes: #93335
For decl with body, we should provide physical locations also. Because
it may be the function which have the same name as std library.
|
|
(#94356)
This commit reimplements the functionality of the Clang Static Analyzer
checker `alpha.core.SizeofPointer` within clang-tidy by adding a new
(off-by-default) option to bugprone-sizeof-expression which activates
reporting all the `sizeof(ptr)` expressions (where ptr is an expression
that produces a pointer).
The main motivation for this change is that `alpha.core.SizeofPointer`
was an AST-based checker, which did not rely on the path sensitive
capabilities of the Static Analyzer, so there was no reason to keep it
in the Static Analyzer instead of the more lightweight clang-tidy.
After this commit I'm planning to create a separate commit that deletes
`alpha.core.SizeofPointer` from Clang Static Analyzer.
It was natural to place this moved logic in bugprone-sizeof-expression,
because that check already provided several heuristics that reported
various especially suspicious classes of `sizeof(ptr)` expressions.
The new mode `WarnOnSizeOfPointer` is off-by-default, so it won't
surprise the existing users; but it can provide a more through coverage
for the vulnerability CWE-467 ("Use of sizeof() on a Pointer Type") than
the existing partial heuristics.
Previously this checker had an exception that the RHS of a
`sizeof(array) / sizeof(array[0])` expression is not reported; I
generalized this to an exception that the check doesn't report
`sizeof(expr[0])` and `sizeof(*expr)`. This idea is taken from the
Static Analyzer checker `alpha.core.SizeofPointer` (which had an
exception for `*expr`), but analysis of open source projects confirmed
that this indeed eliminates lots of unwanted results.
Note that the suppression of `sizeof(expr[0])` and `sizeof(*expr)`
reports also affects the "old" mode `WarnOnSizeOfPointerToAggregate`
which is enabled by default.
This commit also replaces the old message "suspicious usage of
'sizeof(A*)'; pointer to aggregate" with two more concrete messages; but
I feel that this tidy check would deserve a through cleanup of all the
diagnostic messages that it can produce. (I added a FIXME to mark one
outright misleading message.)
|
|
(#94362)
…and operators that have non-const overloads.
This allows `unnecessary-copy-initialization` to warn on more cases.
The common case is a class with a a set of const/non-sconst overloads
(e.g. std::vector::operator[]).
```
void F() {
std::vector<Expensive> v;
// ...
const Expensive e = v[i];
}
```
|
|
Ignore implicit pointer conversions that are part of a cast expression
Closes #93959
|
|
(#94651)
Add StrictCStandardCompliance and StrictCppStandardCompliance options
that default to true.
Closes #83732
|
|
readability-implicit-bool-conversion (#94512)
Ignore implicit declarations and defaulted functions. Helps with issues
in generated code like, C++
spaceship operator.
Closes #93409
|
|
readability-math-missing-parentheses (#94654)
Do not emit warnings for non-math operators.
Closes #92516
|
|
Add new check misc-use-internal-linkage to detect variable and function
can be marked as static.
---------
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
|
|
misc-header-include-cycle (#94636)
Fixes: #94634
|
|
Fixed crash caused by call to getCookedLiteral on
template user defined literal. Fix base on assert in getCookedLiteral
method.
Closes #94454
|
|
(#93217)
Compare class type instead of just assuming
that called constructor belong to same class.
Fixes #91605
|
|
Ensure that FormatStringConverter's constructor fails with a sensible
error message rather than asserting if the format string is not a narrow
string literal.
Also, ensure that we don't even get that far in modernize-use-std-print
and modernize-use-std-format by checking that the format string
parameter is a char pointer.
Fixes #92896
|
|
readability-container-size-empty (#93724)
Verify that size/length methods are called with no arguments.
Closes #88203
|
|
C23 (#92241)
`readability-implicit-bool-conversion` supports language-versions with
`LangOpts.Bool` which includes C23.
This PR corrects an issue that the fixer suggests `static_cast<>()`
which is not available in C23,
and will instead suggest C-style casts on other than C++.
The fixer will also suggest using `nullptr` instead of `0` and avoid a
problem with recursive fixes on C23.
The recursive issue, a function taking bool and a comparison, is now
excluded as in C++.
|
|
Since C++14 has been released for about nine years and most standard
libraries have implemented sized deallocation functions, it's time to
make this feature default again.
This is another try of https://reviews.llvm.org/D112921.
The original commit cf5a8b4 was reverted by 2e5035a due to some
failures (see #83774).
Fixes #60061
|
|
Member function templates defined out-of-line were resulting in
conflicting naming failures with overlapping usage sets. With this
change, out-of-line definitions are treated as a usage of the failure
which is the inline declaration.
|
|
class (#92597)
Consider the following:
```
template<typename T>
struct A
{
struct B : A { };
};
```
According to [class.derived.general] p2:
> [...] A _class-or-decltype_ shall denote a (possibly cv-qualified)
class type that is not an incompletely defined class; any cv-qualifiers
are ignored. [...]
Although GCC and EDG rejects this, Clang accepts it. This is incorrect,
as `A` is incomplete within its own definition (outside of a
complete-class context). This patch correctly diagnoses instances where
the current instantiation is used as a base class before it is complete.
Conversely, Clang erroneously rejects the following:
```
template<typename T>
struct A
{
struct B;
struct C : B { };
struct B : C { }; // error: circular inheritance between 'C' and 'A::B'
};
```
Though it may seem like no valid specialization of this template can be
instantiated, an explicit specialization of either member classes for an
implicit instantiated specialization of `A` would permit the definition
of the other member class to be instantiated, e.g.:
```
template<>
struct A<int>::B { };
A<int>::C c; // ok
```
So this patch also does away with this error. This means that circular
inheritance is diagnosed during instantiation of the definition as a
consequence of requiring the base class type to be complete (matching
the behavior of GCC and EDG).
|
|
Currently, `new struct S` fails to set any valid end source location
because the token corresponding to `S` is consumed in
`ParseClassSpecifier` and is not accessible in the
`ParseDeclarationSpecifiers` that normally sets the end source location.
Fixes #35300
|
|
cppcoreguidelines-special-member-functions (#71683)
Improved cppcoreguidelines-special-member-functions check with a new
option AllowImplicitlyDeletedCopyOrMove, which removes the requirement
for explicit copy or move special member functions when they are already
implicitly deleted.
Closes #62392
|
|
Improved modernize-use-constraints check by fixing a crash that occurred
in some scenarios and excluded system headers from analysis.
Problem were with DependentNameTypeLoc having null type location as
getQualifierLoc().getTypeLoc().
Fixes #91872
|
|
(#91992)
Previously, the call to `findArgs` for a `CallExpr` inside of a `min` or
`max` call would call `findArgs` before checking if the argument is a
call to `min` or `max`, which is what `findArgs` is expecting.
The fix moves the name checking before the call to `findArgs`, such that
only a `min` or `max` function call is used as an argument.
Fixes #91982
Fixes #92249
|
|
This is a renewed attempt to land @toddlipcon's D34654. The comments on
that patch indicate a broad desire for some ability to ignore headers.
After considering various options, including migrating to std::regex, I
believe this is the best path forward. It's intuitive to have separate
regexes for including headers versus excluding them, and this approach
has the added benefit of being completely opt-in. No existing configs
will break, regardless of existing HeaderFilterRegex values.
This functionality is useful for improving performance when analyzing a
targeted subset of code, as well as in cases where some collection of
headers cannot be modified (third party source, for example).
|
|
When someone wants to declare a test case without any diagnosis.
check-clang-tidy will failed with error message
```
CHECK-FIXES, CHECK-MESSAGES or CHECK-NOTES not found in the input
```
This PR want to check there are no diagnosis from clang-tidy when
CHECK-FIXES, CHECK-MESSAGES or CHECK-NOTES are not found.
It also changes the extension of a test case. `hxx` is not a valid test
case extension and won't be tested.
---------
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
|
|
Add a new clang-tidy check that converts absl::StrFormat (and similar
functions) to std::format (and similar functions.)
Split the configuration of FormatStringConverter out to a separate
Configuration class so that we don't risk confusion by passing two
boolean configuration parameters into the constructor. Add
AllowTrailingNewlineRemoval option since we never want to remove
trailing newlines in this check.
|
|
bugprone-optional-value-conversion (#90410)
Ignore optionals in unevaluated context, like static_assert or decltype.
Closes #89593
|
|
|
|
expand from macro when ``IgnoreMacro`` option is enabled. (#91757)
Fixes: #91487
|
|
This XFAIL test is written in 4 years ago and still todo.
4 is already in DefaultIgnoredIntegerValues so I do not think this XFAIL
case can be passed.
|
|
`readability-string-compare` (#88636)
This PR aims to expand the list of classes that are considered to be
"strings" by `readability-string-compare` check.
1. Currently only `std::string;:compare` is checked, but
`std::string_view` has a similar `compare` method. This PR enables
checking of `std::string_view::compare` by default.
2. Some codebases use custom string-like classes that have public
interfaces similar to `std::string` or `std::string_view`. Example:
[TStringBase](https://github.com/yandex/yatool/blob/main/util/generic/strbase.h#L38),
A new option, `readability-string-compare.StringClassNames`, is added to
allow specifying a custom list of string-like classes.
Related to, but does not solve #28396 (only adds support for custom
string-like classes, not custom functions)
|
|
readability-static-accessed-through-instance (#90736)
Improved readability-static-accessed-through-instance check to
support expressions with side-effects.
Originally calls to overloaded operator were
ignored by check, in fear of possible side-effects.
This change remove that restriction, and enables
fix-its for expressions with side-effect via
--fix-notes.
Closes #75163
|
|
IgnorePositiveIntegerLiterals (#90621)
Improved hicpp-signed-bitwise check by ignoring false positives
involving positive integer literals behind implicit casts when
IgnorePositiveIntegerLiterals is enabled.
Closes #89367
|
|
`bugprone-return-const-ref-from-parameter` (#90273)
In the AST for function templates, the return will be a DeclRefExpr,
even if the return type differs from that of the returned variable.
Protect against false-positives by constraining the canonical return
type to be that of the parameter.
Also streams the source range of the returned expression into the
diagnostic.
|
|
Skip files with intentional CRLF line endings:
test/clang-apply-replacements/crlf.cpp
test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
clangd/test/input-mirror.test
clangd/test/protocol.test
clangd/test/too-large.test
|
|
The test was failing spuriously on some machines [1]. Converting from
grep to FileCheck makes it easier to see what's happening, and also grep
is discouraged in tests [2].
Also drop the negative test: checking for the expected output is better.
1. https://crbug.com/338535754
2. https://llvm.org/docs/TestingGuide.html#:~:text=.%20%5BThe-,usage%20of%20grep,-in%20RUN%20lines
|
|
From now readability-const-return-type won't provide warnings for
returning const types, where const is not on top level. In such case
const there is a performance issue, but not a readability.
Closes #73270
|
|
(#90566)
Improved bugprone-casting-through-void check by ignoring casts where
source is already a void pointer, making middle void pointer casts
bug-free.
Closes #87069
|
|
non-existent members of the current instantiation prior to instantiation in the absence of dependent base classes (#84050)" (#90152)
Reapplies #84050, addressing a bug which cases a crash when an
expression with the type of the current instantiation is used as the
_postfix-expression_ in a class member access expression (arrow form).
|
|
`readability-math-missing-parentheses` (#90279)
When a binary operator is the last operand of a macro, the end location
that is past the `BinaryOperator` will be inside the macro and therefore
an
invalid location to insert a `FixIt` into, which is why the check bails
when encountering such a pattern.
However, the end location is only required for the `FixIt` and the
diagnostic can still be emitted, just without an attached fix.
|
|
C23 introduces the `nullptr` constant similar to C++11 which means that
the checker `modernize-use-nullptr` can be used on C23 code as well.
This PR enables the checker to be run on C23 and adds testcases.
See N3042:
https://open-std.org/JTC1/SC22/WG14/www/docs/n3042.htm
|
|
(#83774)" (#90299)
https://lab.llvm.org/buildbot/#/builders/168/builds/20063 (should be
fixed with #90292)
More details in #83774
This reverts commit cf5a8b489464d09dfdd7a48ce7c8b41d3c9bf819.
|
|
Since C++14 has been released for about nine years and most standard
libraries have implemented sized deallocation functions, it's time to
make this feature default again.
This is another try of https://reviews.llvm.org/D112921.
Fixes #60061
|
|
non-existent members of the current instantiation prior to instantiation in the absence of dependent base classes (#84050)"
This reverts commit a8fd0d029dca7d17eee72d0445223c2fe1ee7758.
|
|
members of the current instantiation prior to instantiation in the absence of dependent base classes (#84050)
Consider the following:
```cpp
template<typename T>
struct A
{
auto f()
{
return this->x;
}
};
```
Although `A` has no dependent base classes and the lookup context for
`x` is the current instantiation, we currently do not diagnose the
absence of a member `x` until `A<T>::f` is instantiated. This patch
moves the point of diagnosis for such expressions to occur at the point
of definition (i.e. prior to instantiation).
|