[PATCH] D123655: [clang-tidy] Add portability-std-allocator-const-t check
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 13 13:27:49 PDT 2022
MaskRay added inline comments.
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp:76
+void temp() {
+ std::vector<const T> v;
+ // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
----------------
sammccall wrote:
> This case will always be an error, but isn't diagnosed until you see an instantiation.
>
> If it's important to catch these standalone e.g. when analyzing headers, you could adapt the matcher like:
>
> ```
> hasUnqualifiedDesugaredType(anyOf(
> recordDecl(...), // current case
> templateSpecializationType( // when dependent, TST is canonical
> templateArgumentCountIs(1), // std::vector<const dependent>
> hasTemplateArgument(0, refersToType(qualType(isConstQualified())))
> )
> ))
> ```
Thanks for Sam's offline help! Incorporated this to the matcher.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123655/new/
https://reviews.llvm.org/D123655
More information about the cfe-commits
mailing list