]> granicus.if.org Git - clang/commitdiff
PthreadLockChecker doesn't need PreVisitCallExpr() yet. All the current logic should...
authorTed Kremenek <kremenek@apple.com>
Thu, 12 Nov 2009 06:26:58 +0000 (06:26 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 12 Nov 2009 06:26:58 +0000 (06:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86959 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/PthreadLockChecker.cpp

index 09632547c881820357d099a0d69948c8661ca622..66206616b0089789cec2ca7b2583cba2475663f3 100644 (file)
@@ -30,7 +30,6 @@ public:
     static int x = 0;
     return &x;
   }
-  void PreVisitCallExpr(CheckerContext &C, const CallExpr *CE);
   void PostVisitCallExpr(CheckerContext &C, const CallExpr *CE);
     
   void AcquireLock(CheckerContext &C, const CallExpr *CE,
@@ -55,8 +54,9 @@ void clang::RegisterPthreadLockChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new PthreadLockChecker());
 }
 
-void PthreadLockChecker::PreVisitCallExpr(CheckerContext &C,
-                                          const CallExpr *CE) {
+
+void PthreadLockChecker::PostVisitCallExpr(CheckerContext &C,
+                                           const CallExpr *CE) {
   const GRState *state = C.getState();
   const Expr *Callee = CE->getCallee();
   const CodeTextRegion *R =
@@ -66,7 +66,7 @@ void PthreadLockChecker::PreVisitCallExpr(CheckerContext &C,
     return;
   
   llvm::StringRef FName = R->getDecl()->getName();
-
+  
   if (FName == "pthread_mutex_lock") {
     if (CE->getNumArgs() != 1)
       return;
@@ -76,22 +76,8 @@ void PthreadLockChecker::PreVisitCallExpr(CheckerContext &C,
     if (CE->getNumArgs() != 1)
       return;
     AcquireLock(C, CE, state->getSVal(CE->getArg(0)), true);
-  }
-}
-
-void PthreadLockChecker::PostVisitCallExpr(CheckerContext &C,
-                                           const CallExpr *CE) {
-  const GRState *state = C.getState();
-  const Expr *Callee = CE->getCallee();
-  const CodeTextRegion *R =
-    dyn_cast_or_null<CodeTextRegion>(state->getSVal(Callee).getAsRegion());
-  
-  if (!R)
-    return;
-  
-  llvm::StringRef FName = R->getDecl()->getName();
-  
-  if (FName == "pthread_mutex_unlock") {
+  }  
+  else if (FName == "pthread_mutex_unlock") {
     if (CE->getNumArgs() != 1)
       return;
     ReleaseLock(C, CE, state->getSVal(CE->getArg(0)));