[clang] [analyzer] Do list initialization for CXXNewExpr with initializer list arg (PR #127702)

Michael Flanders via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 28 08:25:33 PST 2025


================
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 -verify %s\
+// RUN:   -analyzer-checker=core,debug.ExprInspection
+
+void clang_analyzer_eval(bool);
+
+using size_t = decltype(sizeof(int));
+
+template <class FirstT, class... Rest>
+void escape(FirstT first, Rest... args);
+
+namespace CustomClassType {
+struct S {
+  int x;
+  static void* operator new(size_t size) {
+    return ::operator new(size);
+  }
+};
+void F() {
+  S *s = new S;
+  clang_analyzer_eval(s->x); // expected-warning{{UNKNOWN}} FIXME: should be an undefined warning
----------------
Flandini wrote:

S is default initialized. Maybe I misunderstand how CSA handles undefined/unknown values. I would expect usage of `s->x` to warn, but maybe if I change this to use `s->x` more like `1 + s->x` then I would get the warning?

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


More information about the cfe-commits mailing list