]> granicus.if.org Git - clang/commitdiff
Enhance return-of-stack-address checker to recognize regions created by alloca().
authorTed Kremenek <kremenek@apple.com>
Sun, 2 Nov 2008 00:35:25 +0000 (00:35 +0000)
committerTed Kremenek <kremenek@apple.com>
Sun, 2 Nov 2008 00:35:25 +0000 (00:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58553 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/GRExprEngineInternalChecks.cpp

index d772744f17cc7c9e7a403e749f4625d342641576..cc5762267b6089cf0e42ca19172c7bfb32385f23 100644 (file)
@@ -216,6 +216,15 @@ public:
         
         R = CL->getSourceRange();
       }
+      else if (const AllocaRegion* AR = dyn_cast<AllocaRegion>(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.";