[clang-tools-extra] [clang-tidy] Add `modernize-use-as-const` check (PR #210554)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 27 08:23:38 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/modernize/UseAsConstCheck.cpp clang-tools-extra/clang-tidy/modernize/UseAsConstCheck.h clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.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/modernize/UseAsConstCheck.cpp:51:3: warning: variable 'Pointee' of type 'QualType' can be declared 'const' [misc-const-correctness]
   51 |   QualType Pointee = RefType->getPointeeType();
      |   ^
      |            const 
clang-tools-extra/clang-tidy/modernize/UseAsConstCheck.cpp:66:3: warning: variable 'SubType' of type 'QualType' can be declared 'const' [misc-const-correctness]
   66 |   QualType SubType = Sub->getType();
      |   ^
      |            const 
clang-tools-extra/clang-tidy/modernize/UseAsConstCheck.cpp:68:8: warning: static member accessed through instance [readability-static-accessed-through-instance]
   68 |       !Ctx.hasSameType(Pointee, SubType.withConst()))
      |        ^~~~
      |        clang::ASTContext::
```

</details>


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


More information about the cfe-commits mailing list