================ @@ -1139,6 +1289,271 @@ void deque_insert_end(std::deque<int> &D, int n) { // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $D.end() - 1 } +/// insert_range() +/// +/// - Design decision: shifts positions to the <-LEFT<- (i.e. all iterator +/// ahead of the insertion point are decremented; if the +/// relation between the insertion point and the first +/// position of the container is known, the first position +/// of the container is also decremented). +/// +/// - Iterator invalidation rules depend the container type. + +/// std::list-like containers: No iterators are invalidated. + +void list_insert_range_begin(std::list<int> &L, std::vector<int>& vec) { + auto i0 = L.cbegin(), i1 = L.cend(); + + clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); + clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); + + auto i2 = L.insert_range(i0, vec); + + clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + + clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning-re {{$L.begin(){{$}}}} + // clang_analyzer_express(clang_analyzer_iterator_position(i2)); FIXME: expect warning $L.begin() - 1 + clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning-re {{$L.end(){{$}}}} +} + +void list_insert_range_behind_begin(std::list<int> &L, std::vector<int>& vec) { + auto i0 = L.cbegin(), i1 = ++L.cbegin(), i2 = L.cend(); + + clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); + clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); + + auto i3 = L.insert_range(i1, vec); + + clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + + clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning-re {{$L.begin(){{$}}}} FIXME: Should be $L.begin() - 1 + clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning-re {{$L.begin() + 1{{$}}}} + // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $L.begin() ---------------- flovent wrote:
These check lines is disabled because currently `ContainerModeling` doesn't model these function's return value like `insert`, this checker only models impact for container now except `begin`(`cbegin`) and `end`(`cend`) call https://github.com/llvm/llvm-project/pull/129719 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits