aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ASTReaderDecl.cpp
diff options
context:
space:
mode:
authorhigher-performance <higher.performance.github@gmail.com>2025-01-14 13:31:12 -0500
committerGitHub <noreply@github.com>2025-01-14 13:31:12 -0500
commit1594413d5edf6a47d4100cb6a2bc613cfbb92beb (patch)
treefc9743f336e09c4e40794ca00570b403ee73f718 /clang/lib/Serialization/ASTReaderDecl.cpp
parent576b53801fc3d721602ae0d8377af9950f356000 (diff)
downloadllvm-1594413d5edf6a47d4100cb6a2bc613cfbb92beb.zip
llvm-1594413d5edf6a47d4100cb6a2bc613cfbb92beb.tar.gz
llvm-1594413d5edf6a47d4100cb6a2bc613cfbb92beb.tar.bz2
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.
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index ee72dd8..95abd75 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -832,6 +832,7 @@ RedeclarableResult ASTDeclReader::VisitRecordDeclImpl(RecordDecl *RD) {
RecordDeclBits.getNextBit());
RD->setHasNonTrivialToPrimitiveDestructCUnion(RecordDeclBits.getNextBit());
RD->setHasNonTrivialToPrimitiveCopyCUnion(RecordDeclBits.getNextBit());
+ RD->setHasUninitializedExplicitInitFields(RecordDeclBits.getNextBit());
RD->setParamDestroyedInCallee(RecordDeclBits.getNextBit());
RD->setArgPassingRestrictions(
(RecordArgPassingKind)RecordDeclBits.getNextBits(/*Width=*/2));