[cfe-commits] r113572 - in /cfe/trunk: include/clang/Checker/PathSensitive/CheckerVisitor.def include/clang/Checker/PathSensitive/GRExprEngine.h lib/Analysis/CFG.cpp lib/Checker/GRExprEngine.cpp
Ted Kremenek
kremenek at apple.com
Thu Sep 9 20:05:33 PDT 2010
Author: kremenek
Date: Thu Sep 9 22:05:33 2010
New Revision: 113572
URL: http://llvm.org/viewvc/llvm-project?rev=113572&view=rev
Log:
Add ObjCAtSynchronizedStmt to the CFG and add GRExprEngine support (PreVisit for checkers).
Modified:
cfe/trunk/include/clang/Checker/PathSensitive/CheckerVisitor.def
cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/Checker/GRExprEngine.cpp
Modified: cfe/trunk/include/clang/Checker/PathSensitive/CheckerVisitor.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/CheckerVisitor.def?rev=113572&r1=113571&r2=113572&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/CheckerVisitor.def (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/CheckerVisitor.def Thu Sep 9 22:05:33 2010
@@ -24,6 +24,7 @@
PREVISIT(CallExpr, Stmt)
PREVISIT(CXXOperatorCallExpr, CallExpr)
PREVISIT(DeclStmt, Stmt)
+PREVISIT(ObjCAtSynchronizedStmt, Stmt)
PREVISIT(ObjCMessageExpr, Stmt)
PREVISIT(ReturnStmt, Stmt)
Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h?rev=113572&r1=113571&r2=113572&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h Thu Sep 9 22:05:33 2010
@@ -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 @@
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);
Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=113572&r1=113571&r2=113572&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Thu Sep 9 22:05:33 2010
@@ -1244,6 +1244,10 @@
Succ = SyncBlock;
}
+ // Add the @synchronized to the CFG.
+ autoCreateBlock();
+ AppendStmt(Block, S, AddStmtChoice::AlwaysAdd);
+
// Inline the sync expression.
return addStmt(S->getSynchExpr());
}
Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=113572&r1=113571&r2=113572&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Thu Sep 9 22:05:33 2010
@@ -809,6 +809,10 @@
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 @@
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 @@
}
//===----------------------------------------------------------------------===//
+// 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.
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list