diff options
author | DeLesley Hutchins <delesley@google.com> | 2012-08-31 21:57:32 +0000 |
---|---|---|
committer | DeLesley Hutchins <delesley@google.com> | 2012-08-31 21:57:32 +0000 |
commit | 4e4c15765d5f097e21dcaa30f1a94481924340f7 (patch) | |
tree | ffc7caf5798970e4ad64c730104b8b7582bad400 /lib/Analysis/ThreadSafety.cpp | |
parent | 35adca009c65a9578b91ab0bdca13691624e13af (diff) |
Thread-safety analysis: fix handling of string constants in mutex
expressions, which should be ignored right now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163026 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ThreadSafety.cpp')
-rw-r--r-- | lib/Analysis/ThreadSafety.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Analysis/ThreadSafety.cpp b/lib/Analysis/ThreadSafety.cpp index 277359ad63..77785d3e29 100644 --- a/lib/Analysis/ThreadSafety.cpp +++ b/lib/Analysis/ThreadSafety.cpp @@ -445,6 +445,12 @@ private: void buildSExprFromExpr(Expr *MutexExp, Expr *DeclExp, const NamedDecl *D) { CallingContext CallCtx(D); + // Ignore string literals + if (MutexExp && isa<StringLiteral>(MutexExp)) { + makeNop(); + return; + } + // If we are processing a raw attribute expression, with no substitutions. if (DeclExp == 0) { buildSExpr(MutexExp, 0); @@ -506,6 +512,12 @@ public: return !NodeVec.empty(); } + bool shouldIgnore() const { + // Nop is a mutex that we have decided to deliberately ignore. + assert(NodeVec.size() > 0 && "Invalid Mutex"); + return NodeVec[0].kind() == EOP_Nop; + } + /// Issue a warning about an invalid lock expression static void warnInvalidLock(ThreadSafetyHandler &Handler, Expr* MutexExp, Expr *DeclExp, const NamedDecl* D) { @@ -1376,6 +1388,9 @@ void ThreadSafetyAnalyzer::addLock(FactSet &FSet, const SExpr &Mutex, const LockData &LDat) { // FIXME: deal with acquired before/after annotations. // FIXME: Don't always warn when we have support for reentrant locks. + if (Mutex.shouldIgnore()) + return; + if (FSet.findLock(FactMan, Mutex)) { Handler.handleDoubleLock(Mutex.toString(), LDat.AcquireLoc); } else { @@ -1391,6 +1406,9 @@ void ThreadSafetyAnalyzer::removeLock(FactSet &FSet, const SExpr &Mutex, SourceLocation UnlockLoc, bool FullyRemove) { + if (Mutex.shouldIgnore()) + return; + const LockData *LDat = FSet.findLock(FactMan, Mutex); if (!LDat) { Handler.handleUnmatchedUnlock(Mutex.toString(), UnlockLoc); @@ -1703,6 +1721,8 @@ void BuildLockset::warnIfMutexNotHeld(const NamedDecl *D, Expr *Exp, SExpr Mutex(MutexExp, Exp, D); if (!Mutex.isValid()) SExpr::warnInvalidLock(Analyzer->Handler, MutexExp, Exp, D); + else if (Mutex.shouldIgnore()) + return; // A Nop is an invalid mutex that we've decided to ignore. else if (!locksetContainsAtLeast(Mutex, LK)) Analyzer->Handler.handleMutexNotHeld(D, POK, Mutex.toString(), LK, Exp->getExprLoc()); |