[clang] [clang] Add support for `__declspec(no_init_all)` (PR #116847)

Daniel Paoliello via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 19 10:44:20 PST 2024


dpaoliello wrote:

> If we're going to treat `/d1initall` as an alias for `-ftrivial-auto-var-init`, can we just treat `__declspec(no_init_all)` as an alias for `__attribute__((uninitialized))`?

`uninitialized` currently only applied to local variable declarations, whereas `__declspec(no_init_all)` is for types and functions.

I think allowing `uninitialized` to be applied to types and functions would be confusing:
* Does `uninitialized` on a non-trivial type suppress the normal automatic initialization? If not, then does this need a warning/error?
* How is a user supposed to interpret `uninitialized` on a function? There's no obvious connection that it's referring to the local variables in the function, let alone those that are not automatically initialized.

This is why I wanted to avoid adding a Clang spelling: it feels like it would need a bunch of naming discussions and design work.



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


More information about the cfe-commits mailing list