================ @@ -241,7 +242,21 @@ CapabilityExpr SExprBuilder::translateAttrExpr(const Expr *AttrExp, return CapabilityExpr(E, AttrExp->getType(), Neg); } -til::LiteralPtr *SExprBuilder::createVariable(const VarDecl *VD) { +til::SExpr *SExprBuilder::translateVarDecl(const VarDecl *VD, + CallingContext *Ctx) { + assert(VD); + // Substitute local pointer variables with their initializers if they are + // explicitly const or never reassigned. + QualType Ty = VD->getType(); + if (Ty->isPointerType() && VD->hasInit() && !isVariableReassigned(VD)) { + const Expr *Init = VD->getInit()->IgnoreParenImpCasts(); + // Check for self-initialization to prevent infinite recursion. ---------------- melver wrote:
No, but it's legal C & C++ code, and if this isn't handled the compiler crashes (or never terminates) per the test I added for this. I'm now handling it in isVariableReassigned - this looks more robust. https://github.com/llvm/llvm-project/pull/142955 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits