aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2025-11-07 17:17:03 -0800
committerGitHub <noreply@github.com>2025-11-07 17:17:03 -0800
commit77a194cb09e23810e449c4bc6e6be8355d2daf47 (patch)
tree416e1a93b7921fda5df14d35d0fc01fe285c211f /clang/lib/CodeGen/CodeGenModule.cpp
parentbaf41d214349cfa5192ac2295b2ef9db6a68038a (diff)
downloadllvm-77a194cb09e23810e449c4bc6e6be8355d2daf47.zip
llvm-77a194cb09e23810e449c4bc6e6be8355d2daf47.tar.gz
llvm-77a194cb09e23810e449c4bc6e6be8355d2daf47.tar.bz2
[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.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp5
1 files changed, 2 insertions, 3 deletions
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<TransparentUnionAttr>())
return Ty;
- for (const auto *it : UD->fields()) {
- return it->getType();
- }
+ if (!UD->fields().empty())
+ return UD->fields().begin()->getType();
return Ty;
}