]> granicus.if.org Git - clang/commitdiff
Add ObjCAtSynchronizedStmt to the CFG and add GRExprEngine support (PreVisit for...
authorTed Kremenek <kremenek@apple.com>
Fri, 10 Sep 2010 03:05:33 +0000 (03:05 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 10 Sep 2010 03:05:33 +0000 (03:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113572 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Checker/PathSensitive/CheckerVisitor.def
include/clang/Checker/PathSensitive/GRExprEngine.h
lib/Analysis/CFG.cpp
lib/Checker/GRExprEngine.cpp

index 2edc4a37b7ebad6a76b55c88929e6266a9a33a08..e68c1485560b0964f80c741638ded91308c28dca 100644 (file)
@@ -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)
 
index b8ccc06b7d7179056aec9e07bd235acfa999739e..39c3ea50a5d94eea10c7589483968a288546e693 100644 (file)
@@ -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);
index 5977de609062b7e8046cc922b1aee14c74789891..804476013efbec3d1b639dd51ce1115407103430 100644 (file)
@@ -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());
 }
index 18124e47fb7ca388a6197ab45badd86f07b123d3..851f34e43b8a2ec9ab15ef1de5d90ab8b0539bc4 100644 (file)
@@ -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:
@@ -2243,6 +2246,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.
 //===----------------------------------------------------------------------===//