aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/Lint.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-05-28 04:33:42 +0000
committerDan Gohman <gohman@apple.com>2010-05-28 04:33:42 +0000
commit292fc87fe2f1611e7c83a61796ab71db6a0f7d97 (patch)
tree8344299ed3991fdb6d170614ef35555d0edc10f3 /lib/Analysis/Lint.cpp
parent28d2e0a39fb0dccb62a08520791070d13339d6e1 (diff)
Add a lint check for returning the address of stack memory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104936 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/Lint.cpp')
-rw-r--r--lib/Analysis/Lint.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Analysis/Lint.cpp b/lib/Analysis/Lint.cpp
index a031cbc65b..8119debdaf 100644
--- a/lib/Analysis/Lint.cpp
+++ b/lib/Analysis/Lint.cpp
@@ -310,6 +310,12 @@ void Lint::visitReturnInst(ReturnInst &I) {
Assert1(!F->doesNotReturn(),
"Unusual: Return statement in function with noreturn attribute",
&I);
+
+ if (Value *V = I.getReturnValue()) {
+ Value *Obj = V->getUnderlyingObject();
+ Assert1(!isa<AllocaInst>(Obj) && !isa<VAArgInst>(Obj),
+ "Unusual: Returning alloca or va_arg value", &I);
+ }
}
// TODO: Add a length argument and check that the reference is in bounds