[cfe-commits] r46524 - in /cfe/trunk: AST/Stmt.cpp AST/StmtSerialization.cpp Parse/ParseObjc.cpp Sema/Sema.h Sema/SemaStmt.cpp include/clang/AST/Stmt.h include/clang/Parse/Action.h
Fariborz Jahanian
fjahanian at apple.com
Tue Jan 29 11:14:59 PST 2008
Author: fjahanian
Date: Tue Jan 29 13:14:59 2008
New Revision: 46524
URL: http://llvm.org/viewvc/llvm-project?rev=46524&view=rev
Log:
AST for @synchronized.
Modified:
cfe/trunk/AST/Stmt.cpp
cfe/trunk/AST/StmtSerialization.cpp
cfe/trunk/Parse/ParseObjc.cpp
cfe/trunk/Sema/Sema.h
cfe/trunk/Sema/SemaStmt.cpp
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Parse/Action.h
Modified: cfe/trunk/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Stmt.cpp?rev=46524&r1=46523&r2=46524&view=diff
==============================================================================
--- cfe/trunk/AST/Stmt.cpp (original)
+++ cfe/trunk/AST/Stmt.cpp Tue Jan 29 13:14:59 2008
@@ -249,3 +249,13 @@
Stmt::child_iterator ObjCAtThrowStmt::child_end() {
return &Throw+1;
}
+
+// ObjCAtSynchronizedStmt
+Stmt::child_iterator ObjCAtSynchronizedStmt::child_begin() {
+ return &SynchBody;
+}
+
+Stmt::child_iterator ObjCAtSynchronizedStmt::child_end() {
+ return &SynchBody+1;
+}
+
Modified: cfe/trunk/AST/StmtSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtSerialization.cpp?rev=46524&r1=46523&r2=46524&view=diff
==============================================================================
--- cfe/trunk/AST/StmtSerialization.cpp (original)
+++ cfe/trunk/AST/StmtSerialization.cpp Tue Jan 29 13:14:59 2008
@@ -893,6 +893,20 @@
Stmt* Throw = D.ReadOwnedPtr<Stmt>();
return new ObjCAtThrowStmt(L,Throw);
}
+
+void ObjCAtSynchronizedStmt::EmitImpl(Serializer& S) const {
+ S.Emit(AtSynchronizedLoc);
+ S.EmitOwnedPtr(SynchExpr);
+ S.EmitOwnedPtr(SynchBody);
+}
+
+ObjCAtSynchronizedStmt* ObjCAtSynchronizedStmt::CreateImpl(Deserializer& D) {
+ SourceLocation L = SourceLocation::ReadVal(D);
+ Expr *syncExpr = D.ReadOwnedPtr<Expr>();
+ Stmt *synchBody = D.ReadOwnedPtr<Stmt>();
+ ObjCAtSynchronizedStmt* stmt = new ObjCAtSynchronizedStmt(L,syncExpr,synchBody);
+ return stmt;
+}
void ObjCAtTryStmt::EmitImpl(Serializer& S) const {
S.Emit(AtTryLoc);
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=46524&r1=46523&r2=46524&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Tue Jan 29 13:14:59 2008
@@ -1113,7 +1113,27 @@
/// @synchronized '(' expression ')'
///
Parser::StmtResult Parser::ParseObjCSynchronizedStmt(SourceLocation atLoc) {
- return 0;
+ ExprResult Res;
+ ConsumeToken(); // consume synchronized
+ if (Tok.isNot(tok::l_paren)) {
+ Diag (Tok, diag::err_expected_lparen_after, "@synchronized");
+ return true;
+ }
+ ConsumeParen(); // '('
+ Res = ParseExpression();
+ if (Res.isInvalid) {
+ SkipUntil(tok::semi);
+ return true;
+ }
+ if (Tok.isNot(tok::r_paren)) {
+ Diag (Tok, diag::err_expected_rparen);
+ return true;
+ }
+ ConsumeParen(); // ')'
+ StmtResult SynchBody = ParseCompoundStatementBody();
+ if (SynchBody.isInvalid)
+ SynchBody = Actions.ActOnNullStmt(Tok.getLocation());
+ return Actions.ActOnObjCAtSynchronizedStmt(atLoc, Res.Val, SynchBody.Val);
}
/// objc-try-catch-statement:
Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=46524&r1=46523&r2=46524&view=diff
==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Tue Jan 29 13:14:59 2008
@@ -378,6 +378,9 @@
virtual StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
StmtTy *Throw);
+ virtual StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
+ ExprTy *SynchExpr,
+ StmtTy *SynchBody);
//===--------------------------------------------------------------------===//
// Expression Parsing Callbacks: SemaExpr.cpp.
Modified: cfe/trunk/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaStmt.cpp?rev=46524&r1=46523&r2=46524&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/Sema/SemaStmt.cpp Tue Jan 29 13:14:59 2008
@@ -809,5 +809,12 @@
return TS;
}
+Action::StmtResult
+Sema::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, ExprTy *SynchExpr,
+ StmtTy *SynchBody) {
+ ObjCAtSynchronizedStmt *SS = new ObjCAtSynchronizedStmt(AtLoc,
+ static_cast<Expr*>(SynchExpr), static_cast<Stmt*>(SynchBody));
+ return SS;
+}
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=46524&r1=46523&r2=46524&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Tue Jan 29 13:14:59 2008
@@ -992,6 +992,9 @@
}
static bool classof(const ObjCAtSynchronizedStmt *) { return true; }
+ virtual child_iterator child_begin();
+ virtual child_iterator child_end();
+
virtual void EmitImpl(llvm::Serializer& S) const;
static ObjCAtSynchronizedStmt* CreateImpl(llvm::Deserializer& D);
};
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=46524&r1=46523&r2=46524&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Tue Jan 29 13:14:59 2008
@@ -335,6 +335,12 @@
return 0;
}
+ virtual StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
+ ExprTy *SynchExpr,
+ StmtTy *SynchBody) {
+ return 0;
+ }
+
//===--------------------------------------------------------------------===//
// Expression Parsing Callbacks.
//===--------------------------------------------------------------------===//
More information about the cfe-commits
mailing list