1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

OpaquePtr: Make byval/sret types mandatory

This commit is contained in:
Matt Arsenault 2020-11-20 18:16:11 -05:00
parent c390d54618
commit 12c5d5881d
5 changed files with 16 additions and 23 deletions

View File

@ -472,14 +472,12 @@ public:
/// Extract the byval type for a parameter.
Type *getParamByValType(unsigned ArgNo) const {
Type *Ty = AttributeSets.getParamByValType(ArgNo);
return Ty ? Ty : (arg_begin() + ArgNo)->getType()->getPointerElementType();
return AttributeSets.getParamByValType(ArgNo);
}
/// Extract the sret type for a parameter.
Type *getParamStructRetType(unsigned ArgNo) const {
Type *Ty = AttributeSets.getParamStructRetType(ArgNo);
return Ty ? Ty : (arg_begin() + ArgNo)->getType()->getPointerElementType();
return AttributeSets.getParamStructRetType(ArgNo);
}
/// Extract the byref type for a parameter.

View File

@ -1699,14 +1699,14 @@ bool LLParser::parseOptionalParamAttrs(AttrBuilder &B) {
}
case lltok::kw_byval: {
Type *Ty;
if (parseOptionalTypeAttr(Ty, lltok::kw_byval))
if (parseRequiredTypeAttr(Ty, lltok::kw_byval))
return true;
B.addByValAttr(Ty);
continue;
}
case lltok::kw_sret: {
Type *Ty;
if (parseOptionalTypeAttr(Ty, lltok::kw_sret))
if (parseRequiredTypeAttr(Ty, lltok::kw_sret))
return true;
B.addStructRetAttr(Ty);
continue;
@ -2628,22 +2628,6 @@ bool LLParser::parseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
return false;
}
/// parseByValWithOptionalType
/// ::= byval
/// ::= byval(<ty>)
bool LLParser::parseOptionalTypeAttr(Type *&Result, lltok::Kind AttrName) {
Result = nullptr;
if (!EatIfPresent(AttrName))
return true;
if (!EatIfPresent(lltok::lparen))
return false;
if (parseType(Result))
return true;
if (!EatIfPresent(lltok::rparen))
return error(Lex.getLoc(), "expected ')'");
return false;
}
/// parseRequiredTypeAttr
/// ::= attrname(<ty>)
bool LLParser::parseRequiredTypeAttr(Type *&Result, lltok::Kind AttrName) {

View File

@ -328,7 +328,6 @@ namespace llvm {
bool parseFnAttributeValuePairs(AttrBuilder &B,
std::vector<unsigned> &FwdRefAttrGrps,
bool inAttrGrp, LocTy &BuiltinLoc);
bool parseOptionalTypeAttr(Type *&Result, lltok::Kind AttrName);
bool parseRequiredTypeAttr(Type *&Result, lltok::Kind AttrName);
bool parsePreallocated(Type *&Result);
bool parseByRef(Type *&Result);

View File

@ -0,0 +1,6 @@
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:34: error: expected '('{{$}}
define void @test_byval(i8* byval) {
ret void
}

View File

@ -0,0 +1,6 @@
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:32: error: expected '('{{$}}
define void @test_sret(i8* sret) {
ret void
}