Skip to content

Commit 5996496

Browse files
committed
[clang][NFC] Use foreach loop in FinalizeDeclaratorGroup
1 parent d563c0f commit 5996496

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14911,53 +14911,53 @@ Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
1491114911
DeclaratorDecl *FirstNonDeducedAutoInGroup = nullptr;
1491214912
bool DiagnosedNonDeducedAuto = false;
1491314913

14914-
for (unsigned i = 0, e = Group.size(); i != e; ++i) {
14915-
if (Decl *D = Group[i]) {
14916-
// Check if the Decl has been declared in '#pragma omp declare target'
14917-
// directive and has static storage duration.
14918-
if (auto *VD = dyn_cast<VarDecl>(D);
14919-
LangOpts.OpenMP && VD && VD->hasAttr<OMPDeclareTargetDeclAttr>() &&
14920-
VD->hasGlobalStorage())
14921-
OpenMP().ActOnOpenMPDeclareTargetInitializer(D);
14922-
// For declarators, there are some additional syntactic-ish checks we need
14923-
// to perform.
14924-
if (auto *DD = dyn_cast<DeclaratorDecl>(D)) {
14925-
if (!FirstDeclaratorInGroup)
14926-
FirstDeclaratorInGroup = DD;
14927-
if (!FirstDecompDeclaratorInGroup)
14928-
FirstDecompDeclaratorInGroup = dyn_cast<DecompositionDecl>(D);
14929-
if (!FirstNonDeducedAutoInGroup && DS.hasAutoTypeSpec() &&
14930-
!hasDeducedAuto(DD))
14931-
FirstNonDeducedAutoInGroup = DD;
14932-
14933-
if (FirstDeclaratorInGroup != DD) {
14934-
// A decomposition declaration cannot be combined with any other
14935-
// declaration in the same group.
14936-
if (FirstDecompDeclaratorInGroup && !DiagnosedMultipleDecomps) {
14937-
Diag(FirstDecompDeclaratorInGroup->getLocation(),
14938-
diag::err_decomp_decl_not_alone)
14939-
<< FirstDeclaratorInGroup->getSourceRange()
14940-
<< DD->getSourceRange();
14941-
DiagnosedMultipleDecomps = true;
14942-
}
14914+
for (Decl *D : Group) {
14915+
if (!D)
14916+
continue;
14917+
// Check if the Decl has been declared in '#pragma omp declare target'
14918+
// directive and has static storage duration.
14919+
if (auto *VD = dyn_cast<VarDecl>(D);
14920+
LangOpts.OpenMP && VD && VD->hasAttr<OMPDeclareTargetDeclAttr>() &&
14921+
VD->hasGlobalStorage())
14922+
OpenMP().ActOnOpenMPDeclareTargetInitializer(D);
14923+
// For declarators, there are some additional syntactic-ish checks we need
14924+
// to perform.
14925+
if (auto *DD = dyn_cast<DeclaratorDecl>(D)) {
14926+
if (!FirstDeclaratorInGroup)
14927+
FirstDeclaratorInGroup = DD;
14928+
if (!FirstDecompDeclaratorInGroup)
14929+
FirstDecompDeclaratorInGroup = dyn_cast<DecompositionDecl>(D);
14930+
if (!FirstNonDeducedAutoInGroup && DS.hasAutoTypeSpec() &&
14931+
!hasDeducedAuto(DD))
14932+
FirstNonDeducedAutoInGroup = DD;
14933+
14934+
if (FirstDeclaratorInGroup != DD) {
14935+
// A decomposition declaration cannot be combined with any other
14936+
// declaration in the same group.
14937+
if (FirstDecompDeclaratorInGroup && !DiagnosedMultipleDecomps) {
14938+
Diag(FirstDecompDeclaratorInGroup->getLocation(),
14939+
diag::err_decomp_decl_not_alone)
14940+
<< FirstDeclaratorInGroup->getSourceRange()
14941+
<< DD->getSourceRange();
14942+
DiagnosedMultipleDecomps = true;
14943+
}
1494314944

14944-
// A declarator that uses 'auto' in any way other than to declare a
14945-
// variable with a deduced type cannot be combined with any other
14946-
// declarator in the same group.
14947-
if (FirstNonDeducedAutoInGroup && !DiagnosedNonDeducedAuto) {
14948-
Diag(FirstNonDeducedAutoInGroup->getLocation(),
14949-
diag::err_auto_non_deduced_not_alone)
14950-
<< FirstNonDeducedAutoInGroup->getType()
14951-
->hasAutoForTrailingReturnType()
14952-
<< FirstDeclaratorInGroup->getSourceRange()
14953-
<< DD->getSourceRange();
14954-
DiagnosedNonDeducedAuto = true;
14955-
}
14945+
// A declarator that uses 'auto' in any way other than to declare a
14946+
// variable with a deduced type cannot be combined with any other
14947+
// declarator in the same group.
14948+
if (FirstNonDeducedAutoInGroup && !DiagnosedNonDeducedAuto) {
14949+
Diag(FirstNonDeducedAutoInGroup->getLocation(),
14950+
diag::err_auto_non_deduced_not_alone)
14951+
<< FirstNonDeducedAutoInGroup->getType()
14952+
->hasAutoForTrailingReturnType()
14953+
<< FirstDeclaratorInGroup->getSourceRange()
14954+
<< DD->getSourceRange();
14955+
DiagnosedNonDeducedAuto = true;
1495614956
}
1495714957
}
14958-
14959-
Decls.push_back(D);
1496014958
}
14959+
14960+
Decls.push_back(D);
1496114961
}
1496214962

1496314963
if (DeclSpec::isDeclRep(DS.getTypeSpecType())) {

0 commit comments

Comments
 (0)