[cfe-commits] r46520 - in /cfe/trunk: AST/StmtPrinter.cpp Parse/ParseObjc.cpp Parse/ParseStmt.cpp include/clang/AST/Stmt.h include/clang/AST/StmtNodes.def include/clang/Parse/Parser.h
Fariborz Jahanian
fjahanian at apple.com
Tue Jan 29 10:21:32 PST 2008
Author: fjahanian
Date: Tue Jan 29 12:21:32 2008
New Revision: 46520
URL: http://llvm.org/viewvc/llvm-project?rev=46520&view=rev
Log:
Bunch of type defs, etc. for @synchronized.
Modified:
cfe/trunk/AST/StmtPrinter.cpp
cfe/trunk/Parse/ParseObjc.cpp
cfe/trunk/Parse/ParseStmt.cpp
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/AST/StmtNodes.def
cfe/trunk/include/clang/Parse/Parser.h
Modified: cfe/trunk/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtPrinter.cpp?rev=46520&r1=46519&r2=46520&view=diff
==============================================================================
--- cfe/trunk/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/AST/StmtPrinter.cpp Tue Jan 29 12:21:32 2008
@@ -455,6 +455,17 @@
OS << ";\n";
}
+void StmtPrinter::VisitObjCAtSynchronizedStmt (ObjCAtSynchronizedStmt *Node) {
+ Indent() << "@synchronized (";
+ PrintExpr(Node->getSynchExpr());
+ OS << ")";
+ if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getSynchBody()))
+ {
+ PrintRawCompoundStmt(CS);
+ OS << "\n";
+ }
+}
+
//===----------------------------------------------------------------------===//
// Expr printing methods.
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=46520&r1=46519&r2=46520&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Tue Jan 29 12:21:32 2008
@@ -1109,6 +1109,13 @@
return Actions.ActOnObjCAtThrowStmt(atLoc, Res.Val);
}
+/// objc-synchronized-statement:
+/// @synchronized '(' expression ')'
+///
+Parser::StmtResult Parser::ParseObjCSynchronizedStmt(SourceLocation atLoc) {
+ return 0;
+}
+
/// objc-try-catch-statement:
/// @try compound-statement objc-catch-list[opt]
/// @try compound-statement objc-catch-list[opt] @finally compound-statement
Modified: cfe/trunk/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseStmt.cpp?rev=46520&r1=46519&r2=46520&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/Parse/ParseStmt.cpp Tue Jan 29 12:21:32 2008
@@ -36,7 +36,7 @@
/// jump-statement
/// [OBC] objc-throw-statement
/// [OBC] objc-try-catch-statement
-/// [OBC] objc-synchronized-statement [TODO]
+/// [OBC] objc-synchronized-statement
/// [GNU] asm-statement
/// [OMP] openmp-construct [TODO]
///
@@ -91,6 +91,8 @@
return ParseObjCTryStmt(AtLoc);
else if (Tok.isObjCAtKeyword(tok::objc_throw))
return ParseObjCThrowStmt(AtLoc);
+ else if (Tok.isObjCAtKeyword(tok::objc_synchronized))
+ return ParseObjCSynchronizedStmt(AtLoc);
ExprResult Res = ParseExpressionWithLeadingAt(AtLoc);
if (Res.isInvalid) {
// If the expression is invalid, skip ahead to the next semicolon. Not
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=46520&r1=46519&r2=46520&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Tue Jan 29 12:21:32 2008
@@ -962,6 +962,40 @@
static ObjCAtTryStmt* CreateImpl(llvm::Deserializer& D);
};
+/// ObjCAtSynchronizedStmt - This is for objective-c's @synchronized statement.
+///
+class ObjCAtSynchronizedStmt : public Stmt {
+private:
+ Expr* SynchExpr;
+ Stmt* SynchBody;
+ SourceLocation AtSynchronizedLoc;
+
+public:
+ ObjCAtSynchronizedStmt(SourceLocation atSynchronizedLoc, Expr *synchExpr,
+ Stmt *synchBody)
+ : Stmt(ObjCAtSynchronizedStmtClass),
+ SynchExpr(synchExpr), SynchBody(synchBody),
+ AtSynchronizedLoc(atSynchronizedLoc) {}
+
+ const Stmt *getSynchBody() const { return SynchBody; }
+ Stmt *getSynchBody() { return SynchBody; }
+
+ const Expr *getSynchExpr() const { return SynchExpr; }
+ Expr *getSynchExpr() { return SynchExpr; }
+
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(AtSynchronizedLoc, SynchBody->getLocEnd());
+ }
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ObjCAtSynchronizedStmtClass;
+ }
+ static bool classof(const ObjCAtSynchronizedStmt *) { return true; }
+
+ virtual void EmitImpl(llvm::Serializer& S) const;
+ static ObjCAtSynchronizedStmt* CreateImpl(llvm::Deserializer& D);
+};
+
/// ObjCAtThrowStmt - This represents objective-c's @throw statement.
class ObjCAtThrowStmt : public Stmt {
Stmt *Throw;
Modified: cfe/trunk/include/clang/AST/StmtNodes.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtNodes.def?rev=46520&r1=46519&r2=46520&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/StmtNodes.def (original)
+++ cfe/trunk/include/clang/AST/StmtNodes.def Tue Jan 29 12:21:32 2008
@@ -49,8 +49,9 @@
STMT(20, ObjCAtCatchStmt , Stmt)
STMT(21, ObjCAtFinallyStmt , Stmt)
STMT(22, ObjCAtThrowStmt , Stmt)
+STMT(23, ObjCAtSynchronizedStmt , Stmt)
// Obj-C2 statements
-STMT(23, ObjCForCollectionStmt, Stmt)
+STMT(24, ObjCForCollectionStmt, Stmt)
LAST_STMT(23)
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=46520&r1=46519&r2=46520&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Jan 29 12:21:32 2008
@@ -405,6 +405,7 @@
StmtResult ParseAsmStatement();
StmtResult ParseObjCTryStmt(SourceLocation atLoc);
StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
+ StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc);
void ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &Names,
llvm::SmallVectorImpl<ExprTy*> &Constraints,
llvm::SmallVectorImpl<ExprTy*> &Exprs);
More information about the cfe-commits
mailing list