forked from OSchip/llvm-project
Thread safety: reverting to use separate warning for requirement to hold any lock
llvm-svn: 139723
This commit is contained in:
parent
5b34a2fd6e
commit
e50d8c3415
|
@ -1421,6 +1421,14 @@ def warn_var_deref_requires_lock : Warning<
|
|||
"%select{reading|writing}2 the value pointed to by '%0' requires lock on '%1'"
|
||||
" to be %select{held|held exclusively}2">,
|
||||
InGroup<ThreadSafety>, DefaultIgnore;
|
||||
def warn_variable_requires_any_lock : Warning<
|
||||
"%select{reading|writing}1 variable '%0' requires lock on any mutex to be "
|
||||
"%select{held|held exclusively}1">,
|
||||
InGroup<ThreadSafety>, DefaultIgnore;
|
||||
def warn_var_deref_requires_any_lock : Warning<
|
||||
"%select{reading|writing}1 the value pointed to by '%0' requires lock on any"
|
||||
" mutex to be %select{held|held exclusively}1">,
|
||||
InGroup<ThreadSafety>, DefaultIgnore;
|
||||
def warn_fun_requires_lock : Warning<
|
||||
"calling function '%0' requires %select{shared|exclusive}2 lock on '%1'">,
|
||||
InGroup<ThreadSafety>, DefaultIgnore;
|
||||
|
|
|
@ -660,9 +660,14 @@ class ThreadSafetyReporter : public clang::thread_safety::ThreadSafetyHandler {
|
|||
|
||||
void handleNoMutexHeld(const NamedDecl *D, ProtectedOperationKind POK,
|
||||
AccessKind AK, SourceLocation Loc) {
|
||||
// FIXME: It would be nice if this case printed without single quotes around
|
||||
// the phrase 'any mutex'
|
||||
handleMutexNotHeld(D, POK, "any mutex", getLockKindFromAccessKind(AK), Loc);
|
||||
assert((POK == POK_VarAccess || POK == POK_VarDereference)
|
||||
&& "Only works for variables");
|
||||
unsigned DiagID = POK == POK_VarAccess?
|
||||
diag::warn_variable_requires_any_lock:
|
||||
diag::warn_var_deref_requires_any_lock;
|
||||
PartialDiagnostic Warning = S.PDiag(DiagID)
|
||||
<< D->getName() << getLockKindFromAccessKind(AK);
|
||||
Warnings.push_back(DelayedDiag(Loc, Warning));
|
||||
}
|
||||
|
||||
void handleMutexNotHeld(const NamedDecl *D, ProtectedOperationKind POK,
|
||||
|
@ -680,7 +685,7 @@ class ThreadSafetyReporter : public clang::thread_safety::ThreadSafetyHandler {
|
|||
break;
|
||||
}
|
||||
PartialDiagnostic Warning = S.PDiag(DiagID)
|
||||
<< D->getName().str() << LockName << LK;
|
||||
<< D->getName() << LockName << LK;
|
||||
Warnings.push_back(DelayedDiag(Loc, Warning));
|
||||
}
|
||||
|
||||
|
|
|
@ -351,12 +351,12 @@ void gb_fun_3() {
|
|||
|
||||
void gb_bad_0() {
|
||||
sls_guard_var = 1; // \
|
||||
// expected-warning{{writing variable 'sls_guard_var' requires lock on 'any mutex' to be held exclusively}}
|
||||
// expected-warning{{writing variable 'sls_guard_var' requires lock on any mutex to be held exclusively}}
|
||||
}
|
||||
|
||||
void gb_bad_1() {
|
||||
int x = sls_guard_var; // \
|
||||
// expected-warning{{reading variable 'sls_guard_var' requires lock on 'any mutex' to be held}}
|
||||
// expected-warning{{reading variable 'sls_guard_var' requires lock on any mutex to be held}}
|
||||
}
|
||||
|
||||
void gb_bad_2() {
|
||||
|
@ -371,12 +371,12 @@ void gb_bad_3() {
|
|||
|
||||
void gb_bad_4() {
|
||||
*pgb_gvar = 1; // \
|
||||
// expected-warning {{writing the value pointed to by 'pgb_gvar' requires lock on 'any mutex' to be held exclusively}}
|
||||
// expected-warning {{writing the value pointed to by 'pgb_gvar' requires lock on any mutex to be held exclusively}}
|
||||
}
|
||||
|
||||
void gb_bad_5() {
|
||||
int x = *pgb_gvar; // \
|
||||
// expected-warning {{reading the value pointed to by 'pgb_gvar' requires lock on 'any mutex' to be held}}
|
||||
// expected-warning {{reading the value pointed to by 'pgb_gvar' requires lock on any mutex to be held}}
|
||||
}
|
||||
|
||||
void gb_bad_6() {
|
||||
|
@ -397,13 +397,13 @@ void gb_bad_8() {
|
|||
|
||||
void gb_bad_9() {
|
||||
sls_guard_var++; // \
|
||||
// expected-warning{{writing variable 'sls_guard_var' requires lock on 'any mutex' to be held exclusively}}
|
||||
// expected-warning{{writing variable 'sls_guard_var' requires lock on any mutex to be held exclusively}}
|
||||
sls_guard_var--; // \
|
||||
// expected-warning{{writing variable 'sls_guard_var' requires lock on 'any mutex' to be held exclusively}}
|
||||
// expected-warning{{writing variable 'sls_guard_var' requires lock on any mutex to be held exclusively}}
|
||||
++sls_guard_var; // \
|
||||
// expected-warning{{writing variable 'sls_guard_var' requires lock on 'any mutex' to be held exclusively}}
|
||||
// expected-warning{{writing variable 'sls_guard_var' requires lock on any mutex to be held exclusively}}
|
||||
--sls_guard_var;// \
|
||||
// expected-warning{{writing variable 'sls_guard_var' requires lock on 'any mutex' to be held exclusively}}
|
||||
// expected-warning{{writing variable 'sls_guard_var' requires lock on any mutex to be held exclusively}}
|
||||
}
|
||||
|
||||
//-----------------------------------------------//
|
||||
|
|
Loading…
Reference in New Issue