[clang] [clang][nullability] Don't discard expression state before end of full-expression. (PR #82611)

Yitzhak Mandelbaum via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 1 11:47:56 PST 2024


================
@@ -94,6 +94,36 @@ static llvm::BitVector findReachableBlocks(const CFG &Cfg) {
   return BlockReachable;
 }
 
+static llvm::DenseSet<const CFGBlock *>
+buildContainsExprConsumedInDifferentBlock(
+    const CFG &Cfg,
+    const llvm::DenseMap<const Stmt *, const CFGBlock *> &StmtToBlock) {
+  llvm::DenseSet<const CFGBlock *> Result;
+
+  auto CheckChildExprs = [&Result, &StmtToBlock](const Stmt *S,
+                                                 const CFGBlock *Block) {
+    for (const Stmt *Child : S->children()) {
+      const CFGBlock *ChildBlock = StmtToBlock.lookup(Child);
+      if (isa<Expr>(Child) && ChildBlock != Block)
----------------
ymand wrote:

nit: check `isa<Expr>` before the lookup? avoids the extra lookup when it's not an expression.

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


More information about the cfe-commits mailing list