Skip to content

Commit c50f924

Browse files
[Sema] Avoid repeated hash lookups (NFC) (#126674)
1 parent 8e4e144 commit c50f924

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5078,7 +5078,8 @@ static bool checkIfClauses(Sema &S, OpenMPDirectiveKind Kind,
50785078
// At most one if clause without a directive-name-modifier can appear on
50795079
// the directive.
50805080
OpenMPDirectiveKind CurNM = IC->getNameModifier();
5081-
if (FoundNameModifiers[CurNM]) {
5081+
auto &FNM = FoundNameModifiers[CurNM];
5082+
if (FNM) {
50825083
S.Diag(C->getBeginLoc(), diag::err_omp_more_one_clause)
50835084
<< getOpenMPDirectiveName(Kind) << getOpenMPClauseName(OMPC_if)
50845085
<< (CurNM != OMPD_unknown) << getOpenMPDirectiveName(CurNM);
@@ -5087,7 +5088,7 @@ static bool checkIfClauses(Sema &S, OpenMPDirectiveKind Kind,
50875088
NameModifierLoc.push_back(IC->getNameModifierLoc());
50885089
++NamedModifiersNumber;
50895090
}
5090-
FoundNameModifiers[CurNM] = IC;
5091+
FNM = IC;
50915092
if (CurNM == OMPD_unknown)
50925093
continue;
50935094
// Check if the specified name modifier is allowed for the current
@@ -6759,16 +6760,15 @@ SemaOpenMP::DeclGroupPtrTy SemaOpenMP::ActOnOpenMPDeclareSimdDirective(
67596760
->getCanonicalDecl() == CanonPVD) {
67606761
// OpenMP [2.8.1, simd construct, Restrictions]
67616762
// A list-item cannot appear in more than one aligned clause.
6762-
if (AlignedArgs.count(CanonPVD) > 0) {
6763+
auto [It, Inserted] = AlignedArgs.try_emplace(CanonPVD, E);
6764+
if (!Inserted) {
67636765
Diag(E->getExprLoc(), diag::err_omp_used_in_clause_twice)
67646766
<< 1 << getOpenMPClauseName(OMPC_aligned)
67656767
<< E->getSourceRange();
6766-
Diag(AlignedArgs[CanonPVD]->getExprLoc(),
6767-
diag::note_omp_explicit_dsa)
6768+
Diag(It->second->getExprLoc(), diag::note_omp_explicit_dsa)
67686769
<< getOpenMPClauseName(OMPC_aligned);
67696770
continue;
67706771
}
6771-
AlignedArgs[CanonPVD] = E;
67726772
QualType QTy = PVD->getType()
67736773
.getNonReferenceType()
67746774
.getUnqualifiedType()

0 commit comments

Comments
 (0)