From be22bcb180714600926d5247ad9439f75cfc49db Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Mon, 10 Mar 2014 17:08:28 +0000 Subject: [C++11] Replacing DeclBase iterators specific_attr_begin() and specific_attr_end() with iterator_range specific_attrs(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203474 --- .../lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 27 ++++++++-------------- 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp') diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 51d26d8a648..ca40bebc99c 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -512,11 +512,8 @@ bool MallocChecker::isAllocationFunction(const FunctionDecl *FD, } if (ChecksEnabled[CK_MallocOptimistic] && FD->hasAttrs()) - for (specific_attr_iterator - i = FD->specific_attr_begin(), - e = FD->specific_attr_end(); - i != e; ++i) - if ((*i)->getOwnKind() == OwnershipAttr::Returns) + for (const auto *I : FD->specific_attrs()) + if (I->getOwnKind() == OwnershipAttr::Returns) return true; return false; } @@ -534,12 +531,9 @@ bool MallocChecker::isFreeFunction(const FunctionDecl *FD, ASTContext &C) const } if (ChecksEnabled[CK_MallocOptimistic] && FD->hasAttrs()) - for (specific_attr_iterator - i = FD->specific_attr_begin(), - e = FD->specific_attr_end(); - i != e; ++i) - if ((*i)->getOwnKind() == OwnershipAttr::Takes || - (*i)->getOwnKind() == OwnershipAttr::Holds) + for (const auto *I : FD->specific_attrs()) + if (I->getOwnKind() == OwnershipAttr::Takes || + I->getOwnKind() == OwnershipAttr::Holds) return true; return false; } @@ -633,17 +627,14 @@ void MallocChecker::checkPostStmt(const CallExpr *CE, CheckerContext &C) const { // Check all the attributes, if there are any. // There can be multiple of these attributes. if (FD->hasAttrs()) - for (specific_attr_iterator - i = FD->specific_attr_begin(), - e = FD->specific_attr_end(); - i != e; ++i) { - switch ((*i)->getOwnKind()) { + for (const auto *I : FD->specific_attrs()) { + switch (I->getOwnKind()) { case OwnershipAttr::Returns: - State = MallocMemReturnsAttr(C, CE, *i); + State = MallocMemReturnsAttr(C, CE, I); break; case OwnershipAttr::Takes: case OwnershipAttr::Holds: - State = FreeMemAttr(C, CE, *i); + State = FreeMemAttr(C, CE, I); break; } } -- cgit v1.2.3