[clang] [clang] Add size filter for stack auto init (PR #74777)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 12 17:03:47 PST 2023
================
@@ -1759,20 +1759,29 @@ void CodeGenFunction::emitZeroOrPatternForAutoVarInit(QualType type,
const VarDecl &D,
Address Loc) {
auto trivialAutoVarInit = getContext().getLangOpts().getTrivialAutoVarInit();
+ auto trivialAutoVarInitSizeBound =
+ getContext().getLangOpts().TrivialAutoVarInitSizeBound;
CharUnits Size = getContext().getTypeSizeInChars(type);
bool isVolatile = type.isVolatileQualified();
if (!Size.isZero()) {
+ auto allocSize = CGM.getDataLayout().getTypeAllocSize(Loc.getElementType());
----------------
efriedma-quic wrote:
Ignoring a few less common cases (C++ classes with non-trivial constructors, unions, self-referencing initializers), variable initialization is generally is an all-or-nothing proposition. If you write something like `struct X { int x,y,z; }; struct X x[100] = {0};`, that initializes every field of every element. What examples are you worried about?
https://github.com/llvm/llvm-project/pull/74777
More information about the cfe-commits
mailing list