@@ -489,6 +489,94 @@ class ObjCOrigExpr : public Expr {
489489 }
490490};
491491
492+
493+ // / ObjCInitExpr, used for \@init in ObjC-Logos. \@orig has the same
494+ // / type as the return type of the Objective-C method it is used in.
495+ class ObjCInitExpr : public Expr {
496+
497+ public:
498+ SmallVector<ObjCGroupDecl*, 5 > Args;
499+ private:
500+
501+ enum { NumArgsBitWidth = 16 };
502+
503+ // / \brief The number of arguments in the message send, not
504+ // / including the receiver.
505+ unsigned NumArgs : NumArgsBitWidth;
506+
507+ void setNumArgs (unsigned Num) {
508+ assert ((Num >> NumArgsBitWidth) == 0 && " Num of args is out of range!" );
509+ NumArgs = Num;
510+ }
511+
512+ SourceLocation AtLoc, RParenLoc;
513+
514+ public:
515+ ObjCInitExpr (QualType type, ArrayRef<ObjCGroupDecl*> Args,
516+ SourceLocation at, SourceLocation rp);
517+
518+ explicit ObjCInitExpr (EmptyShell Empty) : Expr(ObjCInitExprClass, Empty){}
519+
520+
521+ SourceLocation getAtLoc () const { return AtLoc; }
522+ void setAtLoc (SourceLocation L) { AtLoc = L; }
523+ SourceLocation getRParenLoc () const { return RParenLoc; }
524+ void setRParenLoc (SourceLocation L) { RParenLoc = L; }
525+
526+ // / \brief Return the number of arguments
527+ unsigned getNumArgs () const { return NumArgs; }
528+
529+ // / \brief Retrieve the arguments to this message, not including the
530+ // / receiver.
531+ Expr **getArgs () {
532+ return reinterpret_cast <Expr **>(this + 1 ) + 1 ;
533+ }
534+ const Expr * const *getArgs () const {
535+ return reinterpret_cast <const Expr * const *>(this + 1 ) + 1 ;
536+ }
537+
538+ // / getArg - Return the specified argument.
539+ Expr *getArg (unsigned Arg) {
540+ assert (Arg < NumArgs && " Arg access out of range!" );
541+ return cast<Expr>(getArgs ()[Arg]);
542+ }
543+ const Expr *getArg (unsigned Arg) const {
544+ assert (Arg < NumArgs && " Arg access out of range!" );
545+ return cast<Expr>(getArgs ()[Arg]);
546+ }
547+ // / setArg - Set the specified argument.
548+ void setArg (unsigned Arg, Expr *ArgExpr) {
549+ assert (Arg < NumArgs && " Arg access out of range!" );
550+ getArgs ()[Arg] = ArgExpr;
551+ }
552+
553+ child_range children ();
554+
555+ typedef ExprIterator arg_iterator;
556+ typedef ConstExprIterator const_arg_iterator;
557+
558+ arg_iterator arg_begin () { return reinterpret_cast <Stmt **>(getArgs ()); }
559+ arg_iterator arg_end () {
560+ return reinterpret_cast <Stmt **>(getArgs () + NumArgs);
561+ }
562+ const_arg_iterator arg_begin () const {
563+ return reinterpret_cast <Stmt const * const *>(getArgs ());
564+ }
565+ const_arg_iterator arg_end () const {
566+ return reinterpret_cast <Stmt const * const *>(getArgs () + NumArgs);
567+ }
568+
569+ SourceLocation getLocStart () const LLVM_READONLY { return AtLoc; }
570+ SourceLocation getLocEnd () const LLVM_READONLY { return RParenLoc; }
571+
572+ SourceLocation getBeginLoc () const LLVM_READONLY { return AtLoc; }
573+ SourceLocation getEndLoc () const LLVM_READONLY { return RParenLoc; }
574+
575+ static bool classof (const Stmt *T) {
576+ return T->getStmtClass () == ObjCInitExprClass;
577+ }
578+ };
579+
492580// / ObjCEncodeExpr, used for \@encode in Objective-C. \@encode has the same
493581// / type and behavior as StringLiteral except that the string initializer is
494582// / obtained from ASTContext with the encoding type as an argument.
0 commit comments