CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
143 lines
5.7 KiB
C++
143 lines
5.7 KiB
C++
// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.MismatchedIterator -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
|
|
// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.MismatchedIterator -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
|
|
|
|
#include "Inputs/system-header-simulator-cxx.h"
|
|
|
|
void good_insert1(std::vector<int> &V, int n) {
|
|
V.insert(V.cbegin(), n); // no-warning
|
|
}
|
|
|
|
void good_insert2(std::vector<int> &V, int len, int n) {
|
|
V.insert(V.cbegin(), len, n); // no-warning
|
|
}
|
|
|
|
void good_insert3(std::vector<int> &V1, std::vector<int> &V2) {
|
|
V1.insert(V1.cbegin(), V2.cbegin(), V2.cend()); // no-warning
|
|
}
|
|
|
|
void good_insert4(std::vector<int> &V, int len, int n) {
|
|
V.insert(V.cbegin(), {n-1, n, n+1}); // no-warning
|
|
}
|
|
|
|
void good_insert5(std::vector<int> &V, int len, int n) {
|
|
std::unordered_set<int> us;
|
|
us.insert(V.cbegin(), V.cend()); // no-warning
|
|
}
|
|
|
|
void good_insert_find(std::vector<int> &V, int n, int m) {
|
|
auto i = std::find(V.cbegin(), V.cend(), n);
|
|
V.insert(i, m); // no-warning
|
|
}
|
|
|
|
void good_erase1(std::vector<int> &V) {
|
|
V.erase(V.cbegin()); // no-warning
|
|
}
|
|
|
|
void good_erase2(std::vector<int> &V) {
|
|
V.erase(V.cbegin(), V.cend()); // no-warning
|
|
}
|
|
|
|
void good_emplace(std::vector<int> &V, int n) {
|
|
V.emplace(V.cbegin(), n); // no-warning
|
|
}
|
|
|
|
void good_ctor(std::vector<int> &V) {
|
|
std::vector<int> new_v(V.cbegin(), V.cend()); // no-warning
|
|
}
|
|
|
|
void good_find(std::vector<int> &V, int n) {
|
|
std::find(V.cbegin(), V.cend(), n); // no-warning
|
|
}
|
|
|
|
void good_find_first_of(std::vector<int> &V1, std::vector<int> &V2) {
|
|
std::find_first_of(V1.cbegin(), V1.cend(), V2.cbegin(), V2.cend()); // no-warning
|
|
}
|
|
|
|
void good_copy(std::vector<int> &V1, std::vector<int> &V2, int n) {
|
|
std::copy(V1.cbegin(), V1.cend(), V2.begin()); // no-warning
|
|
}
|
|
|
|
void bad_insert1(std::vector<int> &V1, std::vector<int> &V2, int n) {
|
|
V2.insert(V1.cbegin(), n); // expected-warning{{Container accessed using foreign iterator argument}}
|
|
}
|
|
|
|
void bad_insert2(std::vector<int> &V1, std::vector<int> &V2, int len, int n) {
|
|
V2.insert(V1.cbegin(), len, n); // expected-warning{{Container accessed using foreign iterator argument}}
|
|
}
|
|
|
|
void bad_insert3(std::vector<int> &V1, std::vector<int> &V2) {
|
|
V2.insert(V1.cbegin(), V2.cbegin(), V2.cend()); // expected-warning{{Container accessed using foreign iterator argument}}
|
|
V1.insert(V1.cbegin(), V1.cbegin(), V2.cend()); // expected-warning{{Iterators of different containers used where the same container is expected}}
|
|
V1.insert(V1.cbegin(), V2.cbegin(), V1.cend()); // expected-warning{{Iterators of different containers used where the same container is expected}}
|
|
}
|
|
|
|
void bad_insert4(std::vector<int> &V1, std::vector<int> &V2, int len, int n) {
|
|
V2.insert(V1.cbegin(), {n-1, n, n+1}); // expected-warning{{Container accessed using foreign iterator argument}}
|
|
}
|
|
|
|
void bad_insert5(std::vector<int> &V1, std::vector<int> &V2, int len, int n) {
|
|
std::unordered_set<int> us;
|
|
us.insert(V1.cbegin(), V2.cend()); // expected-warning{{Iterators of different containers used where the same container is expected}}
|
|
}
|
|
|
|
void bad_erase1(std::vector<int> &V1, std::vector<int> &V2) {
|
|
V2.erase(V1.cbegin()); // expected-warning{{Container accessed using foreign iterator argument}}
|
|
}
|
|
|
|
void bad_erase2(std::vector<int> &V1, std::vector<int> &V2) {
|
|
V2.erase(V2.cbegin(), V1.cend()); // expected-warning{{Container accessed using foreign iterator argument}}
|
|
V2.erase(V1.cbegin(), V2.cend()); // expected-warning{{Container accessed using foreign iterator argument}}
|
|
V2.erase(V1.cbegin(), V1.cend()); // expected-warning{{Container accessed using foreign iterator argument}}
|
|
}
|
|
|
|
void bad_emplace(std::vector<int> &V1, std::vector<int> &V2, int n) {
|
|
V2.emplace(V1.cbegin(), n); // expected-warning{{Container accessed using foreign iterator argument}}
|
|
}
|
|
|
|
void good_comparison(std::vector<int> &V) {
|
|
if (V.cbegin() == V.cend()) {} // no-warning
|
|
}
|
|
|
|
void bad_comparison(std::vector<int> &V1, std::vector<int> &V2) {
|
|
if (V1.cbegin() != V2.cend()) {} // expected-warning{{Iterators of different containers used where the same container is expected}}
|
|
}
|
|
|
|
void bad_ctor(std::vector<int> &V1, std::vector<int> &V2) {
|
|
std::vector<int> new_v(V1.cbegin(), V2.cend()); // expected-warning{{Iterators of different containers used where the same container is expected}}
|
|
}
|
|
|
|
void bad_find(std::vector<int> &V1, std::vector<int> &V2, int n) {
|
|
std::find(V1.cbegin(), V2.cend(), n); // expected-warning{{Iterators of different containers used where the same container is expected}}
|
|
}
|
|
|
|
void bad_find_first_of(std::vector<int> &V1, std::vector<int> &V2) {
|
|
std::find_first_of(V1.cbegin(), V2.cend(), V2.cbegin(), V2.cend()); // expected-warning{{Iterators of different containers used where the same container is expected}}
|
|
std::find_first_of(V1.cbegin(), V1.cend(), V2.cbegin(), V1.cend()); // expected-warning{{Iterators of different containers used where the same container is expected}}
|
|
}
|
|
|
|
std::vector<int> &return_vector_ref();
|
|
|
|
void ignore_conjured1() {
|
|
std::vector<int> &V1 = return_vector_ref(), &V2 = return_vector_ref();
|
|
|
|
V2.erase(V1.cbegin()); // no-warning
|
|
}
|
|
|
|
void ignore_conjured2() {
|
|
std::vector<int> &V1 = return_vector_ref(), &V2 = return_vector_ref();
|
|
|
|
if (V1.cbegin() == V2.cbegin()) {} //no-warning
|
|
}
|
|
|
|
template<typename T>
|
|
struct cont_with_ptr_iterator {
|
|
T *begin() const;
|
|
T *end() const;
|
|
};
|
|
|
|
void comparison_ptr_iterator(cont_with_ptr_iterator<int> &C1,
|
|
cont_with_ptr_iterator<int> &C2) {
|
|
if (C1.begin() != C2.end()) {} // expected-warning{{Iterators of different containers used where the same container is expected}}
|
|
}
|
|
|