diff options
author | DeLesley Hutchins <delesley@google.com> | 2013-08-15 23:06:33 +0000 |
---|---|---|
committer | DeLesley Hutchins <delesley@google.com> | 2013-08-15 23:06:33 +0000 |
commit | 9f5193cf6172ae02c9cae52def52de9d87c437eb (patch) | |
tree | e93651a98aa8e52b82de673beb06f188cb9b2800 /clang/lib/Analysis/ThreadSafety.cpp | |
parent | e66f3d6d505498f76f8a02d6ba6e922f092630ba (diff) | |
download | bcm5719-llvm-9f5193cf6172ae02c9cae52def52de9d87c437eb.tar.gz bcm5719-llvm-9f5193cf6172ae02c9cae52def52de9d87c437eb.zip |
Thread Safety Analysis: fix bug when using TryLock with && and || expressions.
llvm-svn: 188505
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; |