[clang] [analyzer] Fix StackAddrEscapeChecker crash on temporary object fields (PR #66493)

via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 15 05:53:25 PDT 2023


================
@@ -398,7 +400,7 @@ void StackAddrEscapeChecker::checkEndFunction(const ReturnStmt *RS,
     }(Referrer->getMemorySpace());
 
     // This cast supposed to succeed.
----------------
DonatNagyE wrote:

I think the best would be either a comment that explains _why_ we expect a `VarRegion` here (e.g. it's already checked in function `fooBar()` etc.) or if possible, then a crash-less logic (converting an earlier `isa`-like check + this `cast` into a single `getAs`).

I don't think that we should add defensive/paranoid checks; if this logic is broken by some change in the distant future, then a fixable crash is better than silent degradation. 

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


More information about the cfe-commits mailing list