forked from OSchip/llvm-project
Implement support for variadic methods (work in progress).
llvm-svn: 44171
This commit is contained in:
parent
05caa48fb4
commit
d8ea1ac576
|
@ -1278,7 +1278,7 @@ Stmt *RewriteTest::RewriteMessageExpr(ObjCMessageExpr *Exp) {
|
||||||
// Now do the "normal" pointer to function cast.
|
// Now do the "normal" pointer to function cast.
|
||||||
QualType castType = Context->getFunctionType(returnType,
|
QualType castType = Context->getFunctionType(returnType,
|
||||||
&ArgTypes[0], ArgTypes.size(),
|
&ArgTypes[0], ArgTypes.size(),
|
||||||
false/*FIXME:variadic*/);
|
Exp->getMethodDecl()->isVariadic());
|
||||||
castType = Context->getPointerType(castType);
|
castType = Context->getPointerType(castType);
|
||||||
cast = new CastExpr(castType, cast, SourceLocation());
|
cast = new CastExpr(castType, cast, SourceLocation());
|
||||||
|
|
||||||
|
|
|
@ -619,13 +619,17 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
|
||||||
// We have a selector or a colon, continue parsing.
|
// We have a selector or a colon, continue parsing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isVariadic = false;
|
||||||
|
|
||||||
// Parse the (optional) parameter list.
|
// Parse the (optional) parameter list.
|
||||||
while (Tok.is(tok::comma)) {
|
while (Tok.is(tok::comma)) {
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
if (Tok.is(tok::ellipsis)) {
|
if (Tok.is(tok::ellipsis)) {
|
||||||
|
isVariadic = true;
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// FIXME: implement this...
|
||||||
// Parse the c-style argument declaration-specifier.
|
// Parse the c-style argument declaration-specifier.
|
||||||
DeclSpec DS;
|
DeclSpec DS;
|
||||||
ParseDeclarationSpecifiers(DS);
|
ParseDeclarationSpecifiers(DS);
|
||||||
|
@ -645,8 +649,8 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
|
||||||
return Actions.ActOnMethodDeclaration(mLoc, Tok.getLocation(),
|
return Actions.ActOnMethodDeclaration(mLoc, Tok.getLocation(),
|
||||||
mType, IDecl, DSRet, ReturnType, Sel,
|
mType, IDecl, DSRet, ReturnType, Sel,
|
||||||
&ArgTypeQuals[0], &KeyTypes[0],
|
&ArgTypeQuals[0], &KeyTypes[0],
|
||||||
&ArgNames[0],
|
&ArgNames[0], MethodAttrs,
|
||||||
MethodAttrs, MethodImplKind);
|
MethodImplKind, isVariadic);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CmpProtocolVals - Comparison predicate for sorting protocols.
|
/// CmpProtocolVals - Comparison predicate for sorting protocols.
|
||||||
|
|
|
@ -560,7 +560,8 @@ public:
|
||||||
// optional arguments. The number of types/arguments is obtained
|
// optional arguments. The number of types/arguments is obtained
|
||||||
// from the Sel.getNumArgs().
|
// from the Sel.getNumArgs().
|
||||||
ObjcDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames,
|
ObjcDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames,
|
||||||
AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind);
|
AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind,
|
||||||
|
bool isVariadic = false);
|
||||||
|
|
||||||
// ActOnClassMessage - used for both unary and keyword messages.
|
// ActOnClassMessage - used for both unary and keyword messages.
|
||||||
// ArgExprs is optional - if it is present, the number of expressions
|
// ArgExprs is optional - if it is present, the number of expressions
|
||||||
|
|
|
@ -2119,7 +2119,8 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration(
|
||||||
// optional arguments. The number of types/arguments is obtained
|
// optional arguments. The number of types/arguments is obtained
|
||||||
// from the Sel.getNumArgs().
|
// from the Sel.getNumArgs().
|
||||||
ObjcDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames,
|
ObjcDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames,
|
||||||
AttributeList *AttrList, tok::ObjCKeywordKind MethodDeclKind) {
|
AttributeList *AttrList, tok::ObjCKeywordKind MethodDeclKind,
|
||||||
|
bool isVariadic) {
|
||||||
llvm::SmallVector<ParmVarDecl*, 16> Params;
|
llvm::SmallVector<ParmVarDecl*, 16> Params;
|
||||||
|
|
||||||
for (unsigned i = 0; i < Sel.getNumArgs(); i++) {
|
for (unsigned i = 0; i < Sel.getNumArgs(); i++) {
|
||||||
|
@ -2148,7 +2149,7 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration(
|
||||||
resultDeclType,
|
resultDeclType,
|
||||||
CDecl,
|
CDecl,
|
||||||
0, -1, AttrList,
|
0, -1, AttrList,
|
||||||
MethodType == tok::minus,
|
MethodType == tok::minus, isVariadic,
|
||||||
MethodDeclKind == tok::objc_optional ?
|
MethodDeclKind == tok::objc_optional ?
|
||||||
ObjcMethodDecl::Optional :
|
ObjcMethodDecl::Optional :
|
||||||
ObjcMethodDecl::Required);
|
ObjcMethodDecl::Required);
|
||||||
|
|
|
@ -626,6 +626,8 @@ private:
|
||||||
/// declared in class Decl.
|
/// declared in class Decl.
|
||||||
/// instance (true) or class (false) method.
|
/// instance (true) or class (false) method.
|
||||||
bool IsInstance : 1;
|
bool IsInstance : 1;
|
||||||
|
bool IsVariadic : 1;
|
||||||
|
|
||||||
/// @required/@optional
|
/// @required/@optional
|
||||||
ImplementationControl DeclImplementation : 2;
|
ImplementationControl DeclImplementation : 2;
|
||||||
|
|
||||||
|
@ -657,11 +659,12 @@ public:
|
||||||
Decl *contextDecl,
|
Decl *contextDecl,
|
||||||
ParmVarDecl **paramInfo = 0, int numParams=-1,
|
ParmVarDecl **paramInfo = 0, int numParams=-1,
|
||||||
AttributeList *M = 0, bool isInstance = true,
|
AttributeList *M = 0, bool isInstance = true,
|
||||||
|
bool isVariadic = false,
|
||||||
ImplementationControl impControl = None,
|
ImplementationControl impControl = None,
|
||||||
Decl *PrevDecl = 0)
|
Decl *PrevDecl = 0)
|
||||||
: Decl(ObjcMethod, beginLoc),
|
: Decl(ObjcMethod, beginLoc),
|
||||||
IsInstance(isInstance), DeclImplementation(impControl),
|
IsInstance(isInstance), IsVariadic(isVariadic),
|
||||||
objcDeclQualifier(OBJC_TQ_None),
|
DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None),
|
||||||
MethodContext(static_cast<NamedDecl*>(contextDecl)),
|
MethodContext(static_cast<NamedDecl*>(contextDecl)),
|
||||||
SelName(SelInfo), MethodDeclType(T),
|
SelName(SelInfo), MethodDeclType(T),
|
||||||
ParamInfo(paramInfo), NumMethodParams(numParams),
|
ParamInfo(paramInfo), NumMethodParams(numParams),
|
||||||
|
@ -704,6 +707,8 @@ public:
|
||||||
|
|
||||||
AttributeList *getMethodAttrs() const {return MethodAttrs;}
|
AttributeList *getMethodAttrs() const {return MethodAttrs;}
|
||||||
bool isInstance() const { return IsInstance; }
|
bool isInstance() const { return IsInstance; }
|
||||||
|
bool isVariadic() const { return IsVariadic; }
|
||||||
|
|
||||||
// Related to protocols declared in @protocol
|
// Related to protocols declared in @protocol
|
||||||
void setDeclImplementation(ImplementationControl ic) {
|
void setDeclImplementation(ImplementationControl ic) {
|
||||||
DeclImplementation = ic;
|
DeclImplementation = ic;
|
||||||
|
|
|
@ -565,7 +565,8 @@ public:
|
||||||
IdentifierInfo **ArgNames, // non-zero when Sel.getNumArgs() > 0
|
IdentifierInfo **ArgNames, // non-zero when Sel.getNumArgs() > 0
|
||||||
AttributeList *AttrList, // optional
|
AttributeList *AttrList, // optional
|
||||||
// tok::objc_not_keyword, tok::objc_optional, tok::objc_required
|
// tok::objc_not_keyword, tok::objc_optional, tok::objc_required
|
||||||
tok::ObjCKeywordKind impKind) {
|
tok::ObjCKeywordKind impKind,
|
||||||
|
bool isVariadic = false) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// ActOnAtEnd - called to mark the @end. For declarations (interfaces,
|
// ActOnAtEnd - called to mark the @end. For declarations (interfaces,
|
||||||
|
|
Loading…
Reference in New Issue