================
@@ -0,0 +1,83 @@
+// RUN: %check_clang_tidy %s bugprone-nondeterministic-pointer-iteration-order
%t -- -- -I%S -std=c++!4
+
+#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]]:32: warning: Iteration of pointers is
nondeterministic
+
+ for (auto &i : UnorderedPtrSet) // no-warning
+ f(i);
----------------
vabridgers wrote:
completed, resolving.
https://github.com/llvm/llvm-project/pull/110471
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits