[clang-tools-extra] [clang-tidy] Add `readability-redundant-tag` check (PR #210007)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 16 04:26:01 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE LINT COMMENT: clang-tidy-->


:warning: C/C++ code linter, clang-tidy found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

```bash

git diff -U0 origin/main...HEAD -- clang-tools-extra/clang-tidy/readability/RedundantTagCheck.cpp clang-tools-extra/clang-tidy/readability/RedundantTagCheck.h clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp |
python3 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py   -path build -p1 -quiet
```

</details>

<details>
<summary>
View the output from clang-tidy here.
</summary>

```
clang-tools-extra/clang-tidy/readability/RedundantTagCheck.cpp:24:13: warning: place static function 'canHideTag' outside of an anonymous namespace [llvm-prefer-static-over-anonymous-namespace]
   24 | static bool canHideTag(const NamedDecl *D) {
      |             ^
clang-tools-extra/clang-tidy/readability/RedundantTagCheck.cpp:62:8: warning: pointee of variable 'ND' of type 'NamedDecl *' can be declared 'const' [misc-const-correctness]
   62 |   for (NamedDecl *ND : Lookup) {
      |        ^
      |                   const
clang-tools-extra/clang-tidy/readability/RedundantTagCheck.cpp:70:3: warning: variable 'KeywordLoc' of type 'SourceLocation' can be declared 'const' [misc-const-correctness]
   70 |   SourceLocation KeywordLoc = TagTL.getElaboratedKeywordLoc();
      |   ^
      |                  const 
clang-tools-extra/clang-tidy/readability/RedundantTagCheck.cpp:80:3: warning: variable 'Keyword' of type 'llvm::StringRef' can be declared 'const' [misc-const-correctness]
   80 |   llvm::StringRef Keyword = Tok.getRawIdentifier();
      |   ^
      |                   const
```

</details>


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


More information about the cfe-commits mailing list