diff options
Diffstat (limited to 'clang/lib/Analysis/ThreadSafety.cpp')
| -rw-r--r-- | clang/lib/Analysis/ThreadSafety.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp index 0c90751155d..d0655878c7c 100644 --- a/clang/lib/Analysis/ThreadSafety.cpp +++ b/clang/lib/Analysis/ThreadSafety.cpp @@ -1660,15 +1660,22 @@ const CallExpr* ThreadSafetyAnalyzer::getTrylockCallExpr(const Stmt *Cond, if (!TCond) Negate = !Negate; return getTrylockCallExpr(BOP->getLHS(), C, Negate); } - else if (getStaticBooleanValue(BOP->getLHS(), TCond)) { + TCond = false; + if (getStaticBooleanValue(BOP->getLHS(), TCond)) { if (!TCond) Negate = !Negate; return getTrylockCallExpr(BOP->getRHS(), C, Negate); } return 0; } + if (BOP->getOpcode() == BO_LAnd) { + // LHS must have been evaluated in a different block. + return getTrylockCallExpr(BOP->getRHS(), C, Negate); + } + if (BOP->getOpcode() == BO_LOr) { + return getTrylockCallExpr(BOP->getRHS(), C, Negate); + } return 0; } - // FIXME -- handle && and || as well. return 0; } @@ -1682,11 +1689,11 @@ void ThreadSafetyAnalyzer::getEdgeLockset(FactSet& Result, const CFGBlock *CurrBlock) { Result = ExitSet; - if (!PredBlock->getTerminatorCondition()) + const Stmt *Cond = PredBlock->getTerminatorCondition(); + if (!Cond) return; bool Negate = false; - const Stmt *Cond = PredBlock->getTerminatorCondition(); const CFGBlockInfo *PredBlockInfo = &BlockInfo[PredBlock->getBlockID()]; const LocalVarContext &LVarCtx = PredBlockInfo->ExitContext; @@ -1699,7 +1706,6 @@ void ThreadSafetyAnalyzer::getEdgeLockset(FactSet& Result, if(!FunDecl || !FunDecl->hasAttrs()) return; - MutexIDList ExclusiveLocksToAdd; MutexIDList SharedLocksToAdd; |

