Skip to content

Commit 9c19701

Browse files
Linting
1 parent 47c244a commit 9c19701

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

clang/lib/AST/DeclCXX.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,9 +1118,8 @@ void CXXRecordDecl::addedMember(Decl *D) {
11181118
} else if (!T.isCXX98PODType(Context))
11191119
data().PlainOldData = false;
11201120

1121-
if (Field->hasAttr<ExplicitInitAttr>() && !Field->hasInClassInitializer()) {
1121+
if (Field->hasAttr<ExplicitInitAttr>() && !Field->hasInClassInitializer())
11221122
setHasUninitializedExplicitInitFields(true);
1123-
}
11241123

11251124
if (T->isReferenceType()) {
11261125
if (!Field->hasInClassInitializer())
@@ -2202,26 +2201,24 @@ void CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) {
22022201
if (isAggregate() && hasUserDeclaredConstructor() &&
22032202
!Context.getLangOpts().CPlusPlus20) {
22042203
// Diagnose any aggregate behavior changes in C++20
2205-
for (field_iterator I = field_begin(), E = field_end(); I != E; ++I) {
2206-
if (const auto *attr = I->getAttr<ExplicitInitAttr>()) {
2204+
for (const FieldDecl *FD : RD->fields()) {
2205+
if (const auto *AT = FD->getAttr<ExplicitInitAttr>())
22072206
Context.getDiagnostics().Report(
2208-
attr->getLocation(),
2207+
AT->getLocation(),
22092208
diag::warn_cxx20_compat_requires_explicit_init_non_aggregate)
2210-
<< attr << Context.getRecordType(this);
2211-
}
2209+
<< AT << Context.getRecordType(this);
22122210
}
22132211
}
22142212

22152213
if (!isAggregate() && hasUninitializedExplicitInitFields()) {
22162214
// Diagnose any fields that required explicit initialization in a
22172215
// non-aggregate type. (Note that the fields may not be directly in this
22182216
// type, but in a subobject. In such cases we don't emit diagnoses here.)
2219-
for (field_iterator I = field_begin(), E = field_end(); I != E; ++I) {
2220-
if (const auto *attr = I->getAttr<ExplicitInitAttr>()) {
2221-
Context.getDiagnostics().Report(attr->getLocation(),
2217+
for (const FieldDecl *FD : RD->fields()) {
2218+
if (const auto *AT = FD->getAttr<ExplicitInitAttr>())
2219+
Context.getDiagnostics().Report(AT->getLocation(),
22222220
diag::warn_attribute_needs_aggregate)
2223-
<< attr << Context.getRecordType(this);
2224-
}
2221+
<< AT << Context.getRecordType(this);
22252222
}
22262223
setHasUninitializedExplicitInitFields(false);
22272224
}

clang/lib/Sema/SemaDecl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19189,9 +19189,8 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl,
1918919189
if (FT.hasNonTrivialToPrimitiveCopyCUnion() || Record->isUnion())
1919019190
Record->setHasNonTrivialToPrimitiveCopyCUnion(true);
1919119191
}
19192-
if (FD->hasAttr<ExplicitInitAttr>()) {
19192+
if (FD->hasAttr<ExplicitInitAttr>())
1919319193
Record->setHasUninitializedExplicitInitFields(true);
19194-
}
1919519194
if (FT.isDestructedType()) {
1919619195
Record->setNonTrivialToPrimitiveDestroy(true);
1919719196
Record->setParamDestroyedInCallee(true);

clang/lib/Sema/SemaInit.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,8 @@ static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT,
266266

267267
void emitUninitializedExplicitInitFields(Sema &S, const RecordDecl *R) {
268268
for (const FieldDecl *Field : R->fields()) {
269-
if (Field->hasAttr<ExplicitInitAttr>()) {
269+
if (Field->hasAttr<ExplicitInitAttr>())
270270
S.Diag(Field->getLocation(), diag::note_entity_declared_at) << Field;
271-
}
272271
}
273272
}
274273

0 commit comments

Comments
 (0)