[llvm-commits] [llvm] r44538 - in /llvm/trunk/lib/AsmParser: llvmAsmParser.y llvmAsmParser.y.cvs
Anton Korobeynikov
asl at math.spbu.ru
Mon Dec 3 11:16:54 PST 2007
Author: asl
Date: Mon Dec 3 13:16:54 2007
New Revision: 44538
URL: http://llvm.org/viewvc/llvm-project?rev=44538&view=rev
Log:
More sanity checks for function types.
Thanks goes to PyPy folks for generating broken stuff :)
Modified:
llvm/trunk/lib/AsmParser/llvmAsmParser.y
llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs
Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.y
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.y?rev=44538&r1=44537&r2=44538&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/llvmAsmParser.y (original)
+++ llvm/trunk/lib/AsmParser/llvmAsmParser.y Mon Dec 3 13:16:54 2007
@@ -1330,16 +1330,24 @@
| Types '(' ArgTypeListI ')' OptFuncAttrs {
// Allow but ignore attributes on function types; this permits auto-upgrade.
// FIXME: remove in LLVM 3.0.
+ const Type* RetTy = *$1;
+ if (!(RetTy->isFirstClassType() || isa<OpaqueType>(RetTy)))
+ GEN_ERROR("LLVM Functions cannot return aggregates");
+
std::vector<const Type*> Params;
TypeWithAttrsList::iterator I = $3->begin(), E = $3->end();
for (; I != E; ++I ) {
const Type *Ty = I->Ty->get();
+ if (!(Ty->isFirstClassType() || isa<OpaqueType>(Ty)))
+ GEN_ERROR("Function arguments must be value types!");
Params.push_back(Ty);
}
+ CHECK_FOR_ERROR
+
bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
if (isVarArg) Params.pop_back();
- FunctionType *FT = FunctionType::get(*$1, Params, isVarArg);
+ FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
delete $3; // Delete the argument list
delete $1; // Delete the return type handle
$$ = new PATypeHolder(HandleUpRefs(FT));
@@ -1352,8 +1360,12 @@
TypeWithAttrsList::iterator I = $3->begin(), E = $3->end();
for ( ; I != E; ++I ) {
const Type* Ty = I->Ty->get();
+ if (!(Ty->isFirstClassType() || isa<OpaqueType>(Ty)))
+ GEN_ERROR("Function arguments must be value types!");
Params.push_back(Ty);
}
+ CHECK_FOR_ERROR
+
bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
if (isVarArg) Params.pop_back();
Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs?rev=44538&r1=44537&r2=44538&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs (original)
+++ llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs Mon Dec 3 13:16:54 2007
@@ -1330,16 +1330,24 @@
| Types '(' ArgTypeListI ')' OptFuncAttrs {
// Allow but ignore attributes on function types; this permits auto-upgrade.
// FIXME: remove in LLVM 3.0.
+ const Type* RetTy = *$1;
+ if (!(RetTy->isFirstClassType() || isa<OpaqueType>(RetTy)))
+ GEN_ERROR("LLVM Functions cannot return aggregates");
+
std::vector<const Type*> Params;
TypeWithAttrsList::iterator I = $3->begin(), E = $3->end();
for (; I != E; ++I ) {
const Type *Ty = I->Ty->get();
+ if (!(Ty->isFirstClassType() || isa<OpaqueType>(Ty)))
+ GEN_ERROR("Function arguments must be value types!");
Params.push_back(Ty);
}
+ CHECK_FOR_ERROR
+
bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
if (isVarArg) Params.pop_back();
- FunctionType *FT = FunctionType::get(*$1, Params, isVarArg);
+ FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
delete $3; // Delete the argument list
delete $1; // Delete the return type handle
$$ = new PATypeHolder(HandleUpRefs(FT));
@@ -1352,8 +1360,12 @@
TypeWithAttrsList::iterator I = $3->begin(), E = $3->end();
for ( ; I != E; ++I ) {
const Type* Ty = I->Ty->get();
+ if (!(Ty->isFirstClassType() || isa<OpaqueType>(Ty)))
+ GEN_ERROR("Function arguments must be value types!");
Params.push_back(Ty);
}
+ CHECK_FOR_ERROR
+
bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
if (isVarArg) Params.pop_back();
More information about the llvm-commits
mailing list