[all-commits] [llvm/llvm-project] 159441: Add Clang attribute to ensure that fields are init...

higher-performance via All-commits all-commits at lists.llvm.org
Tue Jan 14 10:31:33 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1594413d5edf6a47d4100cb6a2bc613cfbb92beb
      https://github.com/llvm/llvm-project/commit/1594413d5edf6a47d4100cb6a2bc613cfbb92beb
  Author: higher-performance <higher.performance.github at gmail.com>
  Date:   2025-01-14 (Tue, 14 Jan 2025)

  Changed paths:
    M clang/include/clang/AST/Decl.h
    M clang/include/clang/AST/DeclBase.h
    M clang/include/clang/Basic/Attr.td
    M clang/include/clang/Basic/AttrDocs.td
    M clang/include/clang/Basic/DiagnosticASTKinds.td
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/AST/Decl.cpp
    M clang/lib/AST/DeclCXX.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaInit.cpp
    M clang/lib/Serialization/ASTReaderDecl.cpp
    M clang/lib/Serialization/ASTWriterDecl.cpp
    M clang/test/Misc/pragma-attribute-supported-attributes-list.test
    M clang/test/Sema/uninit-variables.c
    M clang/test/SemaCXX/uninitialized.cpp

  Log Message:
  -----------
  Add Clang attribute to ensure that fields are initialized explicitly (#102040)

This is a new Clang-specific attribute to ensure that field
initializations are performed explicitly.

For example, if we have
```
struct B {
  [[clang::explicit]] int f1;
};
```
then the diagnostic would trigger if we do `B b{};`:
```
field 'f1' is left uninitialized, but was marked as requiring initialization
```

This prevents callers from accidentally forgetting to initialize fields,
particularly when new fields are added to the class.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list