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
diff --git a/lib/Checker/MallocChecker.cpp b/lib/Checker/MallocChecker.cpp
index b7ad4be..8765465 100644
--- a/lib/Checker/MallocChecker.cpp
+++ b/lib/Checker/MallocChecker.cpp
@@ -100,7 +100,8 @@
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 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::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);
}