[clang] Fix: Issue #165239 — resolve -Wuninitialized warnings (PR #166991)

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 8 05:26:29 PST 2025


================
@@ -661,8 +711,23 @@ class TransferFunctions : public StmtVisitor<TransferFunctions> {
 
 } // namespace
 
-void TransferFunctions::reportUse(const Expr *ex, const VarDecl *vd) {
+void TransferFunctions::VisitArraySubscriptExpr(ArraySubscriptExpr *ASE) {  
+  // Handle array subscript expressions like arr[i]
+  // Check if the base array variable is uninitialized
+  FindVarResult Var = findVar(ASE->getBase());
+  
+  if (const VarDecl *VD = Var.getDecl()) {
+    if (VD->getType()->isArrayType())
+      reportUse(ASE, VD);
+  }
+  
+  // Also visit index expression
+  Visit(ASE->getIdx());
+}
+
+void TransferFunctions::reportUse(const Expr *ex, const VarDecl *vd) {  
   Value v = vals[vd];
+  
----------------
zwuis wrote:

Unrelated changes?

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


More information about the cfe-commits mailing list