diff options
| author | Reid Spencer <rspencer@reidspencer.com> | 2007-07-23 23:09:55 +0000 |
|---|---|---|
| committer | Reid Spencer <rspencer@reidspencer.com> | 2007-07-23 23:09:55 +0000 |
| commit | 6c2b393f0c55670e9e2cc60a968b31edbd58f15f (patch) | |
| tree | 2420ce2ba1dac2f80a0abd5d89b7b2d1400c725e /llvm/lib/VMCore/Verifier.cpp | |
| parent | 49a953ab139dd60031177aba06b895bd7e75213f (diff) | |
| download | bcm5719-llvm-6c2b393f0c55670e9e2cc60a968b31edbd58f15f.tar.gz bcm5719-llvm-6c2b393f0c55670e9e2cc60a968b31edbd58f15f.zip | |
Add better verification of attributes on function types. It is not permitted
to use sret or inreg on the function. It is equally illegal to use noreturn
or nounwind on a parameter; they only go with the function. This patch
enforces these rules.
llvm-svn: 40453
Diffstat (limited to 'llvm/lib/VMCore/Verifier.cpp')
| -rw-r--r-- | llvm/lib/VMCore/Verifier.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp index cbb34f09e46..6da36452fcd 100644 --- a/llvm/lib/VMCore/Verifier.cpp +++ b/llvm/lib/VMCore/Verifier.cpp @@ -364,6 +364,10 @@ void Verifier::visitFunction(Function &F) { Assert(!Attrs->paramHasAttr(0, ParamAttr::ByVal), "Attribute ByVal should not apply to functions!"); + Assert(!Attrs->paramHasAttr(0, ParamAttr::StructRet), + "Attribute SRet should not apply to functions!"); + Assert(!Attrs->paramHasAttr(0, ParamAttr::InReg), + "Attribute SRet should not apply to functions!"); for (FunctionType::param_iterator I = FT->param_begin(), E = FT->param_end(); I != E; ++I, ++Idx) { @@ -386,6 +390,11 @@ void Verifier::visitFunction(Function &F) { Assert1(isa<StructType>(Ty->getElementType()), "Attribute ByVal should only apply to pointer to structs!", &F); } + + if (Attrs->paramHasAttr(Idx, ParamAttr::NoReturn)) + Assert1(0, "Attribute NoReturn should only be applied to function", &F); + if (Attrs->paramHasAttr(Idx, ParamAttr::NoUnwind)) + Assert1(0, "Attribute NoUnwind should only be applied to function", &F); } } |

