[clang] [clang] Add clang::default_constructed_after_move attribute (PR #178432)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 30 08:55:13 PST 2026


halbi2 wrote:

This is a good idea, thank you!
But, does it matter that the moved-from state equate to the default-constructed state? That is true of smart pointers but perhaps that is not true of all types of which `bugprone-use-after-move` would care to be suppressed. What are the risks and benefits of `[[default_constructed_after_move]]` as compared to `[[usable_after_move]]`?

Does `bugprone-use-after-move` already know that a default-constructed `unique_ptr` is null therefore not dereferencable? If yes why does `bugprone-use-after-move` not also know that a moved-from `unique_ptr` is null? If no how would this help `bugprone-use-after-move`?

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


More information about the cfe-commits mailing list