Re: [PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-23 Thread Aaron Ballman via cfe-commits
On Wed, Aug 22, 2018 at 6:35 PM, Aaron Puchert via Phabricator wrote: > aaronpuchert added inline comments. > > > > Comment at: lib/Analysis/ThreadSafety.cpp:932 > + // We're relocking the underlying mutexes. Warn on double locking. > + if (FSet.findLock(FactMan, UnderCp

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-22 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments. Comment at: lib/Analysis/ThreadSafety.cpp:932 + // We're relocking the underlying mutexes. Warn on double locking. + if (FSet.findLock(FactMan, UnderCp)) +Handler.handleDoubleLock(DiagKind, UnderCp.toString(), entry.loc()); --

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-22 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL340459: Thread safety analysis: Allow relockable scopes (authored by aaronpuchert, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D49885 Files:

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-20 Thread Delesley Hutchins via Phabricator via cfe-commits
delesley accepted this revision. delesley added a comment. This looks good to me. Thanks for the patch. Comment at: lib/Analysis/ThreadSafety.cpp:932 + // We're relocking the underlying mutexes. Warn on double locking. + if (FSet.findLock(FactMan, UnderCp)) +

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-20 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 161598. aaronpuchert added a comment. Reformat tests. I promise, this is the last one. Repository: rC Clang https://reviews.llvm.org/D49885 Files: lib/Analysis/ThreadSafety.cpp test/SemaCXX/warn-thread-safety-analysis.cpp Index: test/SemaCXX/wa

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-20 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 161596. aaronpuchert added a comment. Formatting changes. Repository: rC Clang https://reviews.llvm.org/D49885 Files: lib/Analysis/ThreadSafety.cpp test/SemaCXX/warn-thread-safety-analysis.cpp Index: test/SemaCXX/warn-thread-safety-analysis.cpp

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-20 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 161595. aaronpuchert added a comment. Proper capitalization of member function, reduction of test code. Repository: rC Clang https://reviews.llvm.org/D49885 Files: lib/Analysis/ThreadSafety.cpp test/SemaCXX/warn-thread-safety-analysis.cpp Index

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert marked 4 inline comments as done. aaronpuchert added a comment. @aaron.ballman Maybe you can have a look again — this is much more elegant. I'm not sure why I didn't see this in the first place. Comment at: test/SemaCXX/warn-thread-safety-analysis.cpp:2765-2768 +

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 160719. aaronpuchert added a comment. Found a much simpler solution. After introducing a new virtual function HandleLock() in FactEntry, I just needed to change two lines in ThreadSafetyAnalyzer::addLock. Changes in BuildLockset::handleCall are no long

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-13 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment. The case distinction in `case attr::AcquireCapability` is not very beautiful, but it's due to the fact that scoped capabilities are not "real" capabilities and so we need to distinguish them. What this still doesn't allow for is attributes on other classes than the

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-13 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 160505. aaronpuchert added a comment. Fix crash. The problem was that ACQUIRES with arguments did not no longer have (only) `this` as argument, hence our assumption that we would have only ScopedLockableFactEntry's was false. So now we lock a bit closer

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-13 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert reopened this revision. aaronpuchert added a comment. This revision is now accepted and ready to land. This didn't cross my mind, because an `ACQUIRES` attribute with arguments on a function other than the constructor does not add the argument locks to the set of managed mutexes. So

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment. Hello, this patch seems introduce a new crash, and I have reverted it in r339558. Here is the minimal test case: class SCOPED_LOCKABLE FileLock { public: explicit FileLock() EXCLUSIVE_LOCK_FUNCTION(file_); ~FileLock() UNLOCK_FUNCTION(file_); //vo

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision. aaron.ballman added a comment. Committed in r339456; if @delesley has concerns with the commit, they can be addressed post-commit. Thank you for the patch! Repository: rC Clang https://reviews.llvm.org/D49885

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-07 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert marked an inline comment as done. aaronpuchert added a comment. @delesley Did you have a chance to look at this yet? Repository: rC Clang https://reviews.llvm.org/D49885 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-07-28 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert marked 3 inline comments as done. aaronpuchert added inline comments. Comment at: lib/Analysis/ThreadSafety.cpp:960-961 +FSet.removeLock(FactMan, !UnderCp); +FSet.addLock(FactMan, llvm::make_unique(UnderCp, LK, +

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-07-28 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 157872. aaronpuchert added a comment. Formatting changes suggested by Aaron Ballman. Repository: rC Clang https://reviews.llvm.org/D49885 Files: lib/Analysis/ThreadSafety.cpp test/SemaCXX/warn-thread-safety-analysis.cpp Index: test/SemaCXX/warn

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-07-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. The changes look reasonable to me (after fixing a few nits), but please give @delesley a chance to weigh in before committing. Comment at: lib/Analysis/ThreadS

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-07-26 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment. Imagine having a producer loop, where we check a loop condition while holding a mutex, but release it in the loop body to let other producers/consumers do their work. In that scenario it makes sense to allow "relocking" a scope. RelockableScope Scope(mu); while

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-07-26 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision. aaronpuchert added reviewers: delesley, aaron.ballman. Herald added a subscriber: cfe-commits. It's already allowed to prematurely release a scoped lock, now we also allow relocking it again, possibly even in another mode. Arguably the solution is not very eleg