Skip to content

Commit

Permalink
[Sema] Avoid repeated hash lookups (NFC) (llvm#112156)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata authored Oct 14, 2024
1 parent d81c2f1 commit 4459a9b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions clang/lib/Sema/SemaAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,12 +750,10 @@ bool Sema::UnifySection(StringRef SectionName, int SectionFlags,
if (auto A = Decl->getAttr<SectionAttr>())
if (A->isImplicit())
PragmaLocation = A->getLocation();
auto SectionIt = Context.SectionInfos.find(SectionName);
if (SectionIt == Context.SectionInfos.end()) {
Context.SectionInfos[SectionName] =
ASTContext::SectionInfo(Decl, PragmaLocation, SectionFlags);
auto [SectionIt, Inserted] = Context.SectionInfos.try_emplace(
SectionName, Decl, PragmaLocation, SectionFlags);
if (Inserted)
return false;
}
// A pre-declared section takes precedence w/o diagnostic.
const auto &Section = SectionIt->second;
if (Section.SectionFlags == SectionFlags ||
Expand Down

0 comments on commit 4459a9b

Please sign in to comment.