================
@@ -398,7 +400,7 @@ void StackAddrEscapeChecker::checkEndFunction(const 
ReturnStmt *RS,
     }(Referrer->getMemorySpace());
 
     // This cast supposed to succeed.
----------------
steakhal 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`).

There is nothing that would directly imply this.
It's like, ATM I don't know of any other situations where it could be not a 
`VarRegion`, and so far it didn't appear in practice that would disprove this.

I'm not exactly sure if a comment like that would suffice. Would you accept it? 
And do you think it's necessary?

Another alternative could be a combination:

```c++
if (!isa<VarRegion>(Referrer)) {
  assert(false && "We should really only have VarRegions here");
  continue;
}
// ...
cast<VarRegion>(Referrer)...
```

https://github.com/llvm/llvm-project/pull/66493
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to