From: Ted Kremenek Date: Thu, 13 May 2010 16:38:08 +0000 (+0000) Subject: Don't add a null successor to a CFGBlock when the contents of an @synchronized statem... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fadebbafe622752c3c6565b53ce8cd42bbbbd90c;p=clang Don't add a null successor to a CFGBlock when the contents of an @synchronized statement is empty. Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103717 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index 7f71e0acf7..c7eb53d361 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -1223,10 +1223,9 @@ CFGBlock* CFGBuilder::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt* S) { return 0; Block = 0; + Succ = SyncBlock; } - Succ = SyncBlock; - // Inline the sync expression. return addStmt(S->getSynchExpr()); } diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 2b21eec18c..7061f6b2d1 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -957,3 +957,13 @@ void pr6938_b() { }) == 0) { } } + +//===----------------------------------------------------------------------===// +// - The CFG for code containing an empty +// @synchronized block was previously broken (and would crash the analyzer). +//===----------------------------------------------------------------------===// + +void r7979430(id x) { + @synchronized(x) {} +} +