Skip to content

Commit c9219d6

Browse files
committed
[test] false positive is fixed
1 parent bf6c98b commit c9219d6

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

clang/test/Analysis/block-in-critical-section.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,19 +294,13 @@ void testBlockInCriticalSectionUniqueLockNested() {
294294
sleep(1); // no-warning
295295
}
296296

297-
void testTrylockCurrentlyFalsePositive(pthread_mutex_t *m) {
298-
// expected-note@+4 {{Assuming the condition is true}}
299-
// expected-note@+3 {{Taking true branch}}
300-
// expected-note@+2 {{Assuming the condition is false}}
301-
// expected-note@+1 {{Taking false branch}}
302-
if (pthread_mutex_trylock(m) == 0) { // expected-note 2 {{Entering critical section here}}
303-
// FIXME: we are entering the critical section only in the true branch
297+
void testTrylockStateSplitting(pthread_mutex_t *m) {
298+
// expected-note@+1 {{Taking true branch}}
299+
if (pthread_mutex_trylock(m) == 0) { // expected-note {{Entering critical section here}}
304300
sleep(10); // expected-warning {{Call to blocking function 'sleep' inside of critical section}}
305301
// expected-note@-1 {{Call to blocking function 'sleep' inside of critical section}}
306302
pthread_mutex_unlock(m);
307303
} else {
308-
sleep(10); // expected-warning {{Call to blocking function 'sleep' inside of critical section}}
309-
// expected-note@-1 {{Call to blocking function 'sleep' inside of critical section}}
310-
// FIXME: this is a false positive, the lock was not acquired
304+
sleep(10); // no-warning
311305
}
312306
}

0 commit comments

Comments
 (0)