[llvm-commits] [llvm] r104936 - in /llvm/trunk: lib/Analysis/Lint.cpp test/Other/lint.ll

Eli Friedman eli.friedman at gmail.com
Thu May 27 21:45:56 PDT 2010


On Thu, May 27, 2010 at 9:33 PM, Dan Gohman <gohman at apple.com> wrote:
> Author: djg
> Date: Thu May 27 23:33:42 2010
> New Revision: 104936
>
> URL: http://llvm.org/viewvc/llvm-project?rev=104936&view=rev
> Log:
> Add a lint check for returning the address of stack memory.
>
> Modified:
>    llvm/trunk/lib/Analysis/Lint.cpp
>    llvm/trunk/test/Other/lint.ll
>
> Modified: llvm/trunk/lib/Analysis/Lint.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Lint.cpp?rev=104936&r1=104935&r2=104936&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Analysis/Lint.cpp (original)
> +++ llvm/trunk/lib/Analysis/Lint.cpp Thu May 27 23:33:42 2010
> @@ -310,6 +310,12 @@
>   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);
> +  }
>  }

A VAArgInst doesn't in general return a pointer to something on the stack...

-Eli




More information about the llvm-commits mailing list