================
@@ -620,6 +620,21 @@ void ExprEngine::VisitDeclStmt(const DeclStmt *DS,
ExplodedNode *Pred,
return;
}
+ // Self-assignment initialization in variable declaration,
+ // i.e., `int x = x;`,
+ // is a C idiom to suppress warnings of unused variables.
+ // This filter will not match variables of C++ record types, but will match
+ // C++ references. Allow references continuing here to make the undefined
+ // value checker report self-assignments of C++ references.
+ if (const Expr *EI = VD->getInit()) {
+ if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(EI->IgnoreImpCasts()))
----------------
Snape3058 wrote:
I don't know. But my impression is that since `T v = v;` works, developers are
less likely to elaborate to add a pair of parentheses, unless required by their
coding style. Adding is also ok to me, if you think that's very necessary.
https://github.com/llvm/llvm-project/pull/187530
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits