diff options
author | Jordy Rose <jediknil@belkadan.com> | 2010-08-12 08:54:03 +0000 |
---|---|---|
committer | Jordy Rose <jediknil@belkadan.com> | 2010-08-12 08:54:03 +0000 |
commit | 2a479929f70d32f626778ef6e70ef46d3a37f74e (patch) | |
tree | 02514b9e7010e15d8fc89bd874cb8eecb5be8322 /lib/Checker/MallocChecker.cpp | |
parent | 6d311229f0b894f6a8acda2d78f06a4198b487b7 (diff) |
Remove OwnershipAttr::Kind, since it's essentially redundant with attr::Kind the way it's being used. Also fix isa<OwnershipAttr> support, break more-than-80-char lines, and other miscellaneous ownership attr cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110908 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/MallocChecker.cpp')
-rw-r--r-- | lib/Checker/MallocChecker.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/lib/Checker/MallocChecker.cpp b/lib/Checker/MallocChecker.cpp index b7ad4be00b..8765465d9c 100644 --- a/lib/Checker/MallocChecker.cpp +++ b/lib/Checker/MallocChecker.cpp @@ -100,7 +100,8 @@ private: const GRState *state); void FreeMem(CheckerContext &C, const CallExpr *CE); - void FreeMemAttr(CheckerContext &C, const CallExpr *CE, const OwnershipAttr* Att); + void FreeMemAttr(CheckerContext &C, const CallExpr *CE, + const OwnershipAttr* Att); const GRState *FreeMemAux(CheckerContext &C, const CallExpr *CE, const GRState *state, unsigned Num, bool Hold); @@ -176,22 +177,19 @@ bool MallocChecker::EvalCallExpr(CheckerContext &C, const CallExpr *CE) { bool rv = false; if (FD->hasAttrs()) { for (const Attr *attr = FD->getAttrs(); attr; attr = attr->getNext()) { - if(const OwnershipAttr* Att = dyn_cast<OwnershipAttr>(attr)) { - switch (Att->getKind()) { - case OwnershipAttr::Returns: { - MallocMemReturnsAttr(C, CE, Att); - rv = true; - break; - } - case OwnershipAttr::Takes: - case OwnershipAttr::Holds: { - FreeMemAttr(C, CE, Att); - rv = true; - break; - } - default: - break; - } + switch (attr->getKind()) { + case attr::OwnershipReturns: + MallocMemReturnsAttr(C, CE, cast<OwnershipAttr>(attr)); + rv = true; + break; + case attr::OwnershipTakes: + case attr::OwnershipHolds: + FreeMemAttr(C, CE, cast<OwnershipAttr>(attr)); + rv = true; + break; + default: + // Ignore non-ownership attributes. + break; } } } @@ -259,13 +257,13 @@ void MallocChecker::FreeMem(CheckerContext &C, const CallExpr *CE) { } void MallocChecker::FreeMemAttr(CheckerContext &C, const CallExpr *CE, - const OwnershipAttr* Att) { + const OwnershipAttr* Att) { if (!Att->isModule("malloc")) return; for (const unsigned *I = Att->begin(), *E = Att->end(); I != E; ++I) { const GRState *state = - FreeMemAux(C, CE, C.getState(), *I, Att->isKind(OwnershipAttr::Holds)); + FreeMemAux(C, CE, C.getState(), *I, isa<OwnershipHoldsAttr>(Att)); if (state) C.addTransition(state); } |