Skip to content

Commit fcf4e36

Browse files
committed
Iterate over StringMaps using structured bindings. NFCI.
1 parent 02c75e8 commit fcf4e36

File tree

8 files changed

+25
-28
lines changed

8 files changed

+25
-28
lines changed

clang/lib/Serialization/GlobalModuleIndex.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -815,10 +815,8 @@ bool GlobalModuleIndexBuilder::writeIndex(llvm::BitstreamWriter &Stream) {
815815
IdentifierIndexWriterTrait Trait;
816816

817817
// Populate the hash table.
818-
for (InterestingIdentifierMap::iterator I = InterestingIdentifiers.begin(),
819-
IEnd = InterestingIdentifiers.end();
820-
I != IEnd; ++I) {
821-
Generator.insert(I->first(), I->second, Trait);
818+
for (auto &[Identifier, IDs] : InterestingIdentifiers) {
819+
Generator.insert(Identifier, IDs, Trait);
822820
}
823821

824822
// Create the on-disk hash table in a buffer.

llvm/include/llvm/ProfileData/SampleProf.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,8 @@ class SampleRecord {
405405
/// Sort call targets in descending order of call frequency.
406406
static const SortedCallTargetSet SortCallTargets(const CallTargetMap &Targets) {
407407
SortedCallTargetSet SortedTargets;
408-
for (const auto &I : Targets) {
409-
SortedTargets.emplace(I.first(), I.second);
408+
for (const auto &[Target, Frequency] : Targets) {
409+
SortedTargets.emplace(Target, Frequency);
410410
}
411411
return SortedTargets;
412412
}
@@ -415,8 +415,8 @@ class SampleRecord {
415415
static const CallTargetMap adjustCallTargets(const CallTargetMap &Targets,
416416
float DistributionFactor) {
417417
CallTargetMap AdjustedTargets;
418-
for (const auto &I : Targets) {
419-
AdjustedTargets[I.first()] = I.second * DistributionFactor;
418+
for (const auto &[Target, Frequency] : Targets) {
419+
AdjustedTargets[Target] = Frequency * DistributionFactor;
420420
}
421421
return AdjustedTargets;
422422
}

llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ class ProfiledCallGraph {
159159
addProfiledFunction(Samples.getFuncName());
160160

161161
for (const auto &Sample : Samples.getBodySamples()) {
162-
for (const auto &Target : Sample.second.getCallTargets()) {
163-
addProfiledFunction(Target.first());
164-
addProfiledCall(Samples.getFuncName(), Target.first(), Target.second);
162+
for (const auto &[Target, Frequency] : Sample.second.getCallTargets()) {
163+
addProfiledFunction(Target);
164+
addProfiledCall(Samples.getFuncName(), Target, Frequency);
165165
}
166166
}
167167

llvm/lib/CodeGen/CommandFlags.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,8 @@ std::string codegen::getFeaturesStr() {
592592
if (getMCPU() == "native") {
593593
StringMap<bool> HostFeatures;
594594
if (sys::getHostCPUFeatures(HostFeatures))
595-
for (auto &F : HostFeatures)
596-
Features.AddFeature(F.first(), F.second);
595+
for (const auto &[Feature, IsEnabled] : HostFeatures)
596+
Features.AddFeature(Feature, IsEnabled);
597597
}
598598

599599
for (auto const &MAttr : getMAttrs())
@@ -612,8 +612,8 @@ std::vector<std::string> codegen::getFeatureList() {
612612
if (getMCPU() == "native") {
613613
StringMap<bool> HostFeatures;
614614
if (sys::getHostCPUFeatures(HostFeatures))
615-
for (auto &F : HostFeatures)
616-
Features.AddFeature(F.first(), F.second);
615+
for (const auto &[Feature, IsEnabled] : HostFeatures)
616+
Features.AddFeature(Feature, IsEnabled);
617617
}
618618

619619
for (auto const &MAttr : getMAttrs())

llvm/lib/IR/AsmWriter.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,8 +1059,8 @@ int SlotTracker::processIndex() {
10591059
// assigned consecutively. Since the StringMap iteration order isn't
10601060
// guaranteed, use a std::map to order by module ID before assigning slots.
10611061
std::map<uint64_t, StringRef> ModuleIdToPathMap;
1062-
for (auto &ModPath : TheIndex->modulePaths())
1063-
ModuleIdToPathMap[ModPath.second.first] = ModPath.first();
1062+
for (auto &[ModPath, ModId] : TheIndex->modulePaths())
1063+
ModuleIdToPathMap[ModId.first] = ModPath;
10641064
for (auto &ModPair : ModuleIdToPathMap)
10651065
CreateModulePathSlot(ModPair.second);
10661066

@@ -2875,13 +2875,12 @@ void AssemblyWriter::printModuleSummaryIndex() {
28752875
std::string RegularLTOModuleName =
28762876
ModuleSummaryIndex::getRegularLTOModuleName();
28772877
moduleVec.resize(TheIndex->modulePaths().size());
2878-
for (auto &ModPath : TheIndex->modulePaths())
2879-
moduleVec[Machine.getModulePathSlot(ModPath.first())] = std::make_pair(
2878+
for (auto &[ModPath, ModId] : TheIndex->modulePaths())
2879+
moduleVec[Machine.getModulePathSlot(ModPath)] = std::make_pair(
28802880
// A module id of -1 is a special entry for a regular LTO module created
28812881
// during the thin link.
2882-
ModPath.second.first == -1u ? RegularLTOModuleName
2883-
: (std::string)std::string(ModPath.first()),
2884-
ModPath.second.second);
2882+
ModId.first == -1u ? RegularLTOModuleName : std::string(ModPath),
2883+
ModId.second);
28852884

28862885
unsigned i = 0;
28872886
for (auto &ModPair : moduleVec) {

llvm/lib/Target/TargetMachineC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ char *LLVMGetHostCPUFeatures(void) {
258258
StringMap<bool> HostFeatures;
259259

260260
if (sys::getHostCPUFeatures(HostFeatures))
261-
for (auto &F : HostFeatures)
262-
Features.AddFeature(F.first(), F.second);
261+
for (const auto &[Feature, IsEnabled] : HostFeatures)
262+
Features.AddFeature(Feature, IsEnabled);
263263

264264
return strdup(Features.getString().c_str());
265265
}

mlir/lib/Dialect/Transform/IR/TransformOps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ LogicalResult PatternApplicatorExtension::findAllMatches(
8888
// also used by the following operations.
8989
auto *dialect =
9090
root->getContext()->getLoadedDialect<transform::TransformDialect>();
91-
for (const auto &pair : dialect->getPDLConstraintHooks())
92-
patternModule.registerConstraintFunction(pair.first(), pair.second);
91+
for (const auto &[name, constraintFn] : dialect->getPDLConstraintHooks())
92+
patternModule.registerConstraintFunction(name, constraintFn);
9393

9494
// Register a noop rewriter because PDL requires patterns to end with some
9595
// rewrite call.

mlir/lib/ExecutionEngine/ExecutionEngine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ bool ExecutionEngine::setupTargetTriple(Module *llvmModule) {
145145
llvm::StringMap<bool> hostFeatures;
146146

147147
if (llvm::sys::getHostCPUFeatures(hostFeatures))
148-
for (auto &f : hostFeatures)
149-
features.AddFeature(f.first(), f.second);
148+
for (const auto &[feature, isEnabled] : hostFeatures)
149+
features.AddFeature(feature, isEnabled);
150150

151151
std::unique_ptr<llvm::TargetMachine> machine(target->createTargetMachine(
152152
targetTriple, cpu, features.getString(), {}, {}));

0 commit comments

Comments
 (0)