From 77a194cb09e23810e449c4bc6e6be8355d2daf47 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Fri, 7 Nov 2025 17:17:03 -0800 Subject: [NFC][CodeGen] Replace loop with "if !empty()" (#166515) The loop iterates once and returns the first element. Replace it with "if !empty()" to make it more explicit. Follow up to https://github.com/llvm/llvm-project/pull/158193. --- clang/lib/CodeGen/CodeGenModule.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 0fea57b..98d59b7 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2368,9 +2368,8 @@ static QualType GeneralizeTransparentUnion(QualType Ty) { const RecordDecl *UD = UT->getDecl()->getDefinitionOrSelf(); if (!UD->hasAttr()) return Ty; - for (const auto *it : UD->fields()) { - return it->getType(); - } + if (!UD->fields().empty()) + return UD->fields().begin()->getType(); return Ty; } -- cgit v1.1