[llvm-commits] [llvm] r50138 - /llvm/trunk/lib/AsmParser/llvmAsmParser.y
Chris Lattner
sabre at nondot.org
Tue Apr 22 22:36:59 PDT 2008
Author: lattner
Date: Wed Apr 23 00:36:58 2008
New Revision: 50138
URL: http://llvm.org/viewvc/llvm-project?rev=50138&view=rev
Log:
Validate that the result of a function type is valid using shared
logic with vmcore.
Modified:
llvm/trunk/lib/AsmParser/llvmAsmParser.y
Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.y
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.y?rev=50138&r1=50137&r2=50138&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/llvmAsmParser.y (original)
+++ llvm/trunk/lib/AsmParser/llvmAsmParser.y Wed Apr 23 00:36:58 2008
@@ -1349,12 +1349,10 @@
| 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() || RetTy == Type::VoidTy ||
- isa<StructType>(RetTy) ||
- isa<OpaqueType>(RetTy)))
- GEN_ERROR("LLVM Functions cannot return aggregates");
-
+ const Type *RetTy = *$1;
+ if (!FunctionType::isValidReturnType(RetTy))
+ GEN_ERROR("Invalid result type for LLVM function");
+
std::vector<const Type*> Params;
TypeWithAttrsList::iterator I = $3->begin(), E = $3->end();
for (; I != E; ++I ) {
@@ -2255,6 +2253,9 @@
if (!CurFun.isDeclare && CurModule.TypeIsUnresolved($2))
GEN_ERROR("Reference to abstract result: "+ $2->get()->getDescription());
+ if (!FunctionType::isValidReturnType(*$2))
+ GEN_ERROR("Invalid result type for LLVM function");
+
std::vector<const Type*> ParamTypeList;
SmallVector<ParamAttrsWithIndex, 8> Attrs;
if ($7 != ParamAttr::None)
@@ -2648,6 +2649,10 @@
GEN_ERROR("Short call syntax cannot be used with varargs");
ParamTypes.push_back(Ty);
}
+
+ if (!FunctionType::isValidReturnType(*$3))
+ GEN_ERROR("Invalid result type for LLVM function");
+
Ty = FunctionType::get($3->get(), ParamTypes, false);
PFTy = PointerType::getUnqual(Ty);
}
@@ -2972,6 +2977,10 @@
GEN_ERROR("Short call syntax cannot be used with varargs");
ParamTypes.push_back(Ty);
}
+
+ if (!FunctionType::isValidReturnType(*$3))
+ GEN_ERROR("Invalid result type for LLVM function");
+
Ty = FunctionType::get($3->get(), ParamTypes, false);
PFTy = PointerType::getUnqual(Ty);
}
More information about the llvm-commits
mailing list