Index: clang/include/clang/AST/StmtObjC.h =================================================================== --- clang/include/clang/AST/StmtObjC.h +++ clang/include/clang/AST/StmtObjC.h @@ -162,8 +162,14 @@ }; /// Represents Objective-C's \@try ... \@catch ... \@finally statement. -class ObjCAtTryStmt : public Stmt { -private: +class ObjCAtTryStmt final + : public Stmt, + private llvm::TrailingObjects { + friend TrailingObjects; + size_t numTrailingObjects(OverloadToken) const { + return 1 + NumCatchStmts + HasFinally; + } + // The location of the @ in the \@try. SourceLocation AtTryLoc; @@ -178,10 +184,8 @@ /// The order of the statements in memory follows the order in the source, /// with the \@try body first, followed by the \@catch statements (if any) /// and, finally, the \@finally (if it exists). - Stmt **getStmts() { return reinterpret_cast (this + 1); } - const Stmt* const *getStmts() const { - return reinterpret_cast (this + 1); - } + Stmt **getStmts() { return getTrailingObjects(); } + Stmt *const *getStmts() const { return getTrailingObjects(); } ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, @@ -257,8 +261,8 @@ } child_range children() { - return child_range(getStmts(), - getStmts() + 1 + NumCatchStmts + HasFinally); + return child_range( + getStmts(), getStmts() + numTrailingObjects(OverloadToken())); } const_child_range children() const {