[clang] [StaticAnalyzer] Make it a noop when initializing a field of empty record (PR #138594)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Tue May 6 05:07:22 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_;
----------------
steakhal wrote:

Now I [see](https://buildkite.com/llvm-project/github-pull-requests/builds/175624) what test didn't pass on Windows.

https://github.com/llvm/llvm-project/pull/138594


More information about the cfe-commits mailing list