Now MainFileMacros preserves enough information, we perform a just-in-time
convertion to interop with include-cleaner::Macro for include-cleaer features.
Differential Revision: https://reviews.llvm.org/D147034
Remove the `DenseMapInfo<std::variant<Ts...>>` variant out from
`llvm/ADT/DenseMapInfo.h` into a separate header
`llvm/ADT/DenseMapInfoVariant.h`
This allows us to remove the `<variant>` include, which is being
transitively and unncessary included in all translation units that
include `llvm/ADT/DenseMap.h`.
There have been similar changes to move out specializations for
* `APInt.h` fd7e309e02 and
* `StringRef.h`/`ArrayRef.h`
983565a6fe
to reduce the compilation time. As we are unable to move the
specialization into `<variant>`, we create a separate
`DenseMapInfoVariant.h` header that can be used by anyone who needs this
specialization.
This reduces the total number of preprocessing tokens across the LLVM
source files in lib from (roughly) 1,964,876,961 to 1,936,551,496 - a
reduction of ~1.44%. This should result in a small improvement in
compilation time.
Differential Revision: https://reviews.llvm.org/D150997
This fixes a false positive where a ParamVarDecl happend to be the
same name of some C standard symbol and has a global namespace.
```
using A = int(int time); // we suggest <ctime> for the `int time`.
```
Differential Revision: https://reviews.llvm.org/D153330
The binary tool only works on working source code, if the source code is
not compilable, don't perform any analysis and edits.
Differential Revision: https://reviews.llvm.org/D153271
We now display a simple note if the reason is that the used class does not
support move semantics.
This fixes llvm#62550
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D153220
For a declaration the `FunctionDecl` begin location does not include the
template parameter lists, but for some reason if you have a separate
definitions to the declaration the begin location does include them.
With this patch we now correctly handle that case.
This fixes llvm#62746
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D153218
This patch removes the last use of deprecated `DirectoryEntry::getName()`.
Depends on D151855.
Reviewed By: benlangmuir
Differential Revision: https://reviews.llvm.org/D151922
Included a note in the release documentation about the improved
performance of certain checks, allowing users who had previously
disabled them due to slowness to reconsider their decision.
Added new checks
- `performance-noexcept-destructor`
- `performance-noexcept-swap`
Also added cppcoreguidlines aliases for the 2 new checks as well as `performance-noexcept-move-constructor`
This fixes llvm#62154
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D148697
I'd like to use RedundantStringCStrCheck's formatDereference function
from the up-coming modernize-use-std-print check. Let's move it to
FixItHintUtils so that the implementation can be shared.
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D150602
This was causes by `getValueOfValueInit` unconditionally calling
`getScalarTypeKind` on the member type, which would then trigger an
assertions since arrays are not scalar type.
This fixes llvm#63285
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D152802
(This patch addresses the comment from https://reviews.llvm.org/D151785#4402460.)
Previously, we used a special printing policy that enabled `PrintCanonicalTypes`
to print type hints for structure bindings. This was intended to
eliminate type aliases like `tuple_element::type`. However, this also
caused TypePrinter to print default template arguments, which could
result in losing the ability to see types like `std::basic_string<char>`
if the fully expanded template-id exceeded the default inlay hint threshold.
Simply getting the canonical type at the call site could help us get rid of
the side effect.
This also merges overloaded `addTypeHint` into one function without
`PrintingPolicy`.
Reviewed By: nridge
Differential Revision: https://reviews.llvm.org/D152520
This patch alleviates https://github.com/clangd/clangd/issues/1298.
Containers in C++ such as `std::vector` or `llvm::SmallVector`,
introduce a series of type aliases to adapt to generic algorithms.
Currently, If we write an declarator involving expressions with
these containers and `auto` placeholder, we probably obtain opaque
type alias like following:
```
std::vector<int> v = {1, 2, 3};
auto value = v[1]; // hint for `value`: value_type
auto *ptr = &v[0]; // hint for `ptr`: value_type *
```
These hints are useless for most of the time. It would be nice if we
desugar the type of `value_type` and print `int`, `int *` respectively
in this situation. But note we can't always prefer desugared type
since user might introduce type-aliases for brevity, where printing
sugared types makes more sense.
This patch introduces a heuristic method that displays the desugared
type that is an alias of template parameter. It merges
analogous method `shouldPrintCanonicalType` into `maybeDesugar` as well.
Previous commit for shouldPrintCanonicalType: dde8a0fe91
Reviewed By: nridge
Differential Revision: https://reviews.llvm.org/D151785
We would like to move the preamble index out of the critical path.
This patch is an RFC to get feedback on the correct implementation and potential pitfalls to keep into consideration.
I am not entirely sure if the lazy AST initialisation would create using Preamble AST in parallel. I tried with tsan enabled clangd but it seems to work OK (at least for the cases I tried)
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D148088
I'd like to use RedundantStringCStrCheck's formatDereference function
from the up-coming modernize-use-std-print check. Let's move it to
FixItHintUtils so that the implementation can be shared.
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D150602
Adds a new option to the clang-tidy's check : readability-container-data-pointer to ignore some containers.
This option is useful in the case of std::array where the size is known at compile time and there is no real risk to access the first index of the container. In that case some users might prefer to ignore this type of container.
Relates to : https://github.com/llvm/llvm-project/issues/57445
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D133244
These functions can rethrow a current exception that is caught by the
catch block. We can pass the currently caught excections to the function
declaration analyzer just like the statement analyzer to handle this
case.
Differential Revision: https://reviews.llvm.org/D152330
This is final optimization for this check. Main
improvements comes from changing a logic order
in mayShadow function, to first validate result
of mayShadowImpl, then search primary context in
a vectors. Secondary improvement comes from excluding
all implicit code by using TK_IgnoreUnlessSpelledInSource.
All other changes are just cosmetic improvements.
Tested on Cataclysm-DDA open source project, result in
check execution time reduction from 3682 seconds to
100 seconds (~0.25s per TU). That's 97.2% reduction for
this change alone. Resulting in cumulative improvement for
this check around -99.6%, finally bringing this check
into a cheap category.
Reviewed By: serge-sans-paille
Differential Revision: https://reviews.llvm.org/D151594
The documentation claims that the check recognizes `ASSERT_THAT`, but it doesn't
recognize any googletest macros at the moment. This patch removes the reference.
(When clients support it, otherwise keep the existing rendering).
In VSCode this makes the signature darker.
Differential Revision: https://reviews.llvm.org/D151253