}
LockData* LDat = FSet.findLock(Analyzer->FactMan, Mutex);
- if (LDat)
- Analyzer->Handler.handleFunExcludesLock(D->getName(), Mutex.toString(),
+ if (LDat) {
+ std::string DeclName = D->getNameAsString();
+ StringRef DeclNameSR (DeclName);
+ Analyzer->Handler.handleFunExcludesLock(DeclNameSR, Mutex.toString(),
Exp->getExprLoc());
+ }
}
diag::warn_variable_requires_any_lock:
diag::warn_var_deref_requires_any_lock;
PartialDiagnosticAt Warning(Loc, S.PDiag(DiagID)
- << D->getName() << getLockKindFromAccessKind(AK));
+ << D->getNameAsString() << getLockKindFromAccessKind(AK));
Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
}
break;
}
PartialDiagnosticAt Warning(Loc, S.PDiag(DiagID)
- << D->getName() << LockName << LK);
+ << D->getNameAsString() << LockName << LK);
PartialDiagnosticAt Note(Loc, S.PDiag(diag::note_found_mutex_near_match)
<< *PossibleMatch);
Warnings.push_back(DelayedDiag(Warning, OptionalNotes(1, Note)));
break;
}
PartialDiagnosticAt Warning(Loc, S.PDiag(DiagID)
- << D->getName() << LockName << LK);
+ << D->getNameAsString() << LockName << LK);
Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
}
}
}; // end namespace ExprMatchingBugfix
+namespace ComplexNameTest {
+class Foo {
+public:
+ static Mutex mu_;
+
+ Foo() EXCLUSIVE_LOCKS_REQUIRED(mu_) { }
+ ~Foo() EXCLUSIVE_LOCKS_REQUIRED(mu_) { }
+
+ int operator[](int i) EXCLUSIVE_LOCKS_REQUIRED(mu_) { return 0; }
+};
+
+class Bar {
+public:
+ static Mutex mu_;
+
+ Bar() LOCKS_EXCLUDED(mu_) { }
+ ~Bar() LOCKS_EXCLUDED(mu_) { }
+
+ int operator[](int i) LOCKS_EXCLUDED(mu_) { return 0; }
+};
+
+
+void test1() {
+ Foo f; // expected-warning {{calling function 'Foo' requires exclusive lock on 'mu_'}}
+ int a = f[0]; // expected-warning {{calling function 'operator[]' requires exclusive lock on 'mu_'}}
+} // expected-warning {{calling function '~Foo' requires exclusive lock on 'mu_'}}
+
+
+void test2() {
+ Bar::mu_.Lock();
+ {
+ Bar b; // expected-warning {{cannot call function 'Bar' while mutex 'mu_' is locked}}
+ int a = b[0]; // expected-warning {{cannot call function 'operator[]' while mutex 'mu_' is locked}}
+ } // expected-warning {{cannot call function '~Bar' while mutex 'mu_' is locked}}
+ Bar::mu_.Unlock();
+}
+
+}; // end namespace ComplexNameTest