[clang-tools-extra] [clang-tidy] Option to ignore anonymous namespaces in avoid-non-const-global-variables (PR #93827)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 15 03:56:48 PDT 2024


================

----------------
5chmidti wrote:

FYI: You could remove the explicit check-nots here:

```c++
// RUN: %check_clang_tidy %s -check-suffixes=,INTERNAL-LINKAGE cppcoreguidelines-avoid-non-const-global-variables %t
// RUN: %check_clang_tidy %s cppcoreguidelines-avoid-non-const-global-variables %t -- \
// RUN: -config="{CheckOptions: {cppcoreguidelines-avoid-non-const-global-variables.AllowInternalLinkage : 'true'}}"


namespace {
int nonConstAnonymousNamespaceInt = 0;
// CHECK-MESSAGES-INTERNAL-LINKAGE: :[[@LINE-1]]:5: warning: variable 'nonConstAnonymousNamespaceInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
} // namespace
```

(There are also two check-nots where the line is off by one)

https://github.com/llvm/llvm-project/pull/93827


More information about the cfe-commits mailing list