From 2a479929f70d32f626778ef6e70ef46d3a37f74e Mon Sep 17 00:00:00 2001 From: Jordy Rose Date: Thu, 12 Aug 2010 08:54:03 +0000 Subject: Remove OwnershipAttr::Kind, since it's essentially redundant with attr::Kind the way it's being used. Also fix isa 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 --- lib/Checker/MallocChecker.cpp | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'lib/Checker/MallocChecker.cpp') 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(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(attr)); + rv = true; + break; + case attr::OwnershipTakes: + case attr::OwnershipHolds: + FreeMemAttr(C, CE, cast(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(Att)); if (state) C.addTransition(state); } -- cgit v1.2.3-70-g09d2