[clang] [analyzer] Fix uninitialized base class with initializer list when ctor is not declared in the base class (#70464) (PR #70792)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 31 11:04:40 PDT 2023


================
@@ -1222,6 +1222,15 @@ void ExprEngine::ProcessInitializer(const CFGInitializer CFGInit,
       PostInitializer PP(BMI, FieldLoc.getAsRegion(), stackFrame);
       evalBind(Tmp, Init, Pred, FieldLoc, InitVal, /*isInit=*/true, &PP);
     }
+  } else if (BMI->isBaseInitializer() && isa<InitListExpr>(Init)) {
+    // When the base class is initialized with an initialization list, there
+    // will not be a CXXConstructExpr to initialize the base region. Hence, we
+    // need to make the bind for it.
+    StoreManager &StoreMgr = State->getStateManager().getStoreManager();
+    SVal BaseLoc = StoreMgr.evalDerivedToBase(
+        thisVal, QualType(BMI->getBaseClass(), 0), BMI->isBaseVirtual());
+    SVal InitVal = State->getSVal(Init, stackFrame);
+    evalBind(Tmp, Init, Pred, BaseLoc, InitVal, true);
----------------
steakhal wrote:

Well, me neither but I think it should be fine with the default.

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


More information about the cfe-commits mailing list