[PATCH] D76379: [Analyzer] IteratorRangeChecker verify `std::advance()`, `std::prev()` and `std::next()`
Balogh, Ádám via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 19 03:44:59 PDT 2020
baloghadamsoftware updated this revision to Diff 251320.
baloghadamsoftware added a comment.
Updated according to the comments and automatic formatting suggestions.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76379/new/
https://reviews.llvm.org/D76379
Files:
clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
clang/test/Analysis/Inputs/system-header-simulator-cxx.h
Index: clang/test/Analysis/Inputs/system-header-simulator-cxx.h
===================================================================
--- clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -785,8 +785,8 @@
template <class ForwardIterator>
ForwardIterator
- next (ForwardIterator it,
- typename iterator_traits<ForwardIterator>::difference_type n = 1) {
+ next(ForwardIterator it,
+ typename iterator_traits<ForwardIterator>::difference_type n = 1) {
advance(it, n);
return it;
}
Index: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
@@ -41,21 +41,19 @@
void verifyNext(CheckerContext &C, SVal LHS, SVal RHS) const;
void reportBug(const StringRef &Message, SVal Val, CheckerContext &C,
ExplodedNode *ErrNode) const;
+
public:
IteratorRangeChecker();
void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
- typedef void (IteratorRangeChecker::*AdvanceFn)(CheckerContext &, SVal,
- SVal) const;
+ using AdvanceFn = void (IteratorRangeChecker::*)(CheckerContext &, SVal,
+ SVal) const;
CallDescriptionMap<AdvanceFn> AdvanceFunctions = {
- {{{"std", "advance"}, 2},
- &IteratorRangeChecker::verifyAdvance},
- {{{"std", "prev"}, 2},
- &IteratorRangeChecker::verifyPrev},
- {{{"std", "next"}, 2},
- &IteratorRangeChecker::verifyNext},
+ {{{"std", "advance"}, 2}, &IteratorRangeChecker::verifyAdvance},
+ {{{"std", "prev"}, 2}, &IteratorRangeChecker::verifyPrev},
+ {{{"std", "next"}, 2}, &IteratorRangeChecker::verifyNext},
};
};
@@ -128,8 +126,9 @@
(this->**Verifier)(C, Call.getArgSVal(0), Call.getArgSVal(1));
} else {
auto &BVF = C.getSValBuilder().getBasicValueFactory();
- (this->**Verifier)(C, Call.getArgSVal(0),
- nonloc::ConcreteInt(BVF.getValue(llvm::APSInt::get(1))));
+ (this->**Verifier)(
+ C, Call.getArgSVal(0),
+ nonloc::ConcreteInt(BVF.getValue(llvm::APSInt::get(1))));
}
}
}
@@ -161,8 +160,8 @@
}
void IteratorRangeChecker::verifyRandomIncrOrDecr(CheckerContext &C,
- OverloadedOperatorKind Op,
- SVal LHS, SVal RHS) const {
+ OverloadedOperatorKind Op,
+ SVal LHS, SVal RHS) const {
auto State = C.getState();
auto Value = RHS;
@@ -213,7 +212,7 @@
}
void IteratorRangeChecker::verifyNext(CheckerContext &C, SVal LHS,
- SVal RHS) const {
+ SVal RHS) const {
verifyRandomIncrOrDecr(C, OO_Plus, LHS, RHS);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76379.251320.patch
Type: text/x-patch
Size: 3115 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200319/6d29eef8/attachment-0001.bin>
More information about the cfe-commits
mailing list