Skip to content

Commit 77a194c

Browse files
authored
[NFC][CodeGen] Replace loop with "if !empty()" (llvm#166515)
The loop iterates once and returns the first element. Replace it with "if !empty()" to make it more explicit. Follow up to llvm#158193.
1 parent baf41d2 commit 77a194c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,9 +2368,8 @@ static QualType GeneralizeTransparentUnion(QualType Ty) {
23682368
const RecordDecl *UD = UT->getDecl()->getDefinitionOrSelf();
23692369
if (!UD->hasAttr<TransparentUnionAttr>())
23702370
return Ty;
2371-
for (const auto *it : UD->fields()) {
2372-
return it->getType();
2373-
}
2371+
if (!UD->fields().empty())
2372+
return UD->fields().begin()->getType();
23742373
return Ty;
23752374
}
23762375

0 commit comments

Comments
 (0)