summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Verifier.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2007-07-10 19:28:12 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2007-07-10 19:28:12 +0000
commit9521a564fbd0fbb4be0e023ffa9c274eae20b340 (patch)
tree35dddf21258b3b2f3347294e1c2dc2ce169c31f7 /llvm/lib/VMCore/Verifier.cpp
parent76547349c148926d69be105d4cb30b16cc3d704e (diff)
downloadbcm5719-llvm-9521a564fbd0fbb4be0e023ffa9c274eae20b340.tar.gz
bcm5719-llvm-9521a564fbd0fbb4be0e023ffa9c274eae20b340.zip
check for correct usage of the byval attribute
llvm-svn: 38506
Diffstat (limited to 'llvm/lib/VMCore/Verifier.cpp')
-rw-r--r--llvm/lib/VMCore/Verifier.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp
index 16e87f4f7a1..4e3a16e8ee9 100644
--- a/llvm/lib/VMCore/Verifier.cpp
+++ b/llvm/lib/VMCore/Verifier.cpp
@@ -361,6 +361,10 @@ void Verifier::visitFunction(Function &F) {
if (const ParamAttrsList *Attrs = FT->getParamAttrs()) {
unsigned Idx = 1;
+
+ Assert(!Attrs->paramHasAttr(0, ParamAttr::ByVal),
+ "Attribute ByVal should not apply to functions!");
+
for (FunctionType::param_iterator I = FT->param_begin(),
E = FT->param_end(); I != E; ++I, ++Idx) {
if (Attrs->paramHasAttr(Idx, ParamAttr::ZExt) ||
@@ -370,9 +374,14 @@ void Verifier::visitFunction(Function &F) {
if (Attrs->paramHasAttr(Idx, ParamAttr::NoAlias))
Assert1(isa<PointerType>(FT->getParamType(Idx-1)),
"Attribute NoAlias should only apply to Pointer type!", &F);
- if (Attrs->paramHasAttr(Idx, ParamAttr::ByVal))
+ if (Attrs->paramHasAttr(Idx, ParamAttr::ByVal)) {
Assert1(isa<PointerType>(FT->getParamType(Idx-1)),
- "Attribute ByVal should only apply to Pointer type!", &F);
+ "Attribute ByVal should only apply to pointer to structs!", &F);
+ const PointerType *Ty =
+ cast<PointerType>(FT->getParamType(Idx-1));
+ Assert1(isa<StructType>(Ty->getElementType()),
+ "Attribute ByVal should only apply to pointer to structs!", &F);
+ }
}
}
OpenPOWER on IntegriCloud