[clang] [alpha.webkit.UncountedLocalVarsChecker] Allow uncounted object references within trivial statements (PR #82229)
Ryosuke Niwa via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 6 22:10:14 PST 2024
================
@@ -305,19 +337,21 @@ class TrivialFunctionAnalysisVisitor
}
bool VisitDeclRefExpr(const DeclRefExpr *DRE) {
- if (auto *decl = DRE->getDecl()) {
- if (isa<ParmVarDecl>(decl))
- return true;
- if (isa<EnumConstantDecl>(decl))
- return true;
- if (auto *VD = dyn_cast<VarDecl>(decl)) {
- if (VD->hasConstantInitialization() && VD->getEvaluatedValue())
+ return WithCachedResult(DRE, [&]() {
+ if (auto *decl = DRE->getDecl()) {
+ if (isa<ParmVarDecl>(decl))
return true;
- auto *Init = VD->getInit();
- return !Init || Visit(Init);
+ if (isa<EnumConstantDecl>(decl))
+ return true;
+ if (auto *VD = dyn_cast<VarDecl>(decl)) {
+ if (VD->hasConstantInitialization() && VD->getEvaluatedValue())
+ return true;
+ auto *Init = VD->getInit();
+ return !Init || Visit(Init);
----------------
rniwa wrote:
Oh, that is a very good point. I guess we can just always `return true` for `DeclRefExpr`.
https://github.com/llvm/llvm-project/pull/82229
More information about the cfe-commits
mailing list