Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang-tidy] Add AllowedTypes option to misc-const-correctness #122592

Open
vbvictor opened this issue Jan 11, 2025 · 5 comments
Open

[clang-tidy] Add AllowedTypes option to misc-const-correctness #122592

vbvictor opened this issue Jan 11, 2025 · 5 comments

Comments

@vbvictor
Copy link

Sometimes in large codebases we want to ignore const-correctness of certain classes because they are immutable by nature, so there is no point in adding const to them.
Minimal example:

#include <mutex>

int main() {
  std::mutex m;
  std::lock_guard<std::mutex> l(m); // check is triggered but we want to ignore it since lock_guard is already immutable.
}

Writing NOLINT for thousands of places bloats code and is not an appealing option.

@llvmbot
Copy link
Member

llvmbot commented Jan 11, 2025

@llvm/issue-subscribers-clang-tidy

Author: Baranov Victor (vbvictor)

Sometimes in large codebases we want to ignore const-correctness of certain classes because they are immutable by nature, so there is no point in adding const to them. Minimal example:
#include &lt;mutex&gt;

int main() {
  std::mutex m;
  std::lock_guard&lt;std::mutex&gt; l(m); // check is triggered but we want to ignore it since lock_guard is already immutable.
}

Writing NOLINT for thousands of places bloats code and is not an appealing option.

@vbvictor
Copy link
Author

Can this issue be assigned to me if it is a good improvement

@firewave
Copy link

There is #58084 which is somewhat related by adding an option to only report it for POD types.

@vbvictor
Copy link
Author

There is #58084 which is somewhat related by adding an option to only report it for POD types.

This option may help with my particular case with std::lock_guard however, I think narrowing to POD types may be too strict for some users, including me.

@vbvictor vbvictor changed the title [clang-tidy] Add ClassIgnoreList option to misc-const-correctness [clang-tidy] Add AllowedTypes option to misc-const-correctness Jan 11, 2025
@firewave
Copy link

This option may help with my particular case with std::lock_guard however, I think narrowing to POD types may be too strict for some users, including me.

See all my notes in the other ticket what the actual intention is. The title is a bit misleading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants