Skip to content

Commit 62397f8

Browse files
authored
Iterate DenseMaps with auto and structured bindings. NFC (llvm#221869)
Avoid naming `std::pair` directly. The DenseMap bucket is subject to change (llvm#221853).
1 parent 49ce9d0 commit 62397f8

16 files changed

Lines changed: 23 additions & 31 deletions

File tree

clang/lib/Sema/SemaAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ void Sema::ActOnPragmaAttributeAttribute(
10741074
// variable(is_parameter).
10751075
// - a sub-rule and a sibling that's negated. E.g.
10761076
// variable(is_thread_local) and variable(unless(is_parameter))
1077-
llvm::SmallDenseMap<int, std::pair<int, SourceRange>, 2>
1077+
llvm::SmallDenseMap<int, attr::ParsedSubjectMatchRuleSet::value_type, 2>
10781078
RulesToFirstSpecifiedNegatedSubRule;
10791079
for (const auto &Rule : Rules) {
10801080
attr::SubjectMatchRule MatchRule = attr::SubjectMatchRule(Rule.first);

llvm/lib/Bitcode/Reader/MetadataLoader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ void BitcodeReaderMetadataList::tryToResolveCycles() {
241241
return;
242242

243243
// Give up on finding a full definition for any forward decls that remain.
244-
for (const auto &Ref : OldTypeRefs.FwdDecls)
245-
OldTypeRefs.Final.insert(Ref);
244+
for (const auto &[UUID, CT] : OldTypeRefs.FwdDecls)
245+
OldTypeRefs.Final.try_emplace(UUID, CT);
246246
OldTypeRefs.FwdDecls.clear();
247247

248248
// Upgrade from old type ref arrays. In strange cases, this could add to

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,12 @@ class IndexBitcodeWriter : public BitcodeWriterBase {
579579
void forEachSummary(Functor Callback) {
580580
if (ModuleToSummariesForIndex) {
581581
for (auto &M : *ModuleToSummariesForIndex)
582-
for (auto &Summary : M.second) {
583-
Callback(Summary, false);
582+
for (auto &[GUID, GVS] : M.second) {
583+
Callback({GUID, GVS}, false);
584584
// Ensure aliasee is handled, e.g. for assigning a valueId,
585585
// even if we are not importing the aliasee directly (the
586586
// imported alias will contain a copy of aliasee).
587-
if (auto *AS = dyn_cast<AliasSummary>(Summary.getSecond()))
587+
if (auto *AS = dyn_cast<AliasSummary>(GVS))
588588
Callback({AS->getAliaseeGUID(), &AS->getAliasee()}, true);
589589
}
590590
} else {

llvm/lib/CodeGen/RegisterUsageInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ PhysicalRegisterUsageInfo::getRegUsageInfo(const Function &FP) {
7070
}
7171

7272
void PhysicalRegisterUsageInfo::print(raw_ostream &OS, const Module *M) const {
73-
using FuncPtrRegMaskPair = std::pair<const Function *, std::vector<uint32_t>>;
73+
using FuncPtrRegMaskPair = decltype(RegMasks)::value_type;
7474

7575
// Create a vector of pointer to RegMasks entries
7676
SmallVector<const FuncPtrRegMaskPair *, 64> FPRMPairVector(

llvm/lib/CodeGen/StackColoring.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
927927
// Keep a list of allocas which has been affected by the remap.
928928
SmallPtrSet<const AllocaInst*, 32> MergedAllocas;
929929

930-
for (const std::pair<int, int> &SI : SlotRemap) {
930+
for (const auto &SI : SlotRemap) {
931931
const AllocaInst *From = MFI->getObjectAllocation(SI.first);
932932
const AllocaInst *To = MFI->getObjectAllocation(SI.second);
933933
assert(To && From && "Invalid allocation object");

llvm/lib/MC/StringTableBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void StringTableBuilder::write(raw_ostream &OS) const {
6666
OS << Data;
6767
}
6868

69-
using StringPair = std::pair<CachedHashStringRef, size_t>;
69+
using StringPair = DenseMap<CachedHashStringRef, size_t>::value_type;
7070

7171
void StringTableBuilder::write(uint8_t *Buf) const {
7272
assert(isFinalized());

llvm/lib/MCA/HardwareUnits/LSUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ LSUnitBase::LSUnitBase(const MCSchedModel &SM, unsigned LQ, unsigned SQ,
4242
LSUnitBase::~LSUnitBase() = default;
4343

4444
void LSUnit::cycleEvent() {
45-
for (const std::pair<unsigned, std::unique_ptr<MemoryGroup>> &G : Groups)
45+
for (const auto &G : Groups)
4646
G.second->cycleEvent();
4747
}
4848

llvm/lib/MCA/HardwareUnits/ResourceManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ void ResourceManager::fastIssueInstruction(
473473
}
474474

475475
void ResourceManager::cycleEvent(SmallVectorImpl<ResourceRef> &ResourcesFreed) {
476-
for (std::pair<ResourceRef, unsigned> &BR : BusyResources) {
476+
for (auto &BR : BusyResources) {
477477
if (BR.second)
478478
BR.second--;
479479
if (!BR.second) {

llvm/lib/Transforms/IPO/SampleProfile.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,9 +2205,8 @@ bool SampleProfileLoader::runOnModule(Module &M, ModuleAnalysisManager &AM,
22052205

22062206
// Account for cold calls not inlined....
22072207
if (!FunctionSamples::ProfileIsCS)
2208-
for (const std::pair<Function *, NotInlinedProfileInfo> &pair :
2209-
notInlinedCallInfo)
2210-
updateProfileCallee(pair.first, pair.second.entryCount);
2208+
for (const auto &[Fn, Info] : notInlinedCallInfo)
2209+
updateProfileCallee(Fn, Info.entryCount);
22112210

22122211
if (RemoveProbeAfterProfileAnnotation &&
22132212
FunctionSamples::ProfileIsProbeBased) {

llvm/lib/Transforms/Scalar/GVNHoist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ void GVNHoist::findHoistableCandidates(OutValuesType &CHIBBs,
835835

836836
// CHIArgs now have the outgoing values, so check for anticipability and
837837
// accumulate hoistable candidates in HPL.
838-
for (std::pair<BasicBlock *, SmallVector<CHIArg, 2>> &A : CHIBBs) {
838+
for (auto &A : CHIBBs) {
839839
BasicBlock *BB = A.first;
840840
SmallVectorImpl<CHIArg> &CHIs = A.second;
841841
// Vector of PHIs contains PHIs for different instructions.

0 commit comments

Comments
 (0)