diff options
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
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<OwnershipAttr> - i = FD->specific_attr_begin<OwnershipAttr>(), - e = FD->specific_attr_end<OwnershipAttr>(); - i != e; ++i) - if ((*i)->getOwnKind() == OwnershipAttr::Returns) + for (const auto *I : FD->specific_attrs<OwnershipAttr>()) + 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<OwnershipAttr> - i = FD->specific_attr_begin<OwnershipAttr>(), - e = FD->specific_attr_end<OwnershipAttr>(); - i != e; ++i) - if ((*i)->getOwnKind() == OwnershipAttr::Takes || - (*i)->getOwnKind() == OwnershipAttr::Holds) + for (const auto *I : FD->specific_attrs<OwnershipAttr>()) + 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<OwnershipAttr> - i = FD->specific_attr_begin<OwnershipAttr>(), - e = FD->specific_attr_end<OwnershipAttr>(); - i != e; ++i) { - switch ((*i)->getOwnKind()) { + for (const auto *I : FD->specific_attrs<OwnershipAttr>()) { + 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; } } |