[clang] [StaticAnalyzer] Make it a noop when initializing a field of empty record (PR #138594)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 5 17:37:59 PDT 2025
================
@@ -0,0 +1,45 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus -verify %s -DEMPTY_CLASS
+
+// expected-no-diagnostics
+
+// This test reproduces the issue that previously the static analyzer
+// initialized an [[__no_unique_address__]] empty field to zero,
+// over-writing a non-empty field with the same offset.
+
+namespace std {
+#ifdef EMPTY_CLASS
+
+ template <typename T>
+ class default_delete {
+ T dump();
+ static T x;
+ };
+ template <class _Tp, class _Dp = default_delete<_Tp> >
+#else
+
+ struct default_delete {};
+ template <class _Tp, class _Dp = default_delete >
+#endif
+ class unique_ptr {
+ [[__no_unique_address__]] _Tp * __ptr_;
----------------
isuckatcs wrote:
Hmm, we get a failing test that says, this attribute doesn't exist on Windows. We need `msvc::no_uniqu_address` there, according to the [documentation](https://clang.llvm.org/docs/AttributeReference.html#no-unique-address).
https://github.com/llvm/llvm-project/pull/138594
More information about the cfe-commits
mailing list