[clang] [clang][analyzer] Add support for detecting uninitialized dynamically-allocated objects (PR #193001)

via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 22 02:51:00 PDT 2026


================
@@ -451,26 +451,44 @@ static void printTail(llvm::raw_ostream &Out,
 //                           Utility functions.
 //===----------------------------------------------------------------------===//
 
+static const SubRegion *
+getConstructedSubRegion(const CXXConstructorDecl *CtorDecl,
+                        CheckerContext &Context) {
+  Loc ThisLoc =
+      Context.getSValBuilder().getCXXThis(CtorDecl, Context.getStackFrame());
+  SVal ObjectV = Context.getState()->getSVal(ThisLoc);
----------------
guillem-bartrina-sonarsource wrote:

I'm not saying that CXXThisRegion is always a SubRegion; what I meant is that the CXXThisRegion inside a CXXConstructorDecl (not in a CXXMethodDecl or a CXXDestructorDecl) must always be a SubRegion, and therefore we cannot create a test case that causes a failure at that point. Note that the Decl we're looking at is always a constructor.

I can't think of any way to do it, nor are there any instance of it in the lit tests.

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


More information about the cfe-commits mailing list