Age | Commit message (Collapse) | Author | Files | Lines |
|
DependentNameTypes (#83542)
When resolving names inside templates that implement recursive
compile-time functions (e.g. waldo<N>::type is defined in terms
of waldo<N-1>::type), HeuristicResolver could get into an infinite
recursion, specifically one where resolveDependentNameType() can
be called recursively with the same DependentNameType*.
To guard against this, HeuristicResolver tracks, for each external
call into a HeuristicResolver function, the set of DependentNameTypes
that it has seen, and bails if it sees the same DependentNameType again.
To implement this, a helper class HeuristicResolverImpl is introduced
to store state that persists for the duration of an external call into
HeuristicResolver (but does not persist between such calls).
Fixes https://github.com/clangd/clangd/issues/1951
(cherry picked from commit e6e53ca8470d719882539359ebe3ad8b442a8cb0)
|
|
|
|
to release/18.x (#80109)
Cherry picked from commit ee01a2c3996f9647f3158f5acdb921a6ede94dc1.
Closes #80041, backport #80108.
Co-authored-by: Shafik Yaghmour <shafik@users.noreply.github.com>
Co-authored-by: cor3ntin <corentinjabot@gmail.com>
Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
|
|
We were previously allowlisting awaitable types returned by
`await_transform` instead of the type of the operand of the `co_await`
expression.
This previously used to give false positives and not respect the
`AllowedAwaitablesList` flag when `await_transform` is used. See added
test cases for such examples.
|
|
Update list.rst to put checks in alphabetical order
|
|
User-defined literals do not accept u?intXX(_t)? variables. So the check
should not emit a warning.
Fixes #54546 #25214
|
|
(#78320)
The check no longer emits a diagnostic for non-parameter-pack
variables in C++17 fold expressions.
The operator used is type-dependent because of the parameter pack
and can therefore not be guaranteed to not mutate the variable.
Fixes: #70323
|
|
https://github.com/llvm/llvm-project/pull/76471 caused buildbot failures
on Windows. For more details, see
https://github.com/llvm/llvm-project/issues/77546.
This PR revises the test and relands
https://github.com/llvm/llvm-project/pull/76471.
|
|
Check that flags chained comparison expressions,
such as a < b < c or a == b == c, which may have
unintended behavior due to implicit operator
associativity.
Moved from Phabricator (D144429).
|
|
cppcoreguidelines-prefer-member-initializer (#72037)
Produces now valid fixes for a member variables initialized with macros.
Correctly uses expansion location instead of location inside macro to
get init code.
Close #70189
|
|
|
|
|
|
This is a follow up to https://github.com/llvm/llvm-project/pull/71417 ,
which aims to resolve concerns brought up there. Namely, this patch
replaces `CXXNewInitializationStyle::Implicit` with a dedicated
`HasInitializer` flag. This makes `CXXNewInitializationStyle` to model
syntax again. This patch also renames `Call` and `List` to less
confusing `Parens` and `Braces`.
|
|
scalar type. (#78041)
Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd, and
reverted because a dependency commit was reverted, then committed again
as 4b574008aef5a7235c1f894ab065fe300d26e786 and reverted again because
"dependency commit" 5a391d38ac6c561ba908334d427f26124ed9132e was
reverted. But it doesn't seem that 5a391d38ac6c was a real dependency
for this.
This commit incorporates 4b574008aef5a7235c1f894ab065fe300d26e786 and
18e093faf726d15f210ab4917142beec51848258 by Richard Smith (@zygoloid),
with some minor fixes, most notably:
- `UncommonValue` renamed to `StructuralValue`
- `VK_PRValue` instead of `VK_RValue` as default kind in lvalue and
member pointer handling branch in
`BuildExpressionFromNonTypeTemplateArgumentValue`;
- handling of `StructuralValue` in `IsTypeDeclaredInsideVisitor`;
- filling in `SugaredConverted` along with `CanonicalConverted`
parameter in `Sema::CheckTemplateArgument`;
- minor cleanup in
`TemplateInstantiator::transformNonTypeTemplateParmRef`;
- `TemplateArgument` constructors refactored;
- `ODRHash` calculation for `UncommonValue`;
- USR generation for `UncommonValue`;
- more correct MS compatibility mangling algorithm (tested on MSVC ver.
19.35; toolset ver. 143);
- IR emitting fixed on using a subobject as a template argument when the
corresponding template parameter is used in an lvalue context;
- `noundef` attribute and opaque pointers in `template-arguments` test;
- analysis for C++17 mode is turned off for templates in
`warn-bool-conversion` test; in C++17 and C++20 mode, array reference
used as a template argument of pointer type produces template argument
of UncommonValue type, and
`BuildExpressionFromNonTypeTemplateArgumentValue` makes
`OpaqueValueExpr` for it, and `DiagnoseAlwaysNonNullPointer` cannot see
through it; despite of "These cases should not warn" comment, I'm not
sure about correct behavior; I'd expect a suggestion to replace `if` by
`if constexpr`;
- `temp.arg.nontype/p1.cpp` and `dr18xx.cpp` tests fixed.
|
|
Add missing -fexceptions in test.
|
|
(#71650)
Fix issue with constructor call being interpreted as functional cast and
considered for a replacement
with static cast or being removed as redundant.
Closes #57959
|
|
|
|
This checks find usages of the inline keywork where it is already
implicitly defined by the compiler and suggests it's removal.
Fixes #72397
|
|
Detects explicit type casting operations that involve the same source
and destination types, and subsequently recommend their removal. Covers
a range of explicit casting operations. Its primary objective is to
enhance code readability and maintainability by eliminating unnecessary
type casting.
Closes #67534
|
|
iterator (#78796)
Fix crash when built-in type (like int) is used as iterator, or when
call to begin() return integer.
Closes #78381
|
|
`collectReplacementsFromDirectory` (NFC) (#78630)
* Convert `collectReplacementsFromDirectory` into a function template.
* Employ explicit specialization to maintain implementation in the
source file.
* Utilize the function template in the source file to eliminate code
duplication.
* Update the documentation for the function.
|
|
Builtin templates e.g. `__make_integer_seq`, `__type_pack_element` are
such that they don't have alias *Decls*.
[D133262](https://reviews.llvm.org/D133262) marked these as alias
templates, resulting in an attempt to collect their null "using" Decls
within our `TargetFinder`.
This fixes https://github.com/clangd/clangd/issues/1906.
|
|
To avoid any possible confusion with the notion of pure function and the
gnu::pure attribute.
|
|
TokenBuffer::spelledForExpanded() (#78092)
Such ranges can legitimately arise in the case of invalid code, such as
a declaration missing an ending brace.
Fixes https://github.com/clangd/clangd/issues/1559
|
|
fixes (#74891)
Check now more properly add missing parentheses to code like this: 'bool
bar = true ? 1 : 0 != 0;'.
Closes #71867
|
|
`UnusedUsingDeclsCheck::removeFromFoundDecls` will be called with high
frequency. At current time it will check every `Context`.
This patch adds a cache to reduce algorithm complexity.
|
|
(#77105)
Right now we are not triggering on:
```
for (auto [x, y] : container) {
// const-only access
}
```
|
|
|
|
|
|
Finds nested conditional operator.
Nested conditional operators lead code hard to understand, so they
should be splited as several statement and stored in temporary varibale.
|
|
comparison bool bitfield (#77878)
Fixes: #76817
For ignoring comparison and xor operator, it needs
to use `ImplicitCastFromBool` without ignoring
exception cases.
This patch splits ignoring exception cases logic
from `ImplicitCastFromBool` and only applies
it during matching targeted AST.
|
|
|
|
|
|
Added support for size-like method returning signed type, and corrected
false positive caused by always-false check for size bellow zero.
Closes #72619
|
|
readability-redundant-member-init (#77206)
Support detecting redundant in-class initializers.
Moved from https://reviews.llvm.org/D157262
Fixes: #62525
|
|
Reorder checks & fix some formating.
|
|
Added support for iter_swap, iter_move in bugprone-exception-escape
and performance-noexcept-swap checks.
Fixes #75686
|
|
`readability-simplify-boolean-expr` check (#78043)
|
|
implicit-widening-multiplication-result (#76315)
The check currently emits warnings for the following code:
`uint64_t fn() { return 1024 * 1024; }`
But the code generated after applying the notes will look like this:
`uint64_t fn() { return static_cast<uint64_t>(1024 * )1024; }`
This is because when generating the notes the check will use the
beginLoc() and EndLoc() of the subexpr of the implicit cast.
But in some cases the AST Node might not have a beginLoc and EndLoc.
This seems to be true when the Node is composed of only 1 token (for
example an integer literal). Calling the getEndLoc() on this type of
node will simply return the known location which is, in this case, the
beginLoc.
Fixes #63070 #56728
|
|
|
|
|
|
|
|
non-constexpr variables (#77203)
Ignore false-positives when referring to non-constexpr variables in
non-unevaluated context (like decltype, sizeof, ...).
Moved from https://reviews.llvm.org/D158657
Fixes: #24066
|
|
llvm-project/clang-tools-extra/clangd/CompileCommands.cpp:324:52:
error: 'startswith' is deprecated: Use starts_with instead [-Werror,-Wdeprecated-declarations]
324 | Cmd, [&](llvm::StringRef Arg) { return Arg.startswith(Flag); });
| ^~~~~~~~~~
| starts_with
|
|
(#75694)
CommandMangler should guess the sysroot path of the host system and add
that through `-isysroot` flag only when there is no `--sysroot` or
`-isysroot` flag in the original compile command to avoid duplicate
sysroot.
Previously, CommandMangler appropriately avoided adding a guessed
sysroot flag if the original command had an argument in the form of
`--sysroot=<sysroot>`, `--sysroot <sysroot>`, or `-isysroot <sysroot>`.
However, when presented as `-isysroot<sysroot>` (without spaces after
`-isysroot`), CommandMangler mistakenly appended the guessed sysroot
flag, resulting in duplicated sysroot in the final command.
This commit fixes it, ensuring the final command has no duplicate
sysroot flags. Also adds unit tests for this fix.
|
|
We used to consider the `DeclContext` for selection nodes inside a
lambda as the enclosing scope of the lambda expression, rather than the
lambda itself.
For example,
```cpp
void foo();
auto lambda = [] {
return ^foo();
};
```
where `N` is the selection node for the expression `foo()`,
`N.getDeclContext()` returns the `TranslationUnitDecl` previously, which
IMO is wrong, since the method `operator()` of the lambda is closer.
Incidentally, this fixes a glitch in add-using-declaration tweaks.
(Thanks @HighCommander4 for the test case.)
|
|
|
|
This makes it easier to ship/install these using the builtin Emacs
package format (in particular, a Version is required).
|
|
Issue #77546
This reverts commit 07c9189fcc063bdf6219d2733843c89cde3991e1.
|
|
|