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
85 lines
3.3 KiB
C++
85 lines
3.3 KiB
C++
// RUN: %check_clang_tidy -std=c++14-or-later %s bugprone-nondeterministic-pointer-iteration-order %t -- -- -I%S
|
|
|
|
#include "Inputs/system-header-simulator/sim_set"
|
|
#include "Inputs/system-header-simulator/sim_unordered_set"
|
|
#include "Inputs/system-header-simulator/sim_map"
|
|
#include "Inputs/system-header-simulator/sim_unordered_map"
|
|
#include "Inputs/system-header-simulator/sim_vector"
|
|
#include "Inputs/system-header-simulator/sim_algorithm"
|
|
|
|
template<class T>
|
|
void f(T x);
|
|
|
|
void PointerIteration() {
|
|
int a = 1, b = 2;
|
|
std::set<int> OrderedIntSet = {a, b};
|
|
std::set<int *> OrderedPtrSet = {&a, &b};
|
|
std::unordered_set<int> UnorderedIntSet = {a, b};
|
|
std::unordered_set<int *> UnorderedPtrSet = {&a, &b};
|
|
std::map<int, int> IntMap = { std::make_pair(a,a), std::make_pair(b,b) };
|
|
std::map<int*, int*> PtrMap = { std::make_pair(&a,&a), std::make_pair(&b,&b) };
|
|
std::unordered_map<int, int> IntUnorderedMap = { std::make_pair(a,a), std::make_pair(b,b) };
|
|
std::unordered_map<int*, int*> PtrUnorderedMap = { std::make_pair(&a,&a), std::make_pair(&b,&b) };
|
|
|
|
for (auto i : OrderedIntSet) // no-warning
|
|
f(i);
|
|
|
|
for (auto i : OrderedPtrSet) // no-warning
|
|
f(i);
|
|
|
|
for (auto i : UnorderedIntSet) // no-warning
|
|
f(i);
|
|
|
|
for (auto i : UnorderedPtrSet)
|
|
f(i);
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:17: warning: iteration of pointers is nondeterministic
|
|
|
|
for (auto &i : UnorderedPtrSet)
|
|
f(i);
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:18: warning: iteration of pointers is nondeterministic
|
|
|
|
for (auto &i : IntMap) // no-warning
|
|
f(i);
|
|
|
|
for (auto &i : PtrMap) // no-warning
|
|
f(i);
|
|
|
|
for (auto &i : IntUnorderedMap) // no-warning
|
|
f(i);
|
|
|
|
for (auto &i : PtrUnorderedMap)
|
|
f(i);
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:18: warning: iteration of pointers is nondeterministic
|
|
}
|
|
|
|
bool g (int *x) { return true; }
|
|
bool h (int x) { return true; }
|
|
|
|
void PointerSorting() {
|
|
int a = 1, b = 2, c = 3;
|
|
std::vector<int> V1 = {a, b};
|
|
std::vector<int *> V2 = {&a, &b};
|
|
|
|
std::is_sorted(V1.begin(), V1.end()); // no-warning
|
|
std::nth_element(V1.begin(), V1.begin() + 1, V1.end()); // no-warning
|
|
std::partial_sort(V1.begin(), V1.begin() + 1, V1.end()); // no-warning
|
|
std::sort(V1.begin(), V1.end()); // no-warning
|
|
std::stable_sort(V1.begin(), V1.end()); // no-warning
|
|
std::partition(V1.begin(), V1.end(), h); // no-warning
|
|
std::stable_partition(V1.begin(), V1.end(), h); // no-warning
|
|
std::is_sorted(V2.begin(), V2.end());
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: sorting pointers is nondeterministic
|
|
std::nth_element(V2.begin(), V2.begin() + 1, V2.end());
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: sorting pointers is nondeterministic
|
|
std::partial_sort(V2.begin(), V2.begin() + 1, V2.end());
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: sorting pointers is nondeterministic
|
|
std::sort(V2.begin(), V2.end());
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: sorting pointers is nondeterministic
|
|
std::stable_sort(V2.begin(), V2.end());
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: sorting pointers is nondeterministic
|
|
std::partition(V2.begin(), V2.end(), g);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: sorting pointers is nondeterministic
|
|
std::stable_partition(V2.begin(), V2.end(), g);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: sorting pointers is nondeterministic
|
|
}
|