r188581 - RetainCountChecker: Replace some loops with std:: algorithms.
Benjamin Kramer
benny.kra at googlemail.com
Fri Aug 16 14:57:14 PDT 2013
Author: d0k
Date: Fri Aug 16 16:57:14 2013
New Revision: 188581
URL: http://llvm.org/viewvc/llvm-project?rev=188581&view=rev
Log:
RetainCountChecker: Replace some loops with std:: algorithms.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=188581&r1=188580&r2=188581&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Fri Aug 16 16:57:14 2013
@@ -321,11 +321,7 @@ public:
/// Return the number of argument effects. This is O(n) in the number
/// of arguments.
unsigned getNumArgs() const {
- unsigned N = 0;
- for (ArgEffects::iterator I = Args.begin(), E = Args.end(); I != E; ++I) {
- ++N;
- };
- return N;
+ return std::distance(Args.begin(), Args.end());
}
void addArg(ArgEffects::Factory &af, unsigned idx, ArgEffect e) {
@@ -1754,16 +1750,6 @@ void CFRefReport::addGCModeDescription(c
addExtraText(GCModeDescription);
}
-// FIXME: This should be a method on SmallVector.
-static inline bool contains(const SmallVectorImpl<ArgEffect>& V,
- ArgEffect X) {
- for (SmallVectorImpl<ArgEffect>::const_iterator I=V.begin(), E=V.end();
- I!=E; ++I)
- if (*I == X) return true;
-
- return false;
-}
-
static bool isNumericLiteralExpression(const Expr *E) {
// FIXME: This set of cases was copied from SemaExprObjC.
return isa<IntegerLiteral>(E) ||
@@ -1925,7 +1911,8 @@ PathDiagnosticPiece *CFRefReportVisitor:
RefVal PrevV = *PrevT;
// Specially handle -dealloc.
- if (!GCEnabled && contains(AEffects, Dealloc)) {
+ if (!GCEnabled && std::find(AEffects.begin(), AEffects.end(), Dealloc) !=
+ AEffects.end()) {
// Determine if the object's reference count was pushed to zero.
assert(!(PrevV == CurrV) && "The typestate *must* have changed.");
// We may not have transitioned to 'release' if we hit an error.
@@ -1938,7 +1925,8 @@ PathDiagnosticPiece *CFRefReportVisitor:
}
// Specially handle CFMakeCollectable and friends.
- if (contains(AEffects, MakeCollectable)) {
+ if (std::find(AEffects.begin(), AEffects.end(), MakeCollectable) !=
+ AEffects.end()) {
// Get the name of the function.
const Stmt *S = N->getLocation().castAs<StmtPoint>().getStmt();
SVal X =
More information about the cfe-commits
mailing list