[clang] [analyzer] Detect leaks of stack addresses via output params, indirect globals 3/3 (PR #105648)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 27 07:34:40 PDT 2024


================
@@ -348,12 +357,27 @@ void StackAddrEscapeChecker::checkEndFunction(const ReturnStmt *RS,
 
   ExplodedNode *Node = Ctx.getPredecessor();
 
+  bool ExitingTopFrame =
+      Ctx.getPredecessor()->getLocationContext()->inTopFrame();
+
+  if (ExitingTopFrame && Node->getLocation().getTag() &&
+      Node->getLocation().getTag()->getTagDescription() ==
----------------
steakhal wrote:

Yea, it's not pretty. However, the string comparison only happens if we are leaving the top-level entry point, which happens once per entry point, so performance shouldn't be an issue here.

Factoring out the clean node construction from the ExprEngine seems like a tangential effort with limited benefits.
I'd say let's keep it as-is.

What we should make sure though, is to have a test for this branch of code. That would guard the condition to never get stale. I think we already have tests for this purpose.

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


More information about the cfe-commits mailing list