23 using namespace clang;
27 class ObjCAtSyncChecker
28 :
public Checker< check::PreStmt<ObjCAtSynchronizedStmt> > {
29 mutable std::unique_ptr<BuiltinBug> BT_null;
30 mutable std::unique_ptr<BuiltinBug> BT_undef;
38 CheckerContext &C)
const {
42 SVal V = C.getSVal(Ex);
45 if (V.getAs<UndefinedVal>()) {
46 if (ExplodedNode *N = C.generateErrorNode()) {
48 BT_undef.reset(
new BuiltinBug(
this,
"Uninitialized value used as mutex " 49 "for @synchronized"));
51 llvm::make_unique<BugReport>(*BT_undef, BT_undef->getDescription(), N);
52 bugreporter::trackExpressionValue(N, Ex, *report);
53 C.emitReport(std::move(report));
63 std::tie(notNullState, nullState) = state->assume(V.castAs<DefinedSVal>());
69 if (ExplodedNode *N = C.generateNonFatalErrorNode(nullState)) {
71 BT_null.reset(
new BuiltinBug(
72 this,
"Nil value used as mutex for @synchronized() " 73 "(no synchronization will occur)"));
75 llvm::make_unique<BugReport>(*BT_null, BT_null->getDescription(), N);
76 bugreporter::trackExpressionValue(N, Ex, *report);
78 C.emitReport(std::move(report));
88 C.addTransition(notNullState);
91 void ento::registerObjCAtSyncChecker(CheckerManager &mgr) {
92 if (mgr.getLangOpts().ObjC)
93 mgr.registerChecker<ObjCAtSyncChecker>();
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
Defines the Objective-C statement AST node classes.
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
This represents one expression.
Represents Objective-C's @synchronized statement.
Dataflow Directional Tag Classes.
const Expr * getSynchExpr() const