[PATCH] D135375: [analyzer] Initialize regions returned by CXXNew to undefined

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 6 12:32:36 PDT 2022


steakhal added a comment.

Awesome!
Have you measured how often would this change introduce new garbage value warnings?
At the other side of the spectrum it could also hide reports, because it sinks the path too soon due to the falsely binding uninitialized value there.
WDYT?



================
Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:927
     SVal RetVal = State->getSVal(CNE, LCtx);
+    State = State->bindDefaultInitial(RetVal, UndefinedVal{}, LCtx);
 
----------------
Yeey, finally we will have this :D

I wonder if we could query from the `ASTContext` if we have a trivially constructible class typeor something as a first approximation.


================
Comment at: clang/test/Analysis/NewDelete-checker-test.cpp:388-392
+  ~DerefClass() {
+    int i = 0;
+    x = &i;
+    *x = 1;
+  }
----------------
This change seems unrelated.
Could you elaborate on that?


================
Comment at: clang/test/Analysis/new.cpp:180-182
 //--------------------------------
 // Incorrectly-modelled behavior
 //--------------------------------
----------------
You should probably adjust this comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135375/new/

https://reviews.llvm.org/D135375



More information about the cfe-commits mailing list