Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init, llvmorg-19.1.7
# a5364444 12-Jan-2025 Barnabás Pőcze <pobrn@protonmail.com>

[clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (#119974)

Static member functions can be considered the same way as free functions
are, so do that.


Revision tags: llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3
# 1b0fcf1e 22-Oct-2024 Vlad Serebrennikov <serebrennikov.vladislav@gmail.com>

[clang-tidy][NFC] Replace usages of `DeclSpec::TQ` with `Qualifiers::TQ` (#113295)

This patch improves, but doens't fully resolve the layering violation,
which stems from relying on Sema. There's o

[clang-tidy][NFC] Replace usages of `DeclSpec::TQ` with `Qualifiers::TQ` (#113295)

This patch improves, but doens't fully resolve the layering violation,
which stems from relying on Sema. There's one function that needs to
convert enumerator to a string (`buildQualifier` in
`FixItHintUtils.cpp`), but `Qualifiers::TQ` doesn't offer such function.
Even more, the set of enumerators is not complete compared to
`DeclSpec::TQ`, so I'm afraid that this would be a functional change.

show more ...


Revision tags: llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8
# 415a82c6 10-Jun-2024 Clement Courbet <courbet@google.com>

[clang-tidy] `doesNotMutateObject`: Handle calls to member functions … (#94362)

…and operators that have non-const overloads.

This allows `unnecessary-copy-initialization` to warn on more cases.

[clang-tidy] `doesNotMutateObject`: Handle calls to member functions … (#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];
}
```

show more ...


Revision tags: llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3
# 11a411a4 31-Mar-2024 Piotr Zegar <me@piotrzegar.pl>

Revert "[clang-tidy][NFC] Remove duplicated code"

This reverts commit b6f6be4b500ff64c23a5103ac3311cb74519542f.


# b6f6be4b 31-Mar-2024 Piotr Zegar <me@piotrzegar.pl>

[clang-tidy][NFC] Remove duplicated code

Remove duplicated matchers by moving some of them to
utils/Matchers.h. Add some anonymous namespaces and
renamed some code to avoid ODR issues.


Revision tags: llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4
# 94ca854d 26-Feb-2024 Clement Courbet <courbet@google.com>

[clang-tidy] Add support for determining constness of more expressions. (#82617)

This uses a more systematic approach for determining whcich
`DeclRefExpr`s mutate the underlying object: Instead of

[clang-tidy] Add support for determining constness of more expressions. (#82617)

This uses a more systematic approach for determining whcich
`DeclRefExpr`s mutate the underlying object: Instead of using a few
matchers, we walk up the AST until we find a parent that we can prove
cannot change the underlying object.

This allows us to handle most address taking and dereference, bindings
to value and const& variables, and track constness of pointee (see
changes in DeclRefExprUtilsTest.cpp).

This allows supporting more patterns in
`performance-unnecessary-copy-initialization`.

Those two patterns are relatively common:

```
const auto e = (*vector_ptr)[i]
```

and

```
const auto e = vector_ptr->at(i);
```

In our codebase, we have around 25% additional findings from
`performance-unnecessary-copy-initialization` with this change. I did
not see any additional false positives.

show more ...


Revision tags: llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init
# 04ce9a34 07-Dec-2023 Clement Courbet <courbet@google.com>

[clang-tidy] performance-unnecessary-copy-init: Add a hook... (#73921)

... so that derived checks can can observe for which
variables a warning has been emitted. Does nothing by default, which
mak

[clang-tidy] performance-unnecessary-copy-init: Add a hook... (#73921)

... so that derived checks can can observe for which
variables a warning has been emitted. Does nothing by default, which
makes this an NFC.

show more ...


Revision tags: llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4
# cbdc3e1b 27-Aug-2023 Piotr Zegar <me@piotrzegar.pl>

[clang-tidy][NFC] Fix cppcoreguidelines-init-variables findings

Fix issues found by clang-tidy in clang-tidy source directory.


Revision tags: llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init
# 7d2ea6c4 14-Jan-2023 Carlos Galvez <carlosgalvezp@gmail.com>

[clang-tidy][NFC] Use C++17 nested namespaces in the clang-tidy folder

Fix applied by running:

run-clang-tidy.py -checks=-*,modernize-concat-nested-namespaces

Differential Revision: https://review

[clang-tidy][NFC] Use C++17 nested namespaces in the clang-tidy folder

Fix applied by running:

run-clang-tidy.py -checks=-*,modernize-concat-nested-namespaces

Differential Revision: https://reviews.llvm.org/D141770

show more ...


Revision tags: llvmorg-15.0.7
# f71ffd3b 08-Jan-2023 Kazu Hirata <kazu@google.com>

[clang-tools-extra] Use std::optional instead of llvm::Optional (NFC)

This patch replaces (llvm::|)Optional< with std::optional<. I'll post
a separate patch to clean up the "using" declarations, #i

[clang-tools-extra] Use std::optional instead of llvm::Optional (NFC)

This patch replaces (llvm::|)Optional< with std::optional<. I'll post
a separate patch to clean up the "using" declarations, #include
"llvm/ADT/Optional.h", etc.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

show more ...


# 71f55735 08-Jan-2023 Kazu Hirata <kazu@google.com>

[clang-tools-extra] Add #include <optional> (NFC)

This patch adds #include <optional> to those files containing
llvm::Optional<...> or Optional<...>.

I'll post a separate patch to actually replace

[clang-tools-extra] Add #include <optional> (NFC)

This patch adds #include <optional> to those files containing
llvm::Optional<...> or Optional<...>.

I'll post a separate patch to actually replace llvm::Optional with
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

show more ...


# cd8702ef 03-Dec-2022 Kazu Hirata <kazu@google.com>

[clang-tidy] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated. The intent is to reduce
the amount

[clang-tidy] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated. The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

show more ...


Revision tags: llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, working, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3
# bcd9ba2b 14-Aug-2022 Matheus Izvekov <mizvekov@gmail.com>

[clang] Track the templated entity in type substitution.

This is a change to how we represent type subsitution in the AST.
Instead of only storing the replaced type, we track the templated
entity we

[clang] Track the templated entity in type substitution.

This is a change to how we represent type subsitution in the AST.
Instead of only storing the replaced type, we track the templated
entity we are substituting, plus an index.
We modify MLTAL to track the templated entity at each level.

Otherwise, it's much more expensive to go from the template parameter back
to the templated entity, and not possible to do in some cases, as when
we instantiate outer templates, parameters might still reference the
original entity.

This also allows us to very cheaply lookup the templated entity we saw in
the naming context and find the corresponding argument it was replaced
from, such as for implementing template specialization resugaring.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Differential Revision: https://reviews.llvm.org/D131858

show more ...


Revision tags: llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init, llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4
# 12cb5405 09-May-2022 Nathan James <n.james93@hotmail.co.uk>

[clang-tidy][NFC] Replace many instances of std::string where a StringRef would suffice.

There's many instances in clang tidy checks where owning strings are used when we already have a stable strin

[clang-tidy][NFC] Replace many instances of std::string where a StringRef would suffice.

There's many instances in clang tidy checks where owning strings are used when we already have a stable string from the options, so using a StringRef makes much more sense.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D124341

show more ...


Revision tags: llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1, llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3, llvmorg-14.0.0-rc2, llvmorg-14.0.0-rc1, llvmorg-15-init, llvmorg-13.0.1, llvmorg-13.0.1-rc3, llvmorg-13.0.1-rc2, llvmorg-13.0.1-rc1
# ba4411e7 19-Nov-2021 Clement Courbet <courbet@google.com>

[clang-tidy] performance-unnecessary-copy-initialization: Fix false negative.

`isConstRefReturningMethodCall` should be considering
`CXXOperatorCallExpr` in addition to `CXXMemberCallExpr`. Clang co

[clang-tidy] performance-unnecessary-copy-initialization: Fix false negative.

`isConstRefReturningMethodCall` should be considering
`CXXOperatorCallExpr` in addition to `CXXMemberCallExpr`. Clang considers
these to be distinct (`CXXOperatorCallExpr` derives from `CallExpr`, not
`CXXMemberCallExpr`), but we don't care in the context of this
check.

This is important because of
`std::vector<Expensive>::operator[](size_t) const`.

Differential Revision: https://reviews.llvm.org/D114249

show more ...


# fefe20b9 19-Nov-2021 Felix Berger <flx@google.com>

[clang-tidy] performance-unnecessary-copy-initialization: Correctly match the type name of the thisPointertype.

The matching did not work correctly for pointer and reference types.

Differential Rev

[clang-tidy] performance-unnecessary-copy-initialization: Correctly match the type name of the thisPointertype.

The matching did not work correctly for pointer and reference types.

Differential Revision: https://reviews.llvm.org/D114212

Reviewed-by: courbet

show more ...


# fc1b24d7 28-Oct-2021 Clement Courbet <courbet@google.com>

[clang-tidy]performance-unnecessary-copy-initialization: fix false negative

We're missing all cases where the return value is a type alias.

Unfortunately, this includes things we care about, such a

[clang-tidy]performance-unnecessary-copy-initialization: fix false negative

We're missing all cases where the return value is a type alias.

Unfortunately, this includes things we care about, such as
`std::vector<T>::operator[]` (return value is `const_reference`,
not `const T&`).

Match the canonical type instead.

Differential Revision: https://reviews.llvm.org/D112722

show more ...


Revision tags: llvmorg-13.0.0, llvmorg-13.0.0-rc4, llvmorg-13.0.0-rc3, llvmorg-13.0.0-rc2, llvmorg-13.0.0-rc1, llvmorg-14-init
# cb4c12b6 16-Jul-2021 Felix Berger <flx@google.com>

[clang-tidy] performance-unnecessary-copy-initialization: Create option to exclude container types from triggering the check.

Add string list option of type names analagous to `AllowedTypes` which l

[clang-tidy] performance-unnecessary-copy-initialization: Create option to exclude container types from triggering the check.

Add string list option of type names analagous to `AllowedTypes` which lets
users specify a list of ExcludedContainerTypes.

Types matching this list will not trigger the check when an expensive variable
is copy initialized from a const accessor method they provide, i.e.:

```
ExcludedContainerTypes = 'ExcludedType'

void foo() {
ExcludedType<ExpensiveToCopy> Container;
const ExpensiveToCopy NecessaryCopy = Container.get();
}
```

Even though an expensive to copy variable is copy initialized the check does not
trigger because the container type is excluded.

This is useful for container types that don't own their data, such as view types
where modification of the returned references in other places cannot be reliably
tracked, or const incorrect types.

Differential Revision: https://reviews.llvm.org/D106173

Reviewed-by: ymandel

show more ...


# 00edae92 14-Jul-2021 Felix Berger <flx@google.com>

[clang-tidy] performance-unnecessary-copy-initialization: Disable check when variable and initializer have different replaced template param types.

This can happen when a template with two parameter

[clang-tidy] performance-unnecessary-copy-initialization: Disable check when variable and initializer have different replaced template param types.

This can happen when a template with two parameter types is instantiated with a
single type. The fix would only be valid for this instantiation but fail for
others that rely on an implicit type conversion.

The test cases illustrate when the check should trigger and when not.

Differential Revision: https://reviews.llvm.org/D106011

show more ...


# 0ec81202 09-Jul-2021 Felix Berger <flx@google.com>

[clang-tidy] performance-unnecessary-copy-initialization: Do not remove comments on new lines.

When deleting the copy assignment statement because copied variable is not used
only remove trailing co

[clang-tidy] performance-unnecessary-copy-initialization: Do not remove comments on new lines.

When deleting the copy assignment statement because copied variable is not used
only remove trailing comments on the same line.

Differential Revision: https://reviews.llvm.org/D105734

Reviewed-by: ymandel

show more ...


# 187e050b 09-Jul-2021 Felix Berger <flx@google.com>

[clang-tidy] performance-unnecessary-copy-initialization: Disable structured bindings.

Structured bindings can currently trigger the check and lead to a wrong
fix. Because the DecompositionDecl itse

[clang-tidy] performance-unnecessary-copy-initialization: Disable structured bindings.

Structured bindings can currently trigger the check and lead to a wrong
fix. Because the DecompositionDecl itself is not used and the check does not
iterate through its the decl's bindings to verify whether the bindings' holding
vars are used this leads to the whole statement to be deleted.

To support structured bindings properly 3 cases would need to be considered.

1. All holding vars are not used -> The statement can be deleted.
2. All holding vars are used as const or not used -> auto can be converted to const auto&.
3. Neither case is true -> leave unchanged.

In the check we'll have to separate the logic that determines this from the code
that produces the diagnostic and fixes and first determine which of the cases
we're dealing with before creating fixes.

Since this is a bigger refactoring we'll disable structured bindings for now to
prevent incorrect fixes.

Differential Revision: https://reviews.llvm.org/D105727

Reviewed-by: ymandel

show more ...


Revision tags: llvmorg-12.0.1, llvmorg-12.0.1-rc4, llvmorg-12.0.1-rc3, llvmorg-12.0.1-rc2, llvmorg-12.0.1-rc1
# bdd5da9d 24-May-2021 Felix Berger <flx@google.com>

[clang-tidy] performance-unnecessary-copy-initialization: Directly examine the initializing var's initializer.

This fixes false positive cases where a reference is initialized outside of a
block sta

[clang-tidy] performance-unnecessary-copy-initialization: Directly examine the initializing var's initializer.

This fixes false positive cases where a reference is initialized outside of a
block statement and then its initializing variable is modified. Another case is
when the looped over container is modified.

Differential Revision: https://reviews.llvm.org/D103021

Reviewed-by: ymandel

show more ...


# efa4dbc3 24-May-2021 Felix Berger <flx@google.com>

[clang-tidy] performance-unnecessary-copy-initialization: Look at the canonical type when checking for aliases.

This fixes a false positive case where for instance a pointer is obtained and declared

[clang-tidy] performance-unnecessary-copy-initialization: Look at the canonical type when checking for aliases.

This fixes a false positive case where for instance a pointer is obtained and declared using `auto`.

Differential Revision: https://reviews.llvm.org/D103018

Reviewed-by: ymandel

show more ...


# 5dbe3bf4 10-May-2021 Felix Berger <flx@google.com>

[clang-tidy] performance-unnecessary-copy-initialization: Remove the complete statement when the copied variable is unused.

It is not useful to keep the statement around and can lead to compiler
war

[clang-tidy] performance-unnecessary-copy-initialization: Remove the complete statement when the copied variable is unused.

It is not useful to keep the statement around and can lead to compiler
warnings when -Wall (-Wunused-variable specifically) turned on.

Differential Revision: https://reviews.llvm.org/D102175

Reviewed-by: ymandel

show more ...


Revision tags: llvmorg-12.0.0, llvmorg-12.0.0-rc5, llvmorg-12.0.0-rc4, llvmorg-12.0.0-rc3
# 1a721b6a 26-Feb-2021 Nathan James <n.james93@hotmail.co.uk>

[clang-tidy][NFC] Tweak some generation of diag messages

Fix up cases where diag is called by piecing together a string in favour of placeholders.
Fix up cases where select could be used instead of

[clang-tidy][NFC] Tweak some generation of diag messages

Fix up cases where diag is called by piecing together a string in favour of placeholders.
Fix up cases where select could be used instead of duplicating the message for sake of 1 word difference.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D97488

show more ...


12