diff options
author | Steve Naroff <snaroff@apple.com> | 2007-11-15 12:35:21 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2007-11-15 12:35:21 +0000 |
commit | d8ea1ac5761b311fc6e3b45a8154fe281dd18cfb (patch) | |
tree | aeff07daa9450539d26a7e6556e8a6db003bb91f | |
parent | 05caa48fb403cfd5a73909e317e8f1d9e4cb75f4 (diff) | |
download | bcm5719-llvm-d8ea1ac5761b311fc6e3b45a8154fe281dd18cfb.tar.gz bcm5719-llvm-d8ea1ac5761b311fc6e3b45a8154fe281dd18cfb.zip |
Implement support for variadic methods (work in progress).
llvm-svn: 44171
-rw-r--r-- | clang/Driver/RewriteTest.cpp | 4 | ||||
-rw-r--r-- | clang/Parse/ParseObjc.cpp | 8 | ||||
-rw-r--r-- | clang/Sema/Sema.h | 3 | ||||
-rw-r--r-- | clang/Sema/SemaDecl.cpp | 5 | ||||
-rw-r--r-- | clang/include/clang/AST/DeclObjC.h | 9 | ||||
-rw-r--r-- | clang/include/clang/Parse/Action.h | 3 |
6 files changed, 22 insertions, 10 deletions
diff --git a/clang/Driver/RewriteTest.cpp b/clang/Driver/RewriteTest.cpp index a768d17b3a5..b5dcdfc802e 100644 --- a/clang/Driver/RewriteTest.cpp +++ b/clang/Driver/RewriteTest.cpp @@ -1274,11 +1274,11 @@ Stmt *RewriteTest::RewriteMessageExpr(ObjCMessageExpr *Exp) { // xx.m:13: note: if this code is reached, the program will abort cast = new CastExpr(Context->getPointerType(Context->VoidTy), DRE, SourceLocation()); - + // Now do the "normal" pointer to function cast. QualType castType = Context->getFunctionType(returnType, &ArgTypes[0], ArgTypes.size(), - false/*FIXME:variadic*/); + Exp->getMethodDecl()->isVariadic()); castType = Context->getPointerType(castType); cast = new CastExpr(castType, cast, SourceLocation()); diff --git a/clang/Parse/ParseObjc.cpp b/clang/Parse/ParseObjc.cpp index 345906e70f1..be33f86f0cc 100644 --- a/clang/Parse/ParseObjc.cpp +++ b/clang/Parse/ParseObjc.cpp @@ -619,13 +619,17 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(SourceLocation mLoc, // We have a selector or a colon, continue parsing. } + bool isVariadic = false; + // Parse the (optional) parameter list. while (Tok.is(tok::comma)) { ConsumeToken(); if (Tok.is(tok::ellipsis)) { + isVariadic = true; ConsumeToken(); break; } + // FIXME: implement this... // Parse the c-style argument declaration-specifier. DeclSpec DS; ParseDeclarationSpecifiers(DS); @@ -645,8 +649,8 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(SourceLocation mLoc, return Actions.ActOnMethodDeclaration(mLoc, Tok.getLocation(), mType, IDecl, DSRet, ReturnType, Sel, &ArgTypeQuals[0], &KeyTypes[0], - &ArgNames[0], - MethodAttrs, MethodImplKind); + &ArgNames[0], MethodAttrs, + MethodImplKind, isVariadic); } /// CmpProtocolVals - Comparison predicate for sorting protocols. diff --git a/clang/Sema/Sema.h b/clang/Sema/Sema.h index 8b470fe5c6c..a1026448867 100644 --- a/clang/Sema/Sema.h +++ b/clang/Sema/Sema.h @@ -560,7 +560,8 @@ public: // optional arguments. The number of types/arguments is obtained // from the Sel.getNumArgs(). 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. // ArgExprs is optional - if it is present, the number of expressions diff --git a/clang/Sema/SemaDecl.cpp b/clang/Sema/SemaDecl.cpp index dc1a9935191..2c016df7812 100644 --- a/clang/Sema/SemaDecl.cpp +++ b/clang/Sema/SemaDecl.cpp @@ -2119,7 +2119,8 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration( // optional arguments. The number of types/arguments is obtained // from the Sel.getNumArgs(). ObjcDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames, - AttributeList *AttrList, tok::ObjCKeywordKind MethodDeclKind) { + AttributeList *AttrList, tok::ObjCKeywordKind MethodDeclKind, + bool isVariadic) { llvm::SmallVector<ParmVarDecl*, 16> Params; for (unsigned i = 0; i < Sel.getNumArgs(); i++) { @@ -2148,7 +2149,7 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration( resultDeclType, CDecl, 0, -1, AttrList, - MethodType == tok::minus, + MethodType == tok::minus, isVariadic, MethodDeclKind == tok::objc_optional ? ObjcMethodDecl::Optional : ObjcMethodDecl::Required); diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index a475984b12b..fb0a8b4a36a 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -626,6 +626,8 @@ private: /// declared in class Decl. /// instance (true) or class (false) method. bool IsInstance : 1; + bool IsVariadic : 1; + /// @required/@optional ImplementationControl DeclImplementation : 2; @@ -657,11 +659,12 @@ public: Decl *contextDecl, ParmVarDecl **paramInfo = 0, int numParams=-1, AttributeList *M = 0, bool isInstance = true, + bool isVariadic = false, ImplementationControl impControl = None, Decl *PrevDecl = 0) : Decl(ObjcMethod, beginLoc), - IsInstance(isInstance), DeclImplementation(impControl), - objcDeclQualifier(OBJC_TQ_None), + IsInstance(isInstance), IsVariadic(isVariadic), + DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None), MethodContext(static_cast<NamedDecl*>(contextDecl)), SelName(SelInfo), MethodDeclType(T), ParamInfo(paramInfo), NumMethodParams(numParams), @@ -704,6 +707,8 @@ public: AttributeList *getMethodAttrs() const {return MethodAttrs;} bool isInstance() const { return IsInstance; } + bool isVariadic() const { return IsVariadic; } + // Related to protocols declared in @protocol void setDeclImplementation(ImplementationControl ic) { DeclImplementation = ic; diff --git a/clang/include/clang/Parse/Action.h b/clang/include/clang/Parse/Action.h index bfbcfb93dc3..e2aa1bad402 100644 --- a/clang/include/clang/Parse/Action.h +++ b/clang/include/clang/Parse/Action.h @@ -565,7 +565,8 @@ public: IdentifierInfo **ArgNames, // non-zero when Sel.getNumArgs() > 0 AttributeList *AttrList, // optional // tok::objc_not_keyword, tok::objc_optional, tok::objc_required - tok::ObjCKeywordKind impKind) { + tok::ObjCKeywordKind impKind, + bool isVariadic = false) { return 0; } // ActOnAtEnd - called to mark the @end. For declarations (interfaces, |