[clang] [clang][ExprConst] Support virtual bases in C++26 (PR #204289)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 29 10:54:46 PDT 2026
================
@@ -110,10 +112,30 @@ static bool CheckFieldsInitialized(InterpState &S, SourceLocation Loc,
}
return false;
}
- Result &= CheckFieldsInitialized(S, Loc, P, B.R);
+ Result &= CheckFieldsInitialized(S, Loc, P, B.R, false);
+ }
+
+ if (Toplevel) {
+ for (auto [I, B] : llvm::enumerate(R->virtual_bases())) {
+ PtrView P = BasePtr.atField(B.Offset);
+ if (!P.isInitialized()) {
+ const Descriptor *Desc = BasePtr.getDeclDesc();
+ if (const auto *CD = dyn_cast_if_present<CXXRecordDecl>(R->getDecl())) {
+ const auto &BS = *std::next(CD->bases_begin(), I);
+ SourceLocation TypeBeginLoc = BS.getBaseTypeLoc();
+ S.FFDiag(TypeBeginLoc, diag::note_constexpr_uninitialized_base)
+ << B.Desc->getType() << SourceRange(TypeBeginLoc, BS.getEndLoc());
+ } else {
+ S.FFDiag(Desc->getLocation(), diag::note_constexpr_uninitialized_base)
+ << B.Desc->getType();
+ }
+ return false;
+ }
+
+ Result &= CheckFieldsInitialized(S, Loc, P, B.R, false);
----------------
Sirraide wrote:
Can you factor (some of) this out into a lambda instead of duplicating it from above?
https://github.com/llvm/llvm-project/pull/204289
More information about the cfe-commits
mailing list