[clang] [libc++] Add builtin to clear padding bytes (prework for P0528R3) (PR #75371)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 26 10:48:48 PST 2024
================
@@ -2456,6 +2461,139 @@ static RValue EmitHipStdParUnsupportedBuiltin(CodeGenFunction *CGF,
return RValue::get(CGF->Builder.CreateCall(UBF, Args));
}
+template <class T>
+void RecursivelyClearPaddingImpl(CodeGenFunction &CGF, Value *Ptr, QualType Ty, size_t CurrentStartOffset, size_t &RunningOffset, T&& WriteZeroAtOffset);
+
+template <class T>
+void ClearPaddingStruct(CodeGenFunction &CGF, Value *Ptr, QualType Ty, StructType *ST,
+ size_t CurrentStartOffset, size_t &RunningOffset, T&& WriteZeroAtOffset) {
+ std::cerr << "\n struct! " << ST->getName().data() << std::endl;
+ auto SL = CGF.CGM.getModule().getDataLayout().getStructLayout(ST);
+
+ auto R = dyn_cast<CXXRecordDecl>(Ty->getAsRecordDecl());
+ if(!R) {
+ std::cerr << "\n not a CXXRecordDecl" << std::endl;
+
+ }
+ const ASTRecordLayout &ASTLayout = CGF.getContext().getASTRecordLayout(R);
+ for (auto Base : R->bases()) {
----------------
efriedma-quic wrote:
Is iterating over bases/fields like this actually guaranteed to return them in order of offset?
Do we need to worry about vtable pointers?
https://github.com/llvm/llvm-project/pull/75371
More information about the cfe-commits
mailing list