History log of /llvm-project/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp (Results 1 – 25 of 102)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-18.1.8
# c4f83a00 07-Jun-2024 Congcong Cai <congcongcai0907@163.com>

[clang-tidy] new check misc-use-internal-linkage (#90830)

Add new check misc-use-internal-linkage to detect variable and function
can be marked as static.

---------

Co-authored-by: Danny Mösch <da

[clang-tidy] new check misc-use-internal-linkage (#90830)

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>

show more ...


Revision tags: llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4
# 31512811 17-Oct-2023 Utkarsh Saxena <usaxena95@gmail.com>

[clang-tidy] Add check to diagnose coroutine-hostile RAII objects (#68738)

This check detects **hostile-RAII** objects which should not **persist
across a suspension point in a coroutine**.

Some

[clang-tidy] Add check to diagnose coroutine-hostile RAII objects (#68738)

This check detects **hostile-RAII** objects which should not **persist
across a suspension point in a coroutine**.

Some objects require that they be destroyed on the same thread that
created them. Traditionally this requirement was often phrased as "must
be a local variable", under the assumption that local variables always
work this way. However this is incorrect with **C++20 coroutines**,
since an intervening `co_await` may cause the coroutine to suspend and
later be resumed on another thread.

The lifetime of an object that requires being destroyed on the same
thread must not encompass a `co_await` or `co_yield` point. If you
create/destroy an object, you must do so without allowing the coroutine
to suspend in the meantime.

The check considers the following type as hostile:

- **Scoped-lockable types**: A scoped-lockable object persisting across
a suspension point is problematic as the lock held by this object could
be unlocked by a different thread. This would be undefined behaviour.

- Types belonging to a configurable **denylist**.

```cpp
// Call some async API while holding a lock.
const my::MutexLock l(&mu_);

// Oops! The async Bar function may finish on a different
// thread from the one that created the MutexLock object and therefore called
// Mutex::Lock -- now Mutex::Unlock will be called on the wrong thread.
co_await Bar();
```

show more ...


Revision tags: llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init
# 7f6e0052 24-Jun-2023 Piotr Zegar <piotr.zegar@nokia.com>

[clang-tidy] Add misc-header-include-cycle check

Check detects cyclic #include dependencies between user-defined headers.

Reviewed By: njames93

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

[clang-tidy] Add misc-header-include-cycle check

Check detects cyclic #include dependencies between user-defined headers.

Reviewed By: njames93

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

show more ...


# 071b129b 24-Jun-2023 Piotr Zegar <me@piotrzegar.pl>

Revert "[clang-tidy] Add misc-header-include-cycle check"

This reverts commit f3aa6cc0f5d56752242203c2a9231c1bc230c15e.


# f3aa6cc0 24-Jun-2023 Piotr Zegar <piotr.zegar@nokia.com>

[clang-tidy] Add misc-header-include-cycle check

Check detects cyclic #include dependencies between user-defined headers.

Reviewed By: njames93

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

[clang-tidy] Add misc-header-include-cycle check

Check detects cyclic #include dependencies between user-defined headers.

Reviewed By: njames93

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

show more ...


Revision tags: llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3
# c28506ba 19-Apr-2023 Viktoriia Bakalova <bakalova@google.com>

[clang-tidy] Implement an include-cleaner check.

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


Revision tags: llvmorg-16.0.2
# 26e164fa 15-Apr-2023 Piotr Zegar <me@piotrzegar.pl>

Revert "[clang-tidy] Add misc-header-include-cycle check"

This reverts commit 9ece8753d5e6f49c31c2d988ef69225c036b25e0.


# 9ece8753 15-Apr-2023 Piotr Zegar <piotr.zegar@nokia.com>

[clang-tidy] Add misc-header-include-cycle check

Check detects cyclic #include dependencies between user-defined headers.

Reviewed By: njames93

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

[clang-tidy] Add misc-header-include-cycle check

Check detects cyclic #include dependencies between user-defined headers.

Reviewed By: njames93

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

show more ...


Revision tags: 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, llvmorg-15.0.6, llvmorg-15.0.5
# 65d6d67f 03-Nov-2022 Carlos Galvez <carlosgalvezp@gmail.com>

[clang-tidy] Add misc-use-anonymous-namespace check

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


Revision tags: 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, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init
# 46ae26e7 24-Jul-2022 Jonas Toth <development@jonas-toth.eu>

[clang-tidy] implement new check 'misc-const-correctness' to add 'const' to unmodified variables

This patch connects the check for const-correctness with the new general
utility to add `const` to va

[clang-tidy] implement new check 'misc-const-correctness' to add 'const' to unmodified variables

This patch connects the check for const-correctness with the new general
utility to add `const` to variables.
The code-transformation is only done, if the detected variable for const-ness
is not part of a group-declaration.

The check allows to control multiple facets of adding `const`, e.g. if pointers themself should be
marked as `const` if they are not changed.

Reviewed By: njames93

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

show more ...


Revision tags: llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4, 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
# c3574ef7 15-Oct-2021 serge-sans-paille <sguelton@redhat.com>

[clang-tidy] Confusable identifiers detection

Detect identifiers that are confusable using a variant of Unicode definition

http://www.unicode.org/reports/tr39/#Confusable_Detection

and hav

[clang-tidy] Confusable identifiers detection

Detect identifiers that are confusable using a variant of Unicode definition

http://www.unicode.org/reports/tr39/#Confusable_Detection

and have conflicting scopes.

This a recommit (with portability and feature fixes) of b94db7ed7eaf4a3b21f600653a09c55cab77b79f

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

show more ...


# 371e6f8b 03-Jun-2022 Nico Weber <thakis@chromium.org>

Revert "[clang-tidy] Confusable identifiers detection"

This reverts commit b94db7ed7eaf4a3b21f600653a09c55cab77b79f.
See comments on https://reviews.llvm.org/D112916:
- breaks `check-clangd`, and ma

Revert "[clang-tidy] Confusable identifiers detection"

This reverts commit b94db7ed7eaf4a3b21f600653a09c55cab77b79f.
See comments on https://reviews.llvm.org/D112916:
- breaks `check-clangd`, and makes clang-tidy crash on simple inputs
- likely does the wrong thing in cross builds

Also revert follow-up "[gn build] (manually) port b94db7ed7eaf (Confusables.inc)"
This reverts commit 180bae08a04d4dc724cb5e6f2ea9df8641a3f657.

show more ...


# b94db7ed 15-Oct-2021 serge-sans-paille <sguelton@redhat.com>

[clang-tidy] Confusable identifiers detection

Detect identifiers that are confusable according to Unicode definition

http://www.unicode.org/reports/tr39/#Confusable_Detection

and have conf

[clang-tidy] Confusable identifiers detection

Detect identifiers that are confusable according to Unicode definition

http://www.unicode.org/reports/tr39/#Confusable_Detection

and have conflicting scopes.

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

show more ...


# 35cca45b 28-Sep-2021 serge-sans-paille <sguelton@redhat.com>

Misleading bidirectional detection

This patch implements detection of incomplete bidirectional sequence withing
comments and string literals within clang-tidy.

It detects the bidi part of https://w

Misleading bidirectional detection

This patch implements detection of incomplete bidirectional sequence withing
comments and string literals within clang-tidy.

It detects the bidi part of https://www.trojansource.codes/trojan-source.pdf

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

show more ...


# a35efc4d 15-Oct-2021 serge-sans-paille <sguelton@redhat.com>

Misleading unicode identifier detection pass

Detect when an identifier contains some Right-To-Left characters.
This pass relates to https://trojansource.codes/

Example of misleading source:

sh

Misleading unicode identifier detection pass

Detect when an identifier contains some Right-To-Left characters.
This pass relates to https://trojansource.codes/

Example of misleading source:

short int א = (short int)0;
short int ג = (short int)12345;

int main() {
int א = ג; // a local variable, set to zero?
printf("ג is %d\n", ג);
printf("א is %d\n", א);
}

This is a recommit of 299aa4dfa1d8c120648b1404b481d858b76c8173 with missing
option registration fixed.

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

show more ...


# c178ada3 09-Nov-2021 serge-sans-paille <sguelton@redhat.com>

Revert "Misleading unicode identifier detection pass"

This reverts commit 7f92a1a84b96ff0b7568a35704c9483e9f24f057.

It triggers an assert, see http://45.33.8.238/linux/60293/step_9.txt

"AST/Decl.h

Revert "Misleading unicode identifier detection pass"

This reverts commit 7f92a1a84b96ff0b7568a35704c9483e9f24f057.

It triggers an assert, see http://45.33.8.238/linux/60293/step_9.txt

"AST/Decl.h:277: llvm::StringRef clang::NamedDecl::getName() const: Assertion `Name.isIdentifier() && "Name is not a simple identifier"' failed."

show more ...


# 7f92a1a8 15-Oct-2021 serge-sans-paille <sguelton@redhat.com>

Misleading unicode identifier detection pass

Detect when an identifier contains some Right-To-Left characters.
This pass relates to https://trojansource.codes/

This is a recommit of 299aa4dfa1d8c12

Misleading unicode identifier detection pass

Detect when an identifier contains some Right-To-Left characters.
This pass relates to https://trojansource.codes/

This is a recommit of 299aa4dfa1d8c120648b1404b481d858b76c8173 with missing
option registration fixed.

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

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, llvmorg-12.0.1, llvmorg-12.0.1-rc4, llvmorg-12.0.1-rc3, llvmorg-12.0.1-rc2, llvmorg-12.0.1-rc1, llvmorg-12.0.0, llvmorg-12.0.0-rc5, llvmorg-12.0.0-rc4, llvmorg-12.0.0-rc3, llvmorg-12.0.0-rc2, llvmorg-11.1.0, llvmorg-11.1.0-rc3, llvmorg-12.0.0-rc1, llvmorg-13-init, llvmorg-11.1.0-rc2, llvmorg-11.1.0-rc1, llvmorg-11.0.1, llvmorg-11.0.1-rc2, llvmorg-11.0.1-rc1, llvmorg-11.0.0, llvmorg-11.0.0-rc6, llvmorg-11.0.0-rc5, llvmorg-11.0.0-rc4, llvmorg-11.0.0-rc3, llvmorg-11.0.0-rc2, llvmorg-11.0.0-rc1, llvmorg-12-init, llvmorg-10.0.1, llvmorg-10.0.1-rc4, llvmorg-10.0.1-rc3, llvmorg-10.0.1-rc2, llvmorg-10.0.1-rc1, llvmorg-10.0.0, llvmorg-10.0.0-rc6, llvmorg-10.0.0-rc5, llvmorg-10.0.0-rc4, llvmorg-10.0.0-rc3
# 49bffa5f 13-Feb-2020 Roman Lebedev <lebedev.ri@gmail.com>

[clang-tidy] misc-no-recursion: a new check

Summary:
Recursion is a powerful tool, but like any tool
without care it can be dangerous. For example,
if the recursion is unbounded, you will
eventually

[clang-tidy] misc-no-recursion: a new check

Summary:
Recursion is a powerful tool, but like any tool
without care it can be dangerous. For example,
if the recursion is unbounded, you will
eventually run out of stack and crash.

You can of course track the recursion depth
but if it is hardcoded, there can always be some
other environment when that depth is too large,
so said magic number would need to be env-dependent.
But then your program's behavior is suddenly more env-dependent.

Also, recursion, while it does not outright stop optimization,
recursive calls are less great than normal calls,
for example they hinder inlining.

Recursion is banned in some coding guidelines:
* SEI CERT DCL56-CPP. Avoid cycles during initialization of static objects
* JPL 2.4 Do not use direct or indirect recursion.
* I'd say it is frowned upon in LLVM, although not banned
And is plain unsupported in some cases:
* OpenCL 1.2, 6.9 Restrictions: i. Recursion is not supported.

So there's clearly a lot of reasons why one might want to
avoid recursion, and replace it with worklist handling.
It would be great to have a enforcement for it though.

This implements such a check.
Here we detect both direct and indirect recursive calls,
although since clang-tidy (unlike clang static analyzer)
is CTU-unaware, if the recursion transcends a single standalone TU,
we will naturally not find it :/

The algorithm is pretty straight-forward:
1. Build call-graph for the entire TU.
For that, the existing `clang::CallGraph` is re-used,
although it had to be modified to also track the location of the call.
2. Then, the hard problem: how do we detect recursion?
Since we have a graph, let's just do the sane thing,
and look for Strongly Connected Function Declarations - widely known as `SCC`.
For that LLVM provides `llvm::scc_iterator`,
which is internally an Tarjan's DFS algorithm, and is used throught LLVM,
so this should be as performant as possible.
3. Now that we've got SCC's, we discard those that don't contain loops.
Note that there may be more than one loop in SCC!
4. For each loopy SCC, we call out each function, and print a single example
call graph that shows recursion -- it didn't seem worthwhile enumerating
every possible loop in SCC, although i suppose it could be implemented.
* To come up with that call graph cycle example, we start at first SCC node,
see which callee of the node is within SCC (and is thus known to be in cycle),
and recurse into it until we hit the callee that is already in call stack.

Reviewers: JonasToth, aaron.ballman, ffrankies, Eugene.Zelenko, erichkeane, NoQ

Reviewed By: aaron.ballman

Subscribers: Charusso, Naghasan, bader, riccibruno, mgorny, Anastasia, xazax.hun, cfe-commits

Tags: #llvm, #clang

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

show more ...


Revision tags: llvmorg-10.0.0-rc2, llvmorg-10.0.0-rc1, llvmorg-11-init, llvmorg-9.0.1, llvmorg-9.0.1-rc3, llvmorg-9.0.1-rc2, llvmorg-9.0.1-rc1, llvmorg-9.0.0, llvmorg-9.0.0-rc6, llvmorg-9.0.0-rc5, llvmorg-9.0.0-rc4, llvmorg-9.0.0-rc3, llvmorg-9.0.0-rc2, llvmorg-9.0.0-rc1, llvmorg-10-init, llvmorg-8.0.1, llvmorg-8.0.1-rc4, llvmorg-8.0.1-rc3, llvmorg-8.0.1-rc2, llvmorg-8.0.1-rc1, llvmorg-8.0.0, llvmorg-8.0.0-rc5, llvmorg-8.0.0-rc4, llvmorg-8.0.0-rc3, llvmorg-7.1.0, llvmorg-7.1.0-rc1, llvmorg-8.0.0-rc2, llvmorg-8.0.0-rc1
# 2946cd70 19-Jan-2019 Chandler Carruth <chandlerc@gmail.com>

Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the ne

Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636

show more ...


Revision tags: llvmorg-7.0.1, llvmorg-7.0.1-rc3, llvmorg-7.0.1-rc2, llvmorg-7.0.1-rc1
# 6cfa38f1 18-Oct-2018 Roman Lebedev <lebedev.ri@gmail.com>

[clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP)

Summary:
Finds classes that not only contain the data (non-static member variables),
but also have logic (non-s

[clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP)

Summary:
Finds classes that not only contain the data (non-static member variables),
but also have logic (non-static member functions), and diagnoses all member
variables that have any other scope other than `private`. They should be
made `private`, and manipulated exclusively via the member functions.

Optionally, classes with all member variables being `public` could be
ignored, and optionally all `public` member variables could be ignored.

Options
-------

* IgnoreClassesWithAllMemberVariablesBeingPublic

Allows to completely ignore classes if **all** the member variables in that
class have `public` visibility.

* IgnorePublicMemberVariables

Allows to ignore (not diagnose) **all** the member variables with `public`
visibility scope.

References:
* MISRA 11-0-1 Member data in non-POD class types shall be private.
* https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c2-use-class-if-the-class-has-an-invariant-use-struct-if-the-data-members-can-vary-independently
* https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rc-private
* https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-protected

Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun

Reviewed By: aaron.ballman

Subscribers: Eugene.Zelenko, zinovy.nis, cfe-commits, rnkovacs, nemanjai, mgorny, xazax.hun, kbarton

Tags: #clang-tools-extra

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

llvm-svn: 344757

show more ...


# 04d38c5f 20-Sep-2018 Eugene Zelenko <eugene.zelenko@gmail.com>

[Clang-tidy] Alphabetical sort of files/checks. Add space after clang-tidy in source code headers.

llvm-svn: 342601


Revision tags: llvmorg-7.0.0, llvmorg-7.0.0-rc3, llvmorg-7.0.0-rc2, llvmorg-7.0.0-rc1, llvmorg-6.0.1, llvmorg-6.0.1-rc3, llvmorg-6.0.1-rc2, llvmorg-6.0.1-rc1, llvmorg-5.0.2, llvmorg-5.0.2-rc2, llvmorg-5.0.2-rc1
# 67112853 15-Mar-2018 Alexander Kornienko <alexfh@google.com>

[clang-tidy] rename_check.py misc-unused-raii bugprone-unused-raii --check_class_name=UnusedRAIICheck

llvm-svn: 327610


# 68fb65f4 15-Mar-2018 Alexander Kornienko <alexfh@google.com>

[clang-tidy] rename_check.py misc-sizeof-container bugprone-sizeof-container

llvm-svn: 327608


# 32738885 15-Mar-2018 Alexander Kornienko <alexfh@google.com>

[clang-tidy] rename_check.py misc-sizeof-expression bugprone-sizeof-expression

llvm-svn: 327607


12345