forked from OSchip/llvm-project
Correct some thread safety analysis diagnostics; NFC.
The diagnostics were not following the usual style rules.
This commit is contained in:
parent
d18fb09c69
commit
beb5a3a298
|
@ -3634,13 +3634,13 @@ def warn_fun_requires_lock_precise :
|
||||||
def note_found_mutex_near_match : Note<"found near match '%0'">;
|
def note_found_mutex_near_match : Note<"found near match '%0'">;
|
||||||
|
|
||||||
// Verbose thread safety warnings
|
// Verbose thread safety warnings
|
||||||
def warn_thread_safety_verbose : Warning<"Thread safety verbose warning.">,
|
def warn_thread_safety_verbose : Warning<"thread safety verbose warning">,
|
||||||
InGroup<ThreadSafetyVerbose>, DefaultIgnore;
|
InGroup<ThreadSafetyVerbose>, DefaultIgnore;
|
||||||
def note_thread_warning_in_fun : Note<"Thread warning in function %0">;
|
def note_thread_warning_in_fun : Note<"thread warning in function %0">;
|
||||||
def note_guarded_by_declared_here : Note<"Guarded_by declared here.">;
|
def note_guarded_by_declared_here : Note<"guarded_by declared here">;
|
||||||
|
|
||||||
// Dummy warning that will trigger "beta" warnings from the analysis if enabled.
|
// Dummy warning that will trigger "beta" warnings from the analysis if enabled.
|
||||||
def warn_thread_safety_beta : Warning<"Thread safety beta warning.">,
|
def warn_thread_safety_beta : Warning<"thread safety beta warning">,
|
||||||
InGroup<ThreadSafetyBeta>, DefaultIgnore;
|
InGroup<ThreadSafetyBeta>, DefaultIgnore;
|
||||||
|
|
||||||
// Consumed warnings
|
// Consumed warnings
|
||||||
|
|
|
@ -21,41 +21,41 @@ class LOCKABLE Mutex {
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
Mutex mu;
|
Mutex mu;
|
||||||
int a GUARDED_BY(mu); // expected-note3 {{Guarded_by declared here.}}
|
int a GUARDED_BY(mu); // expected-note3 {{guarded_by declared here}}
|
||||||
|
|
||||||
void foo1() EXCLUSIVE_LOCKS_REQUIRED(mu);
|
void foo1() EXCLUSIVE_LOCKS_REQUIRED(mu);
|
||||||
void foo2() SHARED_LOCKS_REQUIRED(mu);
|
void foo2() SHARED_LOCKS_REQUIRED(mu);
|
||||||
void foo3() LOCKS_EXCLUDED(mu);
|
void foo3() LOCKS_EXCLUDED(mu);
|
||||||
|
|
||||||
void test1() { // expected-note {{Thread warning in function 'test1'}}
|
void test1() { // expected-note {{thread warning in function 'test1'}}
|
||||||
a = 0; // expected-warning {{writing variable 'a' requires holding mutex 'mu' exclusively}}
|
a = 0; // expected-warning {{writing variable 'a' requires holding mutex 'mu' exclusively}}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test2() { // expected-note {{Thread warning in function 'test2'}}
|
void test2() { // expected-note {{thread warning in function 'test2'}}
|
||||||
int b = a; // expected-warning {{reading variable 'a' requires holding mutex 'mu'}}
|
int b = a; // expected-warning {{reading variable 'a' requires holding mutex 'mu'}}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test3() { // expected-note {{Thread warning in function 'test3'}}
|
void test3() { // expected-note {{thread warning in function 'test3'}}
|
||||||
foo1(); // expected-warning {{calling function 'foo1' requires holding mutex 'mu' exclusively}}
|
foo1(); // expected-warning {{calling function 'foo1' requires holding mutex 'mu' exclusively}}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test4() { // expected-note {{Thread warning in function 'test4'}}
|
void test4() { // expected-note {{thread warning in function 'test4'}}
|
||||||
foo2(); // expected-warning {{calling function 'foo2' requires holding mutex 'mu'}}
|
foo2(); // expected-warning {{calling function 'foo2' requires holding mutex 'mu'}}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test5() { // expected-note {{Thread warning in function 'test5'}}
|
void test5() { // expected-note {{thread warning in function 'test5'}}
|
||||||
mu.ReaderLock();
|
mu.ReaderLock();
|
||||||
foo1(); // expected-warning {{calling function 'foo1' requires holding mutex 'mu' exclusively}}
|
foo1(); // expected-warning {{calling function 'foo1' requires holding mutex 'mu' exclusively}}
|
||||||
mu.Unlock();
|
mu.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void test6() { // expected-note {{Thread warning in function 'test6'}}
|
void test6() { // expected-note {{thread warning in function 'test6'}}
|
||||||
mu.ReaderLock();
|
mu.ReaderLock();
|
||||||
a = 0; // expected-warning {{writing variable 'a' requires holding mutex 'mu' exclusively}}
|
a = 0; // expected-warning {{writing variable 'a' requires holding mutex 'mu' exclusively}}
|
||||||
mu.Unlock();
|
mu.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void test7() { // expected-note {{Thread warning in function 'test7'}}
|
void test7() { // expected-note {{thread warning in function 'test7'}}
|
||||||
mu.Lock();
|
mu.Lock();
|
||||||
foo3(); // expected-warning {{cannot call function 'foo3' while mutex 'mu' is held}}
|
foo3(); // expected-warning {{cannot call function 'foo3' while mutex 'mu' is held}}
|
||||||
mu.Unlock();
|
mu.Unlock();
|
||||||
|
|
Loading…
Reference in New Issue