aboutsummaryrefslogtreecommitdiff
path: root/lib/Checker/ObjCAtSyncChecker.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-12-22 18:52:29 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-12-22 18:52:29 +0000
commitbce30c533a2b444db97533e3a9a567558120bd70 (patch)
treeb730703a0680231ab757d3f3e607251b4c78e155 /lib/Checker/ObjCAtSyncChecker.cpp
parent98cabbad47a4d9db6b7e95c950d3302c110d1b02 (diff)
[analyzer] Refactoring: lib/Checker -> lib/GR and libclangChecker -> libclangGRCore
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122421 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/ObjCAtSyncChecker.cpp')
-rw-r--r--lib/Checker/ObjCAtSyncChecker.cpp94
1 files changed, 0 insertions, 94 deletions
diff --git a/lib/Checker/ObjCAtSyncChecker.cpp b/lib/Checker/ObjCAtSyncChecker.cpp
deleted file mode 100644
index c95df4ef4b..0000000000
--- a/lib/Checker/ObjCAtSyncChecker.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-//== ObjCAtSyncChecker.cpp - nil mutex checker for @synchronized -*- C++ -*--=//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This defines ObjCAtSyncChecker, a builtin check that checks for null pointers
-// used as mutexes for @synchronized.
-//
-//===----------------------------------------------------------------------===//
-
-#include "GRExprEngineInternalChecks.h"
-#include "clang/GR/BugReporter/BugType.h"
-#include "clang/GR/Checkers/DereferenceChecker.h"
-#include "clang/GR/PathSensitive/CheckerVisitor.h"
-#include "clang/GR/PathSensitive/GRExprEngine.h"
-
-using namespace clang;
-
-namespace {
-class ObjCAtSyncChecker : public CheckerVisitor<ObjCAtSyncChecker> {
- BuiltinBug *BT_null;
- BuiltinBug *BT_undef;
-public:
- ObjCAtSyncChecker() : BT_null(0), BT_undef(0) {}
- static void *getTag() { static int tag = 0; return &tag; }
- void PreVisitObjCAtSynchronizedStmt(CheckerContext &C,
- const ObjCAtSynchronizedStmt *S);
-};
-} // end anonymous namespace
-
-void clang::RegisterObjCAtSyncChecker(GRExprEngine &Eng) {
- // @synchronized is an Objective-C 2 feature.
- if (Eng.getContext().getLangOptions().ObjC2)
- Eng.registerCheck(new ObjCAtSyncChecker());
-}
-
-void ObjCAtSyncChecker::PreVisitObjCAtSynchronizedStmt(CheckerContext &C,
- const ObjCAtSynchronizedStmt *S) {
-
- const Expr *Ex = S->getSynchExpr();
- const GRState *state = C.getState();
- SVal V = state->getSVal(Ex);
-
- // Uninitialized value used for the mutex?
- if (isa<UndefinedVal>(V)) {
- if (ExplodedNode *N = C.generateSink()) {
- if (!BT_undef)
- BT_undef = new BuiltinBug("Uninitialized value used as mutex "
- "for @synchronized");
- EnhancedBugReport *report =
- new EnhancedBugReport(*BT_undef, BT_undef->getDescription(), N);
- report->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue, Ex);
- C.EmitReport(report);
- }
- return;
- }
-
- if (V.isUnknown())
- return;
-
- // Check for null mutexes.
- const GRState *notNullState, *nullState;
- llvm::tie(notNullState, nullState) = state->assume(cast<DefinedSVal>(V));
-
- if (nullState) {
- if (!notNullState) {
- // Generate an error node. This isn't a sink since
- // a null mutex just means no synchronization occurs.
- if (ExplodedNode *N = C.generateNode(nullState)) {
- if (!BT_null)
- BT_null = new BuiltinBug("Nil value used as mutex for @synchronized() "
- "(no synchronization will occur)");
- EnhancedBugReport *report =
- new EnhancedBugReport(*BT_null, BT_null->getDescription(), N);
- report->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue,
- Ex);
-
- C.EmitReport(report);
- return;
- }
- }
- // Don't add a transition for 'nullState'. If the value is
- // under-constrained to be null or non-null, assume it is non-null
- // afterwards.
- }
-
- if (notNullState)
- C.addTransition(notNullState);
-}
-