aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-09-10 03:05:33 +0000
committerTed Kremenek <kremenek@apple.com>2010-09-10 03:05:33 +0000
commit4beaa9f51b2da57c64740cef2bd1c2fdb0c325d5 (patch)
tree0a9084d0cf99378e9fc85db7b414b9834bb000e6
parent383329eef5564ac24a7703574f181d55ccedbab4 (diff)
Add ObjCAtSynchronizedStmt to the CFG and add GRExprEngine support (PreVisit for checkers).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113572 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Checker/PathSensitive/CheckerVisitor.def1
-rw-r--r--include/clang/Checker/PathSensitive/GRExprEngine.h5
-rw-r--r--lib/Analysis/CFG.cpp4
-rw-r--r--lib/Checker/GRExprEngine.cpp22
4 files changed, 31 insertions, 1 deletions
diff --git a/include/clang/Checker/PathSensitive/CheckerVisitor.def b/include/clang/Checker/PathSensitive/CheckerVisitor.def
index 2edc4a37b7..e68c148556 100644
--- a/include/clang/Checker/PathSensitive/CheckerVisitor.def
+++ b/include/clang/Checker/PathSensitive/CheckerVisitor.def
@@ -24,6 +24,7 @@ PREVISIT(BinaryOperator, Stmt)
PREVISIT(CallExpr, Stmt)
PREVISIT(CXXOperatorCallExpr, CallExpr)
PREVISIT(DeclStmt, Stmt)
+PREVISIT(ObjCAtSynchronizedStmt, Stmt)
PREVISIT(ObjCMessageExpr, Stmt)
PREVISIT(ReturnStmt, Stmt)
diff --git a/include/clang/Checker/PathSensitive/GRExprEngine.h b/include/clang/Checker/PathSensitive/GRExprEngine.h
index b8ccc06b7d..39c3ea50a5 100644
--- a/include/clang/Checker/PathSensitive/GRExprEngine.h
+++ b/include/clang/Checker/PathSensitive/GRExprEngine.h
@@ -26,6 +26,7 @@
#include "clang/AST/Type.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/ExprCXX.h"
+#include "clang/AST/StmtObjC.h"
namespace clang {
class AnalysisManager;
@@ -386,6 +387,10 @@ public:
void VisitMemberExpr(const MemberExpr* M, ExplodedNode* Pred,
ExplodedNodeSet& Dst, bool asLValue);
+ /// Transfer function logic for ObjCAtSynchronizedStmts.
+ void VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S,
+ ExplodedNode *Pred, ExplodedNodeSet &Dst);
+
/// VisitObjCIvarRefExpr - Transfer function logic for ObjCIvarRefExprs.
void VisitObjCIvarRefExpr(const ObjCIvarRefExpr* DR, ExplodedNode* Pred,
ExplodedNodeSet& Dst, bool asLValue);
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index 5977de6090..804476013e 100644
--- a/lib/Analysis/CFG.cpp
+++ b/lib/Analysis/CFG.cpp
@@ -1244,6 +1244,10 @@ CFGBlock* CFGBuilder::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt* S) {
Succ = SyncBlock;
}
+ // Add the @synchronized to the CFG.
+ autoCreateBlock();
+ AppendStmt(Block, S, AddStmtChoice::AlwaysAdd);
+
// Inline the sync expression.
return addStmt(S->getSynchExpr());
}
diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp
index 18124e47fb..851f34e43b 100644
--- a/lib/Checker/GRExprEngine.cpp
+++ b/lib/Checker/GRExprEngine.cpp
@@ -809,6 +809,10 @@ void GRExprEngine::Visit(const Stmt* S, ExplodedNode* Pred,
break;
}
+ case Stmt::ObjCAtSynchronizedStmtClass:
+ VisitObjCAtSynchronizedStmt(cast<ObjCAtSynchronizedStmt>(S), Pred, Dst);
+ break;
+
// Cases not handled yet; but will handle some day.
case Stmt::DesignatedInitExprClass:
case Stmt::ExtVectorElementExprClass:
@@ -816,7 +820,6 @@ void GRExprEngine::Visit(const Stmt* S, ExplodedNode* Pred,
case Stmt::ImplicitValueInitExprClass:
case Stmt::ObjCAtCatchStmtClass:
case Stmt::ObjCAtFinallyStmtClass:
- case Stmt::ObjCAtSynchronizedStmtClass:
case Stmt::ObjCAtTryStmtClass:
case Stmt::ObjCEncodeExprClass:
case Stmt::ObjCImplicitSetterGetterRefExprClass:
@@ -2244,6 +2247,23 @@ void GRExprEngine::EvalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src,
}
//===----------------------------------------------------------------------===//
+// Transfer function: Objective-C @synchronized.
+//===----------------------------------------------------------------------===//
+
+void GRExprEngine::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S,
+ ExplodedNode *Pred,
+ ExplodedNodeSet &Dst) {
+
+ // The mutex expression is a CFGElement, so we don't need to explicitly
+ // visit it since it will already be processed.
+
+ // Pre-visit the ObjCAtSynchronizedStmt.
+ ExplodedNodeSet Tmp;
+ Tmp.Add(Pred);
+ CheckerVisit(S, Dst, Tmp, PreVisitStmtCallback);
+}
+
+//===----------------------------------------------------------------------===//
// Transfer function: Objective-C ivar references.
//===----------------------------------------------------------------------===//