summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-21 06:01:00 +0000
committerChris Lattner <sabre@nondot.org>2009-04-21 06:01:00 +0000
commitc70dd56477016528c5f49b8618644bf8a6845f89 (patch)
tree3ee8b02f56c1621bb31b0c11d8687019d7b18a7e /clang/lib
parente08c43a3b0dc9ffed28e3db886a21bf89e9a0a42 (diff)
downloadbcm5719-llvm-c70dd56477016528c5f49b8618644bf8a6845f89.tar.gz
bcm5719-llvm-c70dd56477016528c5f49b8618644bf8a6845f89.zip
add support for goto checking and @synchronized blocks,
rdar://6810106 llvm-svn: 69667
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/JumpDiagnostics.cpp16
-rw-r--r--clang/lib/Sema/SemaStmt.cpp2
2 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp
index 82db0bbd2c3..b812f06f76b 100644
--- a/clang/lib/Sema/JumpDiagnostics.cpp
+++ b/clang/lib/Sema/JumpDiagnostics.cpp
@@ -168,6 +168,22 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned ParentScope) {
continue;
}
+ // Disallow jumps into the protected statement of an @synchronized, but
+ // allow jumps into the object expression it protects.
+ if (ObjCAtSynchronizedStmt *AS = dyn_cast<ObjCAtSynchronizedStmt>(SubStmt)){
+ // Recursively walk the AST for the @synchronized object expr, it is
+ // evaluated in the normal scope.
+ BuildScopeInformation(AS->getSynchExpr(), ParentScope);
+
+ // Recursively walk the AST for the @synchronized part, protected by a new
+ // scope.
+ Scopes.push_back(GotoScope(ParentScope,
+ diag::note_protected_by_objc_synchronized,
+ AS->getAtSynchronizedLoc()));
+ BuildScopeInformation(AS->getSynchBody(), Scopes.size()-1);
+ continue;
+ }
+
// Recursively walk the AST.
BuildScopeInformation(SubStmt, ParentScope);
}
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 35dffa10f2a..26cba5bec74 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1090,6 +1090,8 @@ Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, ExprArg expr,Scope *CurScope) {
Action::OwningStmtResult
Sema::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, ExprArg SynchExpr,
StmtArg SynchBody) {
+ CurFunctionNeedsScopeChecking = true;
+
return Owned(new (Context) ObjCAtSynchronizedStmt(AtLoc,
static_cast<Stmt*>(SynchExpr.release()),
static_cast<Stmt*>(SynchBody.release())));
OpenPOWER on IntegriCloud