[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 6 06:20:36 PDT 2024


AaronBallman wrote:

Thank you for this!

> @AaronBallman I think this is worth of an RFC, WDYT?

Yes, this should definitely get an RFC. Some things worth discussing in the RFC:

* Is there a larger design here beyond just fields? e.g., what about local variables?
* Should there be a class-level attribute for cases where you want all fields to be handled the same way?
* Why is the default to assume all fields don't require initialization? Would it make more sense to have a driver flag to opt in to a mode where it's an error to not initialize a field unless it has an attribute saying it's okay to leave it uninitialized?
* Does there need to be a way to silence the diagnostic on a case-by-case basis? e.g., the field should always be initialized explicitly except in one special case that needs to opt out of that behavior

(I'm sure there are other questions, but basically, it's good to have a big-picture understanding of why a particular design is the way you think we should go.)

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


More information about the cfe-commits mailing list