aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/AnalysisBasedWarnings.cpp
diff options
context:
space:
mode:
authorCaitlin Sadowski <supertri@google.com>2011-09-15 17:25:19 +0000
committerCaitlin Sadowski <supertri@google.com>2011-09-15 17:25:19 +0000
commit4e4bc75d3570835e13183c66ac08974cdc016007 (patch)
treec2c143a55fca0297f305816bbc394e4aee78ca29 /lib/Sema/AnalysisBasedWarnings.cpp
parent0f50b08940ea0a9a44f2715f49ccf6bc64b95491 (diff)
Thread safety: refactoring various out of scope warnings to use the same inteface. This eliminates a lot of unnecessary duplicated code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139801 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r--lib/Sema/AnalysisBasedWarnings.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index bbd8fa38fe..15800b38c0 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -633,20 +633,23 @@ class ThreadSafetyReporter : public clang::thread_safety::ThreadSafetyHandler {
warnLockMismatch(diag::warn_double_lock, LockName, Loc);
}
- void handleMutexHeldEndOfScope(Name LockName, SourceLocation Loc){
- warnLockMismatch(diag::warn_lock_at_end_of_scope, LockName, Loc);
- }
-
- void handleNoLockLoopEntry(Name LockName, SourceLocation Loc) {
- warnLockMismatch(diag::warn_expecting_lock_held_on_loop, LockName, Loc);
+ void handleMutexHeldEndOfScope(Name LockName, SourceLocation Loc,
+ LockErrorKind LEK){
+ unsigned DiagID = 0;
+ switch (LEK) {
+ case LEK_LockedSomePredecessors:
+ DiagID = diag::warn_lock_at_end_of_scope;
+ break;
+ case LEK_LockedSomeLoopIterations:
+ DiagID = diag::warn_expecting_lock_held_on_loop;
+ break;
+ case LEK_LockedAtEndOfFunction:
+ DiagID = diag::warn_no_unlock;
+ break;
+ }
+ warnLockMismatch(DiagID, LockName, Loc);
}
- void handleNoUnlock(Name LockName, llvm::StringRef FunName,
- SourceLocation Loc) {
- PartialDiagnostic Warning =
- S.PDiag(diag::warn_no_unlock) << LockName << FunName;
- Warnings.push_back(DelayedDiag(Loc, Warning));
- }
void handleExclusiveAndShared(Name LockName, SourceLocation Loc1,
SourceLocation Loc2) {