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

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 25 07:20:18 PDT 2022


Szelethus added a comment.

Seems like the issues mentioned above are real, but orthogonal to this patch. Would it be okay to address them in followup patches? @martong @NoQ



================
Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:927
     SVal RetVal = State->getSVal(CNE, LCtx);
+    State = State->bindDefaultInitial(RetVal, UndefinedVal{}, LCtx);
 
----------------
steakhal wrote:
> 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.
And a result skip the rest of this function?


================
Comment at: clang/test/Analysis/NewDelete-checker-test.cpp:388-392
+  ~DerefClass() {
+    int i = 0;
+    x = &i;
+    *x = 1;
+  }
----------------
steakhal wrote:
> This change seems unrelated.
> Could you elaborate on that?
The test case in its original version would have emitted an uninitialized use report, which is fine, but the intention is to test double deletes, not uninitialized use, hence the seemingly unrelated change.


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