@@ -2982,63 +2982,25 @@ bool LLParser::parseArgumentList(SmallVectorImpl<ArgInfo> &ArgList,
2982
2982
assert (Lex.getKind () == lltok::lparen);
2983
2983
Lex.Lex (); // eat the (.
2984
2984
2985
- if (Lex.getKind () == lltok::rparen) {
2986
- // empty
2987
- } else if (Lex.getKind () == lltok::dotdotdot) {
2988
- IsVarArg = true ;
2989
- Lex.Lex ();
2990
- } else {
2991
- LocTy TypeLoc = Lex.getLoc ();
2992
- Type *ArgTy = nullptr ;
2993
- AttrBuilder Attrs (M->getContext ());
2994
- std::string Name;
2995
-
2996
- if (parseType (ArgTy) || parseOptionalParamAttrs (Attrs))
2997
- return true ;
2998
-
2999
- if (ArgTy->isVoidTy ())
3000
- return error (TypeLoc, " argument can not have void type" );
3001
-
3002
- if (Lex.getKind () == lltok::LocalVar) {
3003
- Name = Lex.getStrVal ();
3004
- Lex.Lex ();
3005
- } else {
3006
- unsigned ArgID;
3007
- if (Lex.getKind () == lltok::LocalVarID) {
3008
- ArgID = Lex.getUIntVal ();
3009
- if (checkValueID (TypeLoc, " argument" , " %" , CurValID, ArgID))
3010
- return true ;
3011
- Lex.Lex ();
3012
- } else {
3013
- ArgID = CurValID;
3014
- }
3015
-
3016
- UnnamedArgNums.push_back (ArgID);
3017
- CurValID = ArgID + 1 ;
3018
- }
3019
-
3020
- if (!FunctionType::isValidArgumentType (ArgTy))
3021
- return error (TypeLoc, " invalid type for function argument" );
3022
-
3023
- ArgList.emplace_back (TypeLoc, ArgTy,
3024
- AttributeSet::get (ArgTy->getContext (), Attrs),
3025
- std::move (Name));
3026
-
3027
- while (EatIfPresent (lltok::comma)) {
2985
+ if (Lex.getKind () != lltok::rparen) {
2986
+ do {
3028
2987
// Handle ... at end of arg list.
3029
2988
if (EatIfPresent (lltok::dotdotdot)) {
3030
2989
IsVarArg = true ;
3031
2990
break ;
3032
2991
}
3033
2992
3034
2993
// Otherwise must be an argument type.
3035
- TypeLoc = Lex.getLoc ();
2994
+ LocTy TypeLoc = Lex.getLoc ();
2995
+ Type *ArgTy = nullptr ;
2996
+ AttrBuilder Attrs (M->getContext ());
3036
2997
if (parseType (ArgTy) || parseOptionalParamAttrs (Attrs))
3037
2998
return true ;
3038
2999
3039
3000
if (ArgTy->isVoidTy ())
3040
3001
return error (TypeLoc, " argument can not have void type" );
3041
3002
3003
+ std::string Name;
3042
3004
if (Lex.getKind () == lltok::LocalVar) {
3043
3005
Name = Lex.getStrVal ();
3044
3006
Lex.Lex ();
@@ -3054,7 +3016,6 @@ bool LLParser::parseArgumentList(SmallVectorImpl<ArgInfo> &ArgList,
3054
3016
}
3055
3017
UnnamedArgNums.push_back (ArgID);
3056
3018
CurValID = ArgID + 1 ;
3057
- Name = " " ;
3058
3019
}
3059
3020
3060
3021
if (!ArgTy->isFirstClassType ())
@@ -3063,7 +3024,7 @@ bool LLParser::parseArgumentList(SmallVectorImpl<ArgInfo> &ArgList,
3063
3024
ArgList.emplace_back (TypeLoc, ArgTy,
3064
3025
AttributeSet::get (ArgTy->getContext (), Attrs),
3065
3026
std::move (Name));
3066
- }
3027
+ } while ( EatIfPresent (lltok::comma));
3067
3028
}
3068
3029
3069
3030
return parseToken (lltok::rparen, " expected ')' at end of argument list" );
0 commit comments