diff options
| author | Aaron Puchert <aaronpuchert@alice-dsl.net> | 2018-09-21 23:08:30 +0000 |
|---|---|---|
| committer | Aaron Puchert <aaronpuchert@alice-dsl.net> | 2018-09-21 23:08:30 +0000 |
| commit | 969f32d5154de94427e922e265b4ebe3c912facb (patch) | |
| tree | 1f9053b91963995a2c4dec1807d53421390458b8 /clang/lib/Analysis | |
| parent | 4f27730eaf600aeeb855964de09b90ff168ae247 (diff) | |
| download | bcm5719-llvm-969f32d5154de94427e922e265b4ebe3c912facb.tar.gz bcm5719-llvm-969f32d5154de94427e922e265b4ebe3c912facb.zip | |
Thread safety analysis: Make sure FactEntrys stored in FactManager are immutable [NFC]
Since FactEntrys are stored in the FactManager, we can't manipulate them
anymore when they are stored there.
llvm-svn: 342787
Diffstat (limited to 'clang/lib/Analysis')
| -rw-r--r-- | clang/lib/Analysis/ThreadSafety.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp index 88b3f3c2c10..e11ba12501f 100644 --- a/clang/lib/Analysis/ThreadSafety.cpp +++ b/clang/lib/Analysis/ThreadSafety.cpp @@ -151,7 +151,7 @@ public: StringRef DiagKind) const = 0; // Return true if LKind >= LK, where exclusive > shared - bool isAtLeast(LockKind LK) { + bool isAtLeast(LockKind LK) const { return (LKind == LK_Exclusive) || (LK == LK_Shared); } }; @@ -162,7 +162,7 @@ using FactID = unsigned short; /// the analysis of a single routine. class FactManager { private: - std::vector<std::unique_ptr<FactEntry>> Facts; + std::vector<std::unique_ptr<const FactEntry>> Facts; public: FactID newFact(std::unique_ptr<FactEntry> Entry) { @@ -171,7 +171,6 @@ public: } const FactEntry &operator[](FactID F) const { return *Facts[F]; } - FactEntry &operator[](FactID F) { return *Facts[F]; } }; /// A FactSet is the set of facts that are known to be true at a @@ -241,22 +240,23 @@ public: }); } - FactEntry *findLock(FactManager &FM, const CapabilityExpr &CapE) const { + const FactEntry *findLock(FactManager &FM, const CapabilityExpr &CapE) const { auto I = std::find_if(begin(), end(), [&](FactID ID) { return FM[ID].matches(CapE); }); return I != end() ? &FM[*I] : nullptr; } - FactEntry *findLockUniv(FactManager &FM, const CapabilityExpr &CapE) const { + const FactEntry *findLockUniv(FactManager &FM, + const CapabilityExpr &CapE) const { auto I = std::find_if(begin(), end(), [&](FactID ID) -> bool { return FM[ID].matchesUniv(CapE); }); return I != end() ? &FM[*I] : nullptr; } - FactEntry *findPartialMatch(FactManager &FM, - const CapabilityExpr &CapE) const { + const FactEntry *findPartialMatch(FactManager &FM, + const CapabilityExpr &CapE) const { auto I = std::find_if(begin(), end(), [&](FactID ID) -> bool { return FM[ID].partiallyMatches(CapE); }); @@ -1258,7 +1258,7 @@ void ThreadSafetyAnalyzer::addLock(FactSet &FSet, if (!ReqAttr && !Entry->negative()) { // look for the negative capability, and remove it from the fact set. CapabilityExpr NegC = !*Entry; - FactEntry *Nen = FSet.findLock(FactMan, NegC); + const FactEntry *Nen = FSet.findLock(FactMan, NegC); if (Nen) { FSet.removeLock(FactMan, NegC); } @@ -1277,7 +1277,7 @@ void ThreadSafetyAnalyzer::addLock(FactSet &FSet, } // FIXME: Don't always warn when we have support for reentrant locks. - if (FactEntry *Cp = FSet.findLock(FactMan, *Entry)) { + if (const FactEntry *Cp = FSet.findLock(FactMan, *Entry)) { if (!Entry->asserted()) Cp->handleLock(FSet, FactMan, *Entry, Handler, DiagKind); } else { @@ -1575,7 +1575,7 @@ void BuildLockset::warnIfMutexNotHeld(const NamedDecl *D, const Expr *Exp, if (Cp.negative()) { // Negative capabilities act like locks excluded - FactEntry *LDat = FSet.findLock(Analyzer->FactMan, !Cp); + const FactEntry *LDat = FSet.findLock(Analyzer->FactMan, !Cp); if (LDat) { Analyzer->Handler.handleFunExcludesLock( DiagKind, D->getNameAsString(), (!Cp).toString(), Loc); @@ -1596,7 +1596,7 @@ void BuildLockset::warnIfMutexNotHeld(const NamedDecl *D, const Expr *Exp, return; } - FactEntry* LDat = FSet.findLockUniv(Analyzer->FactMan, Cp); + const FactEntry *LDat = FSet.findLockUniv(Analyzer->FactMan, Cp); bool NoError = true; if (!LDat) { // No exact match found. Look for a partial match. @@ -1632,7 +1632,7 @@ void BuildLockset::warnIfMutexHeld(const NamedDecl *D, const Expr *Exp, return; } - FactEntry* LDat = FSet.findLock(Analyzer->FactMan, Cp); + const FactEntry *LDat = FSet.findLock(Analyzer->FactMan, Cp); if (LDat) { Analyzer->Handler.handleFunExcludesLock( DiagKind, D->getNameAsString(), Cp.toString(), Exp->getExprLoc()); |

