================
@@ -331,6 +336,26 @@ static const DeclRefExpr *getSelfInitExpr(VarDecl *VD) {
void ClassifyRefs::classify(const Expr *E, Class C) {
// The result of a ?: could also be an lvalue.
E = E->IgnoreParens();
+
+ // Handle array subscripts - THE KEY FIX
+ if (const auto *ASE = dyn_cast<ArraySubscriptExpr>(E)) {
+ // For ANY array subscript expression, the base array is being USED
+ // This is the critical fix - don't check C, just mark as Use
+ FindVarResult Var = findVar(ASE->getBase(), DC);
+ if (const VarDecl *VD = Var.getDecl()) {
+ if (VD->getType()->isArrayType()) {
+ // Directly mark the array DeclRefExpr as Use
+ if (const DeclRefExpr *DRE = Var.getDeclRefExpr())
+ Classification[DRE] = Use;
+ }
+ }
+
+ // Process base and index normally
+ classify(ASE->getBase(), C);
+ Visit(const_cast<Expr*>(ASE->getIdx()));
----------------
zwuis wrote:
You should not call `Visit`. All sub-expressions will be visited by
`StmtVisitor`. Ditto elsewhere.
https://github.com/llvm/llvm-project/pull/166991
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits