[clang] Add unique_ptr <T[]> accesses to -Wunsafe-buffer-usage (PR #156773)
Jan Korous via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 17 11:48:09 PDT 2025
================
@@ -31,6 +31,20 @@ void test_unclaimed_use(int *p) { // expected-warning{{'p' is an unsafe pointer
p[5] = 5; // expected-note{{used in buffer access here}}
}
+namespace std {
+inline namespace __1 {
+template <class T> class unique_ptr {
+public:
+ T &operator[](long long i) const;
+};
+} // namespace __1
+} // namespace std
+
+void basic_unique_ptr() {
----------------
jkorous-apple wrote:
We should add more test cases - I imagine at a minimum we should have these:
- index is zero
- index is a non-zero integer literal
- index is a variable
- index is a simple arithmetic expression like `i + 5`
https://github.com/llvm/llvm-project/pull/156773
More information about the cfe-commits
mailing list