22 using namespace clang;
26 class ObjCAtSyncChecker
27 :
public Checker< check::PreStmt<ObjCAtSynchronizedStmt> > {
28 mutable std::unique_ptr<BuiltinBug> BT_null;
29 mutable std::unique_ptr<BuiltinBug> BT_undef;
37 CheckerContext &C)
const {
41 SVal
V = C.getSVal(Ex);
44 if (V.getAs<UndefinedVal>()) {
45 if (ExplodedNode *N = C.generateErrorNode()) {
47 BT_undef.reset(
new BuiltinBug(
this,
"Uninitialized value used as mutex " 48 "for @synchronized"));
49 auto report = std::make_unique<PathSensitiveBugReport>(
50 *BT_undef, BT_undef->getDescription(), N);
51 bugreporter::trackExpressionValue(N, Ex, *report);
52 C.emitReport(std::move(report));
62 std::tie(notNullState, nullState) = state->assume(V.castAs<DefinedSVal>());
68 if (ExplodedNode *N = C.generateNonFatalErrorNode(nullState)) {
70 BT_null.reset(
new BuiltinBug(
71 this,
"Nil value used as mutex for @synchronized() " 72 "(no synchronization will occur)"));
73 auto report = std::make_unique<PathSensitiveBugReport>(
74 *BT_null, BT_null->getDescription(), N);
75 bugreporter::trackExpressionValue(N, Ex, *report);
77 C.emitReport(std::move(report));
87 C.addTransition(notNullState);
90 void ento::registerObjCAtSyncChecker(CheckerManager &mgr) {
91 mgr.registerChecker<ObjCAtSyncChecker>();
94 bool ento::shouldRegisterObjCAtSyncChecker(
const LangOptions &LO) {
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
Defines the Objective-C statement AST node classes.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
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