[clang] [clang] Implement constexpr heap allocation alignments (PR #174549)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 25 00:22:16 PDT 2026
================
@@ -10569,6 +10663,8 @@ static CharUnits getBaseAlignment(EvalInfo &Info, const LValue &Value) {
return Info.Ctx.getDeclAlign(VD);
if (const auto *E = Value.Base.dyn_cast<const Expr *>())
return GetAlignOfExpr(Info.Ctx, E, UETT_AlignOf);
+ if (const auto &DA = Value.Base.dyn_cast<DynamicAllocLValue>())
+ return Info.Ctx.toCharUnitsFromBits(DA.getAlign());
----------------
keinflue wrote:
I did it this way because it should be possible to query the alignment of the pointer out-of-lifetime of the object when it has already been removed from `HeapAllocs`.
See test case https://github.com/llvm/llvm-project/pull/174549/changes/BASE..2804eed24538abf9d80a7e63486eb0dfe8817e5a#diff-1519e5c27a5702f207d8ce9dd86f8c5cfa9b4ea05e2daefde080cbc3f8b1defcR132-R137.
Not entirely sure that this is required, but I don't see anything that would forbid it.
https://github.com/llvm/llvm-project/pull/174549
More information about the cfe-commits
mailing list