diff options
author | Reid Spencer <reid@x10sys.com> | 2007-07-23 23:09:55 +0000 |
---|---|---|
committer | Reid Spencer <reid@x10sys.com> | 2007-07-23 23:09:55 +0000 |
commit | bb511f889f060d856764bede28bff03a3bd25b59 (patch) | |
tree | 6f181fdf00803f61c3a4eae57efee264bf528182 | |
parent | 1d8194dd46a60e7a36c1148f9aa8d9734f94a404 (diff) | |
download | external_llvm-bb511f889f060d856764bede28bff03a3bd25b59.zip external_llvm-bb511f889f060d856764bede28bff03a3bd25b59.tar.gz external_llvm-bb511f889f060d856764bede28bff03a3bd25b59.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40453 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Verifier.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index cbb34f0..6da3645 100644 --- a/lib/VMCore/Verifier.cpp +++ b/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); } } |