Gabor Horvath | 643dee9 | 2020-02-04 15:57:31 -0800 | [diff] [blame] | 1 | // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.fuchsia.Lock -verify %s |
Gabor Horvath | e4f4a6c | 2020-02-04 15:44:57 -0800 | [diff] [blame] | 2 | // expected-no-diagnostics |
| 3 | typedef int spin_lock_t; |
| 4 | |
| 5 | void spin_lock(spin_lock_t *lock); |
| 6 | int getCond(); |
| 7 | int spin_trylock(spin_lock_t *lock) { |
| 8 | if (getCond()) |
| 9 | return 0; |
| 10 | return -1; |
| 11 | } |
| 12 | void spin_unlock(spin_lock_t *lock); |
| 13 | |
| 14 | spin_lock_t mtx; |
| 15 | void no_crash() { |
| 16 | if (spin_trylock(&mtx) == 0) |
| 17 | spin_unlock(&mtx); |
| 18 | } |