[libcxx-commits] [clang] [libcxx] [clang] Add builtin to clear padding bytes (prework for P0528R3) (PR #75371)

Michael Buch via libcxx-commits libcxx-commits at lists.llvm.org
Tue Apr 28 02:38:33 PDT 2026


================
@@ -2592,6 +2595,281 @@ static RValue EmitHipStdParUnsupportedBuiltin(CodeGenFunction *CGF,
   return RValue::get(CGF->Builder.CreateCall(UBF, Args));
 }
 
+namespace {
+
+// PaddingClearer is a utility class that clears padding bits in a
+// c++ type. It traverses the type recursively, collecting occupied
+// bit intervals, and then compute the padding intervals.
+// In the end, it clears the padding bits by writing zeros
+// to the padding intervals bytes-by-bytes. If a byte only contains
+// some padding bits, it writes zeros to only those bits. This is
+// the case for bit-fields.
+struct PaddingClearer {
----------------
Michael137 wrote:

FWIW, we also do some of this work when figuring out whether padding exists as part of `__has_unique_object_representations`. So that may be also benefit from pulling this out into the RecordLayout. Not something that needs to be done as part of this PR imo but worth keeping track of

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


More information about the libcxx-commits mailing list