diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2009-06-07 07:26:46 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2009-06-07 07:26:46 +0000 |
commit | a5f54a06b09acf5c4ed3571039f262128226145b (patch) | |
tree | ab84893b4576a23dcc4e8798e494e099e87fa43c /lib/AsmParser/LLParser.cpp | |
parent | 9dcc26b6a0413b042142017c22d847676b41bac5 (diff) |
Create FunctionType::isValidArgumentType to go along with isValidReturnType.
Also create isValidElementType for ArrayType, PointerType, StructType and
VectorType.
Make LLParser use them. This closes up some holes like an assertion failure on:
%x = type {label}
but largely doesn't change any semantics. The only thing we accept now which
we didn't before is vectors of opaque type such as "<4 x opaque>". The opaque
can be resolved to an int or float when linking.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73016 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/LLParser.cpp')
-rw-r--r-- | lib/AsmParser/LLParser.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 4759d6f19d..4863f3c511 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -1043,6 +1043,8 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) { return TokError("basic block pointers are invalid"); if (Result.get() == Type::VoidTy) return TokError("pointers to void are invalid; use i8* instead"); + if (!PointerType::isValidElementType(Result.get())) + return TokError("pointer to this type is invalid"); Result = HandleUpRefs(PointerType::getUnqual(Result.get())); Lex.Lex(); break; @@ -1053,6 +1055,8 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) { return TokError("basic block pointers are invalid"); if (Result.get() == Type::VoidTy) return TokError("pointers to void are invalid; use i8* instead"); + if (!PointerType::isValidElementType(Result.get())) + return TokError("pointer to this type is invalid"); unsigned AddrSpace; if (ParseOptionalAddrSpace(AddrSpace) || ParseToken(lltok::star, "expected '*' in address space")) @@ -1149,9 +1153,7 @@ bool LLParser::ParseArgumentList(std::vector<ArgInfo> &ArgList, Lex.Lex(); } - if ((!ArgTy->isFirstClassType() && !isa<OpaqueType>(ArgTy)) || - (isa<PointerType>(ArgTy) && - cast<PointerType>(ArgTy)->getElementType() == Type::MetadataTy)) + if (!FunctionType::isValidArgumentType(ArgTy)) return Error(TypeLoc, "invalid type for function argument"); ArgList.push_back(ArgInfo(TypeLoc, ArgTy, Attrs, Name)); @@ -1247,6 +1249,8 @@ bool LLParser::ParseStructType(PATypeHolder &Result, bool Packed) { if (Result == Type::VoidTy) return Error(EltTyLoc, "struct element can not have void type"); + if (!StructType::isValidElementType(Result)) + return Error(EltTyLoc, "invalid element type for struct"); while (EatIfPresent(lltok::comma)) { EltTyLoc = Lex.getLoc(); @@ -1254,6 +1258,8 @@ bool LLParser::ParseStructType(PATypeHolder &Result, bool Packed) { if (Result == Type::VoidTy) return Error(EltTyLoc, "struct element can not have void type"); + if (!StructType::isValidElementType(Result)) + return Error(EltTyLoc, "invalid element type for struct"); ParamsList.push_back(Result); } @@ -1301,11 +1307,11 @@ bool LLParser::ParseArrayVectorType(PATypeHolder &Result, bool isVector) { return Error(SizeLoc, "zero element vector is illegal"); if ((unsigned)Size != Size) return Error(SizeLoc, "size too large for vector"); - if (!EltTy->isFloatingPoint() && !EltTy->isInteger()) + if (!VectorType::isValidElementType(EltTy)) return Error(TypeLoc, "vector element type must be fp or integer"); Result = VectorType::get(EltTy, unsigned(Size)); } else { - if (!EltTy->isFirstClassType() && !isa<OpaqueType>(EltTy)) + if (!ArrayType::isValidElementType(EltTy)) return Error(TypeLoc, "invalid array element type"); Result = HandleUpRefs(ArrayType::get(EltTy, Size)); } |