aaron.ballman added inline comments.
================
Comment at: lib/Analysis/ThreadSafety.cpp:1445
+ if (!TCond && FCond) {
+ Negate = !Negate;
+ return getTrylockCallExpr(COP->getCond(), C, Negate);
----------------
Rather than do an assignment here, why not just pass `!Negate` directly below,
since you're returning?
================
Comment at: test/SemaCXX/warn-thread-safety-analysis.cpp:1879-1880
+ void foo13() {
+ if (mu.TryLock() ? 1 : 0)
+ mu.Unlock();
+ }
----------------
Can you add a test that shows we get it right even if the user does something
less than practical, like:
```
if (mu.TryLock() ? mu.TryLock() : false); // Warn about double lock
if (mu.TryLock() ? mu.Unlock(), 1 : 0)
mu.Unlock(); // Warn about unlocking unheld lock
if (mu.TryLock() ? 1 : mu.Unlock(), 0)
mu.Unlock(); // Warn about unlocking an unheld lock
if (mu.TryLock() ? (true ? mu.TryLock() : false) : false); // Warn about double
lock
```
Repository:
rC Clang
https://reviews.llvm.org/D52888
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits