Thread safety: refactoring test cases

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139368 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 15d5ad1..0dd2099 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1414,16 +1414,10 @@
   "%select{reading|writing}2 variable '%0' requires lock on '%1' to be "
   "%select{held|held exclusively}2">,
   InGroup<ThreadSafety>, DefaultIgnore;
-def warn_variable_requires_any_lock : Warning<
-  "accessing variable '%0' requires some lock">,
-  InGroup<ThreadSafety>, DefaultIgnore;
 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_var_deref_requires_any_lock : Warning<
-  "accessing the value pointed to by '%0' requires some lock">,
-  InGroup<ThreadSafety>, DefaultIgnore;
 def warn_fun_requires_lock : Warning<
   "calling function '%0' requires %select{shared|exclusive}2 lock on '%1'">,
   InGroup<ThreadSafety>, DefaultIgnore;
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index 2da5568..ecdbcb2 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -732,20 +732,9 @@
 
   void handleNoMutexHeld(const NamedDecl *D, ProtectedOperationKind POK,
                          AccessKind AK, SourceLocation Loc) {
-    unsigned DiagID;
-    switch (POK) {
-      case POK_VarAccess:
-        DiagID = diag::warn_variable_requires_any_lock;
-        break;
-      case POK_VarDereference:
-        DiagID = diag::warn_var_deref_requires_any_lock;
-        break;
-      default:
-        return;
-        break;
-    }
-    PartialDiagnostic Warning = S.PDiag(DiagID) << D->getName();
-    Warnings.push_back(DelayedDiag(Loc, Warning));
+    // 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);
   }
 
   void handleMutexNotHeld(const NamedDecl *D, ProtectedOperationKind POK,
diff --git a/test/SemaCXX/warn-thread-safety-analysis.cpp b/test/SemaCXX/warn-thread-safety-analysis.cpp
index cb74504..9cecea7 100644
--- a/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ b/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -345,12 +345,12 @@
 
 void gb_bad_0() {
   sls_guard_var = 1; // \
-    // expected-warning{{accessing variable 'sls_guard_var' requires some lock}}
+    // 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{{accessing variable 'sls_guard_var' requires some lock}}
+    // expected-warning{{reading variable 'sls_guard_var' requires lock on 'any mutex' to be held}}
 }
 
 void gb_bad_2() {
@@ -365,12 +365,12 @@
 
 void gb_bad_4() {
   *pgb_gvar = 1; // \
-    // expected-warning {{accessing the value pointed to by 'pgb_gvar' requires some lock}}
+    // 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 {{accessing the value pointed to by 'pgb_gvar' requires some lock}}
+    // expected-warning {{reading the value pointed to by 'pgb_gvar' requires lock on 'any mutex' to be held}}
 }
 
 void gb_bad_6() {
@@ -391,13 +391,13 @@
 
 void gb_bad_9() {
   sls_guard_var++; // \
-    // expected-warning{{accessing variable 'sls_guard_var' requires some lock}}
+    // expected-warning{{writing variable 'sls_guard_var' requires lock on 'any mutex' to be held exclusively}}
   sls_guard_var--; // \
-    // expected-warning{{accessing variable 'sls_guard_var' requires some lock}}
+    // expected-warning{{writing variable 'sls_guard_var' requires lock on 'any mutex' to be held exclusively}}
   ++sls_guard_var; // \
-    // expected-warning{{accessing variable 'sls_guard_var' requires some lock}}
-  --sls_guard_var; // \
-    // expected-warning{{accessing variable 'sls_guard_var' requires some lock}}
+    // 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}}
 }
 
 //-----------------------------------------------//