From 16f0049415ec596504891259e2a83e19871c0d52 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 26 Apr 2009 01:32:48 +0000 Subject: [PATCH] split ObjC and C++ Statements out into their own headers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70105 91177308-0d34-0410-b5e6-96231b3b80d8 --- clang.xcodeproj/project.pbxproj | 4 + include/clang/AST/Stmt.h | 312 ------------------ include/clang/AST/StmtObjC.h | 266 +++++++++++++++ include/clang/AST/StmtVisitor.h | 2 + .../Analysis/PathSensitive/GRExprEngine.h | 1 + lib/AST/Stmt.cpp | 2 + lib/Analysis/BugReporter.cpp | 4 +- lib/Analysis/GRExprEngine.cpp | 4 +- lib/CodeGen/CGObjC.cpp | 2 +- lib/CodeGen/CGObjCGNU.cpp | 1 + lib/CodeGen/CGObjCMac.cpp | 1 + lib/CodeGen/CodeGenFunction.h | 4 + lib/Frontend/PCHWriter.cpp | 1 - lib/Sema/JumpDiagnostics.cpp | 1 + lib/Sema/SemaStmt.cpp | 3 +- 15 files changed, 290 insertions(+), 318 deletions(-) create mode 100644 include/clang/AST/StmtObjC.h diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj index a92bcca1c4..c6001868eb 100644 --- a/clang.xcodeproj/project.pbxproj +++ b/clang.xcodeproj/project.pbxproj @@ -583,6 +583,8 @@ DECB6D640F9AE26600F5FBC7 /* JumpDiagnostics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JumpDiagnostics.cpp; path = lib/Sema/JumpDiagnostics.cpp; sourceTree = ""; }; DECB6F030F9D939A00F5FBC7 /* InitPreprocessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InitPreprocessor.h; path = clang/Frontend/InitPreprocessor.h; sourceTree = ""; }; DECB6F060F9D93A800F5FBC7 /* InitPreprocessor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InitPreprocessor.cpp; path = lib/Frontend/InitPreprocessor.cpp; sourceTree = ""; }; + DECB734E0FA3ED8400F5FBC7 /* StmtObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StmtObjC.h; path = clang/AST/StmtObjC.h; sourceTree = ""; }; + DECB73550FA3EE5A00F5FBC7 /* StmtCXX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StmtCXX.h; path = clang/AST/StmtCXX.h; sourceTree = ""; }; DED626C80AE0C065001E80A4 /* TargetInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; path = TargetInfo.cpp; sourceTree = ""; tabWidth = 2; }; DED62ABA0AE2EDF1001E80A4 /* Decl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = Decl.cpp; path = lib/AST/Decl.cpp; sourceTree = ""; tabWidth = 2; usesTabs = 0; }; DED676D00B6C786700AAD4A3 /* Builtins.def */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = text; name = Builtins.def; path = clang/AST/Builtins.def; sourceTree = ""; tabWidth = 2; }; @@ -1126,7 +1128,9 @@ 3547129D0C88881300B3E1D5 /* PrettyPrinter.h */, DE6951C60C4D1F5D00A5826B /* RecordLayout.h */, DE3452800AEF1B1800DBC861 /* Stmt.h */, + DECB73550FA3EE5A00F5FBC7 /* StmtCXX.h */, DE345F210AFD347900DBC861 /* StmtNodes.def */, + DECB734E0FA3ED8400F5FBC7 /* StmtObjC.h */, DE345C190AFC658B00DBC861 /* StmtVisitor.h */, 35847BE30CC7DB9000C40FFF /* StmtIterator.h */, 35CFFE010CA1CBDD00E6F2BE /* StmtGraphTraits.h */, diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 0bf4f67230..5165d2ab2e 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -1157,318 +1157,6 @@ public: virtual child_iterator child_end(); }; -/// ObjCForCollectionStmt - This represents Objective-c's collection statement; -/// represented as 'for (element 'in' collection-expression)' stmt. -/// -class ObjCForCollectionStmt : public Stmt { - enum { ELEM, COLLECTION, BODY, END_EXPR }; - Stmt* SubExprs[END_EXPR]; // SubExprs[ELEM] is an expression or declstmt. - SourceLocation ForLoc; - SourceLocation RParenLoc; -public: - ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, Stmt *Body, - SourceLocation FCL, SourceLocation RPL); - - Stmt *getElement() { return SubExprs[ELEM]; } - Expr *getCollection() { - return reinterpret_cast(SubExprs[COLLECTION]); - } - Stmt *getBody() { return SubExprs[BODY]; } - - const Stmt *getElement() const { return SubExprs[ELEM]; } - const Expr *getCollection() const { - return reinterpret_cast(SubExprs[COLLECTION]); - } - const Stmt *getBody() const { return SubExprs[BODY]; } - - SourceLocation getRParenLoc() const { return RParenLoc; } - - virtual SourceRange getSourceRange() const { - return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); - } - static bool classof(const Stmt *T) { - return T->getStmtClass() == ObjCForCollectionStmtClass; - } - static bool classof(const ObjCForCollectionStmt *) { return true; } - - // Iterators - virtual child_iterator child_begin(); - virtual child_iterator child_end(); -}; - -/// ObjCAtCatchStmt - This represents objective-c's @catch statement. -class ObjCAtCatchStmt : public Stmt { -private: - enum { BODY, NEXT_CATCH, END_EXPR }; - ParmVarDecl *ExceptionDecl; - Stmt *SubExprs[END_EXPR]; - SourceLocation AtCatchLoc, RParenLoc; - - // Used by deserialization. - ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc) - : Stmt(ObjCAtCatchStmtClass), AtCatchLoc(atCatchLoc), RParenLoc(rparenloc) {} - -public: - ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc, - ParmVarDecl *catchVarDecl, - Stmt *atCatchStmt, Stmt *atCatchList); - - const Stmt *getCatchBody() const { return SubExprs[BODY]; } - Stmt *getCatchBody() { return SubExprs[BODY]; } - - const ObjCAtCatchStmt *getNextCatchStmt() const { - return static_cast(SubExprs[NEXT_CATCH]); - } - ObjCAtCatchStmt *getNextCatchStmt() { - return static_cast(SubExprs[NEXT_CATCH]); - } - - const ParmVarDecl *getCatchParamDecl() const { - return ExceptionDecl; - } - ParmVarDecl *getCatchParamDecl() { - return ExceptionDecl; - } - - SourceLocation getAtCatchLoc() const { return AtCatchLoc; } - SourceLocation getRParenLoc() const { return RParenLoc; } - - virtual SourceRange getSourceRange() const { - return SourceRange(AtCatchLoc, SubExprs[BODY]->getLocEnd()); - } - - bool hasEllipsis() const { return getCatchParamDecl() == 0; } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == ObjCAtCatchStmtClass; - } - static bool classof(const ObjCAtCatchStmt *) { return true; } - - virtual child_iterator child_begin(); - virtual child_iterator child_end(); -}; - -/// ObjCAtFinallyStmt - This represent objective-c's @finally Statement -class ObjCAtFinallyStmt : public Stmt { - Stmt *AtFinallyStmt; - SourceLocation AtFinallyLoc; -public: - ObjCAtFinallyStmt(SourceLocation atFinallyLoc, Stmt *atFinallyStmt) - : Stmt(ObjCAtFinallyStmtClass), - AtFinallyStmt(atFinallyStmt), AtFinallyLoc(atFinallyLoc) {} - - const Stmt *getFinallyBody() const { return AtFinallyStmt; } - Stmt *getFinallyBody() { return AtFinallyStmt; } - - virtual SourceRange getSourceRange() const { - return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd()); - } - - SourceLocation getAtFinallyLoc() const { return AtFinallyLoc; } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == ObjCAtFinallyStmtClass; - } - static bool classof(const ObjCAtFinallyStmt *) { return true; } - - virtual child_iterator child_begin(); - virtual child_iterator child_end(); -}; - -/// ObjCAtTryStmt - This represent objective-c's over-all -/// @try ... @catch ... @finally statement. -class ObjCAtTryStmt : public Stmt { -private: - enum { TRY, CATCH, FINALLY, END_EXPR }; - Stmt* SubStmts[END_EXPR]; - - SourceLocation AtTryLoc; -public: - ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, - Stmt *atCatchStmt, - Stmt *atFinallyStmt) - : Stmt(ObjCAtTryStmtClass) { - SubStmts[TRY] = atTryStmt; - SubStmts[CATCH] = atCatchStmt; - SubStmts[FINALLY] = atFinallyStmt; - AtTryLoc = atTryLoc; - } - - SourceLocation getAtTryLoc() const { return AtTryLoc; } - const Stmt *getTryBody() const { return SubStmts[TRY]; } - Stmt *getTryBody() { return SubStmts[TRY]; } - const ObjCAtCatchStmt *getCatchStmts() const { - return dyn_cast_or_null(SubStmts[CATCH]); - } - ObjCAtCatchStmt *getCatchStmts() { - return dyn_cast_or_null(SubStmts[CATCH]); - } - const ObjCAtFinallyStmt *getFinallyStmt() const { - return dyn_cast_or_null(SubStmts[FINALLY]); - } - ObjCAtFinallyStmt *getFinallyStmt() { - return dyn_cast_or_null(SubStmts[FINALLY]); - } - virtual SourceRange getSourceRange() const { - return SourceRange(AtTryLoc, SubStmts[TRY]->getLocEnd()); - } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == ObjCAtTryStmtClass; - } - static bool classof(const ObjCAtTryStmt *) { return true; } - - virtual child_iterator child_begin(); - virtual child_iterator child_end(); -}; - -/// ObjCAtSynchronizedStmt - This is for objective-c's @synchronized statement. -/// Example: @synchronized (sem) { -/// do-something; -/// } -/// -class ObjCAtSynchronizedStmt : public Stmt { -private: - enum { SYNC_EXPR, SYNC_BODY, END_EXPR }; - Stmt* SubStmts[END_EXPR]; - SourceLocation AtSynchronizedLoc; - -public: - ObjCAtSynchronizedStmt(SourceLocation atSynchronizedLoc, Stmt *synchExpr, - Stmt *synchBody) - : Stmt(ObjCAtSynchronizedStmtClass) { - SubStmts[SYNC_EXPR] = synchExpr; - SubStmts[SYNC_BODY] = synchBody; - AtSynchronizedLoc = atSynchronizedLoc; - } - - SourceLocation getAtSynchronizedLoc() const { return AtSynchronizedLoc; } - - const CompoundStmt *getSynchBody() const { - return reinterpret_cast(SubStmts[SYNC_BODY]); - } - CompoundStmt *getSynchBody() { - return reinterpret_cast(SubStmts[SYNC_BODY]); - } - - const Expr *getSynchExpr() const { - return reinterpret_cast(SubStmts[SYNC_EXPR]); - } - Expr *getSynchExpr() { - return reinterpret_cast(SubStmts[SYNC_EXPR]); - } - - virtual SourceRange getSourceRange() const { - return SourceRange(AtSynchronizedLoc, getSynchBody()->getLocEnd()); - } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == ObjCAtSynchronizedStmtClass; - } - static bool classof(const ObjCAtSynchronizedStmt *) { return true; } - - virtual child_iterator child_begin(); - virtual child_iterator child_end(); -}; - -/// ObjCAtThrowStmt - This represents objective-c's @throw statement. -class ObjCAtThrowStmt : public Stmt { - Stmt *Throw; - SourceLocation AtThrowLoc; -public: - ObjCAtThrowStmt(SourceLocation atThrowLoc, Stmt *throwExpr) - : Stmt(ObjCAtThrowStmtClass), Throw(throwExpr) { - AtThrowLoc = atThrowLoc; - } - - const Expr *getThrowExpr() const { return reinterpret_cast(Throw); } - Expr *getThrowExpr() { return reinterpret_cast(Throw); } - - virtual SourceRange getSourceRange() const { - if (Throw) - return SourceRange(AtThrowLoc, Throw->getLocEnd()); - else - return SourceRange(AtThrowLoc); - } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == ObjCAtThrowStmtClass; - } - static bool classof(const ObjCAtThrowStmt *) { return true; } - - virtual child_iterator child_begin(); - virtual child_iterator child_end(); -}; - -/// CXXCatchStmt - This represents a C++ catch block. -class CXXCatchStmt : public Stmt { - SourceLocation CatchLoc; - /// The exception-declaration of the type. - Decl *ExceptionDecl; - /// The handler block. - Stmt *HandlerBlock; - -public: - CXXCatchStmt(SourceLocation catchLoc, Decl *exDecl, Stmt *handlerBlock) - : Stmt(CXXCatchStmtClass), CatchLoc(catchLoc), ExceptionDecl(exDecl), - HandlerBlock(handlerBlock) {} - - virtual void Destroy(ASTContext& Ctx); - - virtual SourceRange getSourceRange() const { - return SourceRange(CatchLoc, HandlerBlock->getLocEnd()); - } - - Decl *getExceptionDecl() { return ExceptionDecl; } - QualType getCaughtType(); - Stmt *getHandlerBlock() { return HandlerBlock; } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == CXXCatchStmtClass; - } - static bool classof(const CXXCatchStmt *) { return true; } - - virtual child_iterator child_begin(); - virtual child_iterator child_end(); -}; - -/// CXXTryStmt - A C++ try block, including all handlers. -class CXXTryStmt : public Stmt { - SourceLocation TryLoc; - // First place is the guarded CompoundStatement. Subsequent are the handlers. - // More than three handlers should be rare. - llvm::SmallVector Stmts; - -public: - CXXTryStmt(SourceLocation tryLoc, Stmt *tryBlock, - Stmt **handlers, unsigned numHandlers); - - virtual SourceRange getSourceRange() const { - return SourceRange(TryLoc, Stmts.back()->getLocEnd()); - } - - CompoundStmt *getTryBlock() { return llvm::cast(Stmts[0]); } - const CompoundStmt *getTryBlock() const { - return llvm::cast(Stmts[0]); - } - - unsigned getNumHandlers() const { return Stmts.size() - 1; } - CXXCatchStmt *getHandler(unsigned i) { - return llvm::cast(Stmts[i + 1]); - } - const CXXCatchStmt *getHandler(unsigned i) const { - return llvm::cast(Stmts[i + 1]); - } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == CXXTryStmtClass; - } - static bool classof(const CXXTryStmt *) { return true; } - - virtual child_iterator child_begin(); - virtual child_iterator child_end(); -}; - } // end namespace clang #endif diff --git a/include/clang/AST/StmtObjC.h b/include/clang/AST/StmtObjC.h new file mode 100644 index 0000000000..b9ac8fd045 --- /dev/null +++ b/include/clang/AST/StmtObjC.h @@ -0,0 +1,266 @@ +//===--- StmtObjC.h - Classes for representing ObjC statements --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the Objective-C statement AST node classes. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_AST_STMTOBJC_H +#define LLVM_CLANG_AST_STMTOBJC_H + +#include "clang/AST/Stmt.h" + +namespace clang { + +/// ObjCForCollectionStmt - This represents Objective-c's collection statement; +/// represented as 'for (element 'in' collection-expression)' stmt. +/// +class ObjCForCollectionStmt : public Stmt { + enum { ELEM, COLLECTION, BODY, END_EXPR }; + Stmt* SubExprs[END_EXPR]; // SubExprs[ELEM] is an expression or declstmt. + SourceLocation ForLoc; + SourceLocation RParenLoc; +public: + ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, Stmt *Body, + SourceLocation FCL, SourceLocation RPL); + + Stmt *getElement() { return SubExprs[ELEM]; } + Expr *getCollection() { + return reinterpret_cast(SubExprs[COLLECTION]); + } + Stmt *getBody() { return SubExprs[BODY]; } + + const Stmt *getElement() const { return SubExprs[ELEM]; } + const Expr *getCollection() const { + return reinterpret_cast(SubExprs[COLLECTION]); + } + const Stmt *getBody() const { return SubExprs[BODY]; } + + SourceLocation getRParenLoc() const { return RParenLoc; } + + virtual SourceRange getSourceRange() const { + return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); + } + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjCForCollectionStmtClass; + } + static bool classof(const ObjCForCollectionStmt *) { return true; } + + // Iterators + virtual child_iterator child_begin(); + virtual child_iterator child_end(); +}; + +/// ObjCAtCatchStmt - This represents objective-c's @catch statement. +class ObjCAtCatchStmt : public Stmt { +private: + enum { BODY, NEXT_CATCH, END_EXPR }; + ParmVarDecl *ExceptionDecl; + Stmt *SubExprs[END_EXPR]; + SourceLocation AtCatchLoc, RParenLoc; + + // Used by deserialization. + ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc) + : Stmt(ObjCAtCatchStmtClass), AtCatchLoc(atCatchLoc), RParenLoc(rparenloc) {} + +public: + ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc, + ParmVarDecl *catchVarDecl, + Stmt *atCatchStmt, Stmt *atCatchList); + + const Stmt *getCatchBody() const { return SubExprs[BODY]; } + Stmt *getCatchBody() { return SubExprs[BODY]; } + + const ObjCAtCatchStmt *getNextCatchStmt() const { + return static_cast(SubExprs[NEXT_CATCH]); + } + ObjCAtCatchStmt *getNextCatchStmt() { + return static_cast(SubExprs[NEXT_CATCH]); + } + + const ParmVarDecl *getCatchParamDecl() const { + return ExceptionDecl; + } + ParmVarDecl *getCatchParamDecl() { + return ExceptionDecl; + } + + SourceLocation getAtCatchLoc() const { return AtCatchLoc; } + SourceLocation getRParenLoc() const { return RParenLoc; } + + virtual SourceRange getSourceRange() const { + return SourceRange(AtCatchLoc, SubExprs[BODY]->getLocEnd()); + } + + bool hasEllipsis() const { return getCatchParamDecl() == 0; } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjCAtCatchStmtClass; + } + static bool classof(const ObjCAtCatchStmt *) { return true; } + + virtual child_iterator child_begin(); + virtual child_iterator child_end(); +}; + +/// ObjCAtFinallyStmt - This represent objective-c's @finally Statement +class ObjCAtFinallyStmt : public Stmt { + Stmt *AtFinallyStmt; + SourceLocation AtFinallyLoc; +public: + ObjCAtFinallyStmt(SourceLocation atFinallyLoc, Stmt *atFinallyStmt) + : Stmt(ObjCAtFinallyStmtClass), + AtFinallyStmt(atFinallyStmt), AtFinallyLoc(atFinallyLoc) {} + + const Stmt *getFinallyBody() const { return AtFinallyStmt; } + Stmt *getFinallyBody() { return AtFinallyStmt; } + + virtual SourceRange getSourceRange() const { + return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd()); + } + + SourceLocation getAtFinallyLoc() const { return AtFinallyLoc; } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjCAtFinallyStmtClass; + } + static bool classof(const ObjCAtFinallyStmt *) { return true; } + + virtual child_iterator child_begin(); + virtual child_iterator child_end(); +}; + +/// ObjCAtTryStmt - This represent objective-c's over-all +/// @try ... @catch ... @finally statement. +class ObjCAtTryStmt : public Stmt { +private: + enum { TRY, CATCH, FINALLY, END_EXPR }; + Stmt* SubStmts[END_EXPR]; + + SourceLocation AtTryLoc; +public: + ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, + Stmt *atCatchStmt, + Stmt *atFinallyStmt) + : Stmt(ObjCAtTryStmtClass) { + SubStmts[TRY] = atTryStmt; + SubStmts[CATCH] = atCatchStmt; + SubStmts[FINALLY] = atFinallyStmt; + AtTryLoc = atTryLoc; + } + + SourceLocation getAtTryLoc() const { return AtTryLoc; } + const Stmt *getTryBody() const { return SubStmts[TRY]; } + Stmt *getTryBody() { return SubStmts[TRY]; } + const ObjCAtCatchStmt *getCatchStmts() const { + return dyn_cast_or_null(SubStmts[CATCH]); + } + ObjCAtCatchStmt *getCatchStmts() { + return dyn_cast_or_null(SubStmts[CATCH]); + } + const ObjCAtFinallyStmt *getFinallyStmt() const { + return dyn_cast_or_null(SubStmts[FINALLY]); + } + ObjCAtFinallyStmt *getFinallyStmt() { + return dyn_cast_or_null(SubStmts[FINALLY]); + } + virtual SourceRange getSourceRange() const { + return SourceRange(AtTryLoc, SubStmts[TRY]->getLocEnd()); + } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjCAtTryStmtClass; + } + static bool classof(const ObjCAtTryStmt *) { return true; } + + virtual child_iterator child_begin(); + virtual child_iterator child_end(); +}; + +/// ObjCAtSynchronizedStmt - This is for objective-c's @synchronized statement. +/// Example: @synchronized (sem) { +/// do-something; +/// } +/// +class ObjCAtSynchronizedStmt : public Stmt { +private: + enum { SYNC_EXPR, SYNC_BODY, END_EXPR }; + Stmt* SubStmts[END_EXPR]; + SourceLocation AtSynchronizedLoc; + +public: + ObjCAtSynchronizedStmt(SourceLocation atSynchronizedLoc, Stmt *synchExpr, + Stmt *synchBody) + : Stmt(ObjCAtSynchronizedStmtClass) { + SubStmts[SYNC_EXPR] = synchExpr; + SubStmts[SYNC_BODY] = synchBody; + AtSynchronizedLoc = atSynchronizedLoc; + } + + SourceLocation getAtSynchronizedLoc() const { return AtSynchronizedLoc; } + + const CompoundStmt *getSynchBody() const { + return reinterpret_cast(SubStmts[SYNC_BODY]); + } + CompoundStmt *getSynchBody() { + return reinterpret_cast(SubStmts[SYNC_BODY]); + } + + const Expr *getSynchExpr() const { + return reinterpret_cast(SubStmts[SYNC_EXPR]); + } + Expr *getSynchExpr() { + return reinterpret_cast(SubStmts[SYNC_EXPR]); + } + + virtual SourceRange getSourceRange() const { + return SourceRange(AtSynchronizedLoc, getSynchBody()->getLocEnd()); + } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjCAtSynchronizedStmtClass; + } + static bool classof(const ObjCAtSynchronizedStmt *) { return true; } + + virtual child_iterator child_begin(); + virtual child_iterator child_end(); +}; + +/// ObjCAtThrowStmt - This represents objective-c's @throw statement. +class ObjCAtThrowStmt : public Stmt { + Stmt *Throw; + SourceLocation AtThrowLoc; +public: + ObjCAtThrowStmt(SourceLocation atThrowLoc, Stmt *throwExpr) + : Stmt(ObjCAtThrowStmtClass), Throw(throwExpr) { + AtThrowLoc = atThrowLoc; + } + + const Expr *getThrowExpr() const { return reinterpret_cast(Throw); } + Expr *getThrowExpr() { return reinterpret_cast(Throw); } + + virtual SourceRange getSourceRange() const { + if (Throw) + return SourceRange(AtThrowLoc, Throw->getLocEnd()); + else + return SourceRange(AtThrowLoc); + } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjCAtThrowStmtClass; + } + static bool classof(const ObjCAtThrowStmt *) { return true; } + + virtual child_iterator child_begin(); + virtual child_iterator child_end(); +}; + +} // end namespace clang + +#endif diff --git a/include/clang/AST/StmtVisitor.h b/include/clang/AST/StmtVisitor.h index 2b0dd89158..4f4066ab86 100644 --- a/include/clang/AST/StmtVisitor.h +++ b/include/clang/AST/StmtVisitor.h @@ -16,6 +16,8 @@ #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" +#include "clang/AST/StmtCXX.h" +#include "clang/AST/StmtObjC.h" namespace clang { diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h index bc036b6a19..c3b81bf83f 100644 --- a/include/clang/Analysis/PathSensitive/GRExprEngine.h +++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h @@ -28,6 +28,7 @@ namespace clang { class PathDiagnosticClient; class Diagnostic; + class ObjCForCollectionStmt; class GRExprEngine { public: diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index 67910c8ab6..02f5eee828 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -14,6 +14,8 @@ #include "clang/AST/Stmt.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" +#include "clang/AST/StmtCXX.h" +#include "clang/AST/StmtObjC.h" #include "clang/AST/Type.h" #include "clang/AST/ASTContext.h" #include "clang/AST/ASTDiagnostic.h" diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp index b64182e2f3..d1dbe1cd08 100644 --- a/lib/Analysis/BugReporter.cpp +++ b/lib/Analysis/BugReporter.cpp @@ -14,12 +14,12 @@ #include "clang/Analysis/PathSensitive/BugReporter.h" #include "clang/Analysis/PathSensitive/GRExprEngine.h" -#include "clang/Basic/SourceManager.h" -#include "clang/Basic/SourceLocation.h" #include "clang/AST/ASTContext.h" #include "clang/AST/CFG.h" #include "clang/AST/Expr.h" #include "clang/AST/ParentMap.h" +#include "clang/AST/StmtObjC.h" +#include "clang/Basic/SourceManager.h" #include "clang/Analysis/ProgramPoint.h" #include "clang/Analysis/PathDiagnostic.h" #include "llvm/Support/raw_ostream.h" diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 5a3f9871f7..096ccddd08 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -13,10 +13,12 @@ // //===----------------------------------------------------------------------===// -#include "clang/AST/ParentMap.h" #include "clang/Analysis/PathSensitive/GRExprEngine.h" #include "clang/Analysis/PathSensitive/GRExprEngineBuilders.h" #include "clang/Analysis/PathSensitive/BugReporter.h" +#include "clang/AST/ParentMap.h" +#include "clang/AST/StmtObjC.h" +#include "clang/Basic/SourceManager.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/PrettyStackTrace.h" #include "llvm/Support/Streams.h" diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index 0204246e56..df49c70ec6 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -16,10 +16,10 @@ #include "CodeGenModule.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/StmtObjC.h" #include "clang/Basic/Diagnostic.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Target/TargetData.h" - using namespace clang; using namespace CodeGen; diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index c6221ff925..d3b020d57e 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -20,6 +20,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/StmtObjC.h" #include "llvm/Module.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 5c2dbf8110..faab3cfe10 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -18,6 +18,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/StmtObjC.h" #include "clang/Basic/LangOptions.h" #include "llvm/Intrinsics.h" diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 9fc59527ce..3db7a2e09d 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -50,6 +50,10 @@ namespace clang { class ObjCPropertyImplDecl; class TargetInfo; class VarDecl; + class ObjCForCollectionStmt; + class ObjCAtTryStmt; + class ObjCAtThrowStmt; + class ObjCAtSynchronizedStmt; namespace CodeGen { class CodeGenModule; diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index f648a75650..9056f58c6f 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -1253,7 +1253,6 @@ void PCHStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr *E) { void PCHStmtWriter::VisitObjCSuperExpr(ObjCSuperExpr *E) { VisitExpr(E); Writer.AddSourceLocation(E->getLoc(), Record); - } diff --git a/lib/Sema/JumpDiagnostics.cpp b/lib/Sema/JumpDiagnostics.cpp index b812f06f76..20473e4306 100644 --- a/lib/Sema/JumpDiagnostics.cpp +++ b/lib/Sema/JumpDiagnostics.cpp @@ -14,6 +14,7 @@ #include "Sema.h" #include "clang/AST/Expr.h" +#include "clang/AST/StmtObjC.h" using namespace clang; namespace { diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index fb8a8ece43..1ee8188ec2 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -16,7 +16,8 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/Expr.h" -#include "clang/AST/ASTContext.h" +#include "clang/AST/StmtObjC.h" +#include "clang/AST/StmtCXX.h" #include "clang/Basic/TargetInfo.h" using namespace clang;