aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2007-11-02 00:18:53 +0000
committerFariborz Jahanian <fjahanian@apple.com>2007-11-02 00:18:53 +0000
commit161a9c5afaafb4d527b7efba9675a8b2cbbe32e0 (patch)
treeb29dea01e87b9adb33c75add48350e4da382c05b
parent3b1191d7eaf2f4984564e01ab84b6713a9d80e70 (diff)
AST for @finally statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43629 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Parse/ParseObjc.cpp12
-rw-r--r--Sema/Sema.h3
-rw-r--r--Sema/SemaStmt.cpp6
-rw-r--r--include/clang/Parse/Action.h5
4 files changed, 23 insertions, 3 deletions
diff --git a/Parse/ParseObjc.cpp b/Parse/ParseObjc.cpp
index f65e250fae..5d691a63ae 100644
--- a/Parse/ParseObjc.cpp
+++ b/Parse/ParseObjc.cpp
@@ -1055,9 +1055,10 @@ Parser::StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
return true;
}
StmtResult CatchStmts;
+ StmtResult FinallyStmt;
StmtResult TryBody = ParseCompoundStatementBody();
while (Tok.is(tok::at)) {
- SourceLocation AtCatchLoc = ConsumeToken();
+ SourceLocation AtCatchFinallyLoc = ConsumeToken();
if (Tok.getIdentifierInfo()->getObjCKeywordID() == tok::objc_catch) {
StmtTy *FirstPart = 0;
ConsumeToken(); // consume catch
@@ -1080,12 +1081,13 @@ Parser::StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
StmtResult CatchBody = ParseCompoundStatementBody();
if (CatchBody.isInvalid)
CatchBody = Actions.ActOnNullStmt(Tok.getLocation());
- CatchStmts = Actions.ActOnObjcAtCatchStmt(AtCatchLoc, RParenLoc,
+ CatchStmts = Actions.ActOnObjcAtCatchStmt(AtCatchFinallyLoc, RParenLoc,
FirstPart, CatchBody.Val, CatchStmts.Val);
ExitScope();
}
else {
- Diag(AtCatchLoc, diag::err_expected_lparen_after, "@catch clause");
+ Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after,
+ "@catch clause");
return true;
}
catch_or_finally_seen = true;
@@ -1093,6 +1095,10 @@ Parser::StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
else if (Tok.getIdentifierInfo()->getObjCKeywordID() == tok::objc_finally) {
ConsumeToken(); // consume finally
StmtResult FinallyBody = ParseCompoundStatementBody();
+ if (FinallyBody.isInvalid)
+ FinallyBody = Actions.ActOnNullStmt(Tok.getLocation());
+ FinallyStmt = Actions.ActOnObjcAtFinallyStmt(AtCatchFinallyLoc,
+ FinallyBody.Val);
catch_or_finally_seen = true;
break;
}
diff --git a/Sema/Sema.h b/Sema/Sema.h
index 83d8260931..cdb6c1f630 100644
--- a/Sema/Sema.h
+++ b/Sema/Sema.h
@@ -343,6 +343,9 @@ public:
SourceLocation RParen, StmtTy *Parm,
StmtTy *Body, StmtTy *CatchList);
+ virtual StmtResult ActOnObjcAtFinallyStmt(SourceLocation AtLoc,
+ StmtTy *Body);
+
//===--------------------------------------------------------------------===//
// Expression Parsing Callbacks: SemaExpr.cpp.
diff --git a/Sema/SemaStmt.cpp b/Sema/SemaStmt.cpp
index 252a2422c8..3bd6955a2f 100644
--- a/Sema/SemaStmt.cpp
+++ b/Sema/SemaStmt.cpp
@@ -659,3 +659,9 @@ Sema::ActOnObjcAtCatchStmt(SourceLocation AtLoc,
return CatchList ? CatchList : CS;
}
+Action::StmtResult
+Sema::ActOnObjcAtFinallyStmt(SourceLocation AtLoc, StmtTy *Body) {
+ ObjcAtFinallyStmt *FS = new ObjcAtFinallyStmt(AtLoc,
+ static_cast<Stmt*>(Body));
+ return FS;
+}
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h
index 1859df43e1..b900c5833f 100644
--- a/include/clang/Parse/Action.h
+++ b/include/clang/Parse/Action.h
@@ -295,6 +295,11 @@ public:
return 0;
}
+ virtual StmtResult ActOnObjcAtFinallyStmt(SourceLocation AtLoc,
+ StmtTy *Body) {
+ return 0;
+ }
+
//===--------------------------------------------------------------------===//
// Expression Parsing Callbacks.
//===--------------------------------------------------------------------===//