1 // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.core.C11Lock -verify %s
7 // FIXME: The value if this enum is implementation defined. While all the
8 // implementations I am aware of using 0, the right solution would be to
9 // look this value up in the AST (and disable the check if it is not found).
14 int mtx_init(mtx_t
*mutex
, int type
);
15 int mtx_lock(mtx_t
*mutex
);
16 int mtx_timedlock(mtx_t
*mutex
,
17 const struct timespec
*time_point
);
18 int mtx_trylock(mtx_t
*mutex
);
19 int mtx_unlock(mtx_t
*mutex
);
20 int mtx_destroy(mtx_t
*mutex
);
27 mtx_lock(&mtx1
); // no-warning
28 mtx_lock(&mtx1
); // expected-warning{{This lock has already been acquired}}
35 } // TODO: Warn for missing unlock?
40 } // TODO: Warn for missing destroy?
47 } // TODO: warn for missing destroy?
52 mtx_unlock(&mtx1
); // expected-warning {{This lock has already been unlocked}}
57 if (mtx_trylock(&mtx1
) != thrd_success
)
58 mtx_unlock(&mtx1
); // expected-warning {{This lock has already been unlocked}}
64 mtx_unlock(&mtx1
); // expected-warning {{This was not the most recently acquired lock. Possible lock order reversal}}
79 if (mtx_trylock(&mtx
) == thrd_success
)
87 if (mtx_timedlock(&mtx
, 0) == thrd_success
)