[PATCH] D72217: [clang-tidy] Added readability-qualified-auto check
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 8 18:33:43 PST 2020
njames93 added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp:94-95
+ auto Pointee = QType.getTypePtr()->getPointeeType();
+ if (Pointee.isNull())
+ return Pointee.isLocalConstQualified();
+ return Pointee.isConstQualified();
----------------
njames93 wrote:
> aaron.ballman wrote:
> > Can you explain why this code is needed? If the pointee is null, there's been some sort of error, I believe.
> >
> > I am not certain this function is needed, I think `QType->getPointeeType().isConstQualified()` likely suffices.
> Well it kept crashing without that check so I need to do some more digging on that front
Figured it out, its when the type deduced from auto is a dependant template type, getting the desugarded type is working atm, but I dont know the ast well enough to be sure thats the correct method
================
Comment at: clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp:159
+void QualifiedAutoCheck::check(const MatchFinder::MatchResult &Result) {
+ if (auto Var = Result.Nodes.getNodeAs<VarDecl>("auto")) {
+ bool IsPtrConst = isPointerConst(Var->getType());
----------------
njames93 wrote:
> Eugene.Zelenko wrote:
> > aaron.ballman wrote:
> > > `auto *`
> > This would be nice test for check.
> I feel like this is what the face-palm emoji is for. I should've pointed that run clang tidy script at clang-tools-extra
that wont happen again now :D [[ https://imgur.com/a/YNQoH7c | Idiot proof ]]
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72217/new/
https://reviews.llvm.org/D72217
More information about the cfe-commits
mailing list