From b9b794d60b18163b0ef1f9fcff1649ab155ce211 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Sun, 2 Nov 2008 00:35:25 +0000 Subject: [PATCH] Enhance return-of-stack-address checker to recognize regions created by alloca(). llvm-svn: 58553 --- clang/lib/Analysis/GRExprEngineInternalChecks.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/clang/lib/Analysis/GRExprEngineInternalChecks.cpp b/clang/lib/Analysis/GRExprEngineInternalChecks.cpp index d772744f17cc..cc5762267b60 100644 --- a/clang/lib/Analysis/GRExprEngineInternalChecks.cpp +++ b/clang/lib/Analysis/GRExprEngineInternalChecks.cpp @@ -216,6 +216,15 @@ public: R = CL->getSourceRange(); } + else if (const AllocaRegion* AR = dyn_cast(V.getRegion())) { + const Expr* ARE = AR->getExpr(); + SourceLocation L = ARE->getLocStart(); + R = ARE->getSourceRange(); + + os << "Address of stack memory allocated by call to alloca() on line " + << BR.getSourceManager().getLogicalLineNumber(L) + << " returned."; + } else { os << "Address of stack memory associated with local variable '" << V.getRegion()->getString() << "' returned.";