Iterate over StringMaps using structured bindings. NFCI.

This commit is contained in:
Benjamin Kramer 2022-12-04 18:36:41 +01:00
parent 02c75e8465
commit fcf4e360ba
8 changed files with 25 additions and 28 deletions

View File

@ -815,10 +815,8 @@ bool GlobalModuleIndexBuilder::writeIndex(llvm::BitstreamWriter &Stream) {
IdentifierIndexWriterTrait Trait;
// Populate the hash table.
for (InterestingIdentifierMap::iterator I = InterestingIdentifiers.begin(),
IEnd = InterestingIdentifiers.end();
I != IEnd; ++I) {
Generator.insert(I->first(), I->second, Trait);
for (auto &[Identifier, IDs] : InterestingIdentifiers) {
Generator.insert(Identifier, IDs, Trait);
}
// Create the on-disk hash table in a buffer.

View File

@ -405,8 +405,8 @@ public:
/// Sort call targets in descending order of call frequency.
static const SortedCallTargetSet SortCallTargets(const CallTargetMap &Targets) {
SortedCallTargetSet SortedTargets;
for (const auto &I : Targets) {
SortedTargets.emplace(I.first(), I.second);
for (const auto &[Target, Frequency] : Targets) {
SortedTargets.emplace(Target, Frequency);
}
return SortedTargets;
}
@ -415,8 +415,8 @@ public:
static const CallTargetMap adjustCallTargets(const CallTargetMap &Targets,
float DistributionFactor) {
CallTargetMap AdjustedTargets;
for (const auto &I : Targets) {
AdjustedTargets[I.first()] = I.second * DistributionFactor;
for (const auto &[Target, Frequency] : Targets) {
AdjustedTargets[Target] = Frequency * DistributionFactor;
}
return AdjustedTargets;
}

View File

@ -159,9 +159,9 @@ private:
addProfiledFunction(Samples.getFuncName());
for (const auto &Sample : Samples.getBodySamples()) {
for (const auto &Target : Sample.second.getCallTargets()) {
addProfiledFunction(Target.first());
addProfiledCall(Samples.getFuncName(), Target.first(), Target.second);
for (const auto &[Target, Frequency] : Sample.second.getCallTargets()) {
addProfiledFunction(Target);
addProfiledCall(Samples.getFuncName(), Target, Frequency);
}
}

View File

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

View File

@ -1059,8 +1059,8 @@ int SlotTracker::processIndex() {
// assigned consecutively. Since the StringMap iteration order isn't
// guaranteed, use a std::map to order by module ID before assigning slots.
std::map<uint64_t, StringRef> ModuleIdToPathMap;
for (auto &ModPath : TheIndex->modulePaths())
ModuleIdToPathMap[ModPath.second.first] = ModPath.first();
for (auto &[ModPath, ModId] : TheIndex->modulePaths())
ModuleIdToPathMap[ModId.first] = ModPath;
for (auto &ModPair : ModuleIdToPathMap)
CreateModulePathSlot(ModPair.second);
@ -2875,13 +2875,12 @@ void AssemblyWriter::printModuleSummaryIndex() {
std::string RegularLTOModuleName =
ModuleSummaryIndex::getRegularLTOModuleName();
moduleVec.resize(TheIndex->modulePaths().size());
for (auto &ModPath : TheIndex->modulePaths())
moduleVec[Machine.getModulePathSlot(ModPath.first())] = std::make_pair(
for (auto &[ModPath, ModId] : TheIndex->modulePaths())
moduleVec[Machine.getModulePathSlot(ModPath)] = std::make_pair(
// A module id of -1 is a special entry for a regular LTO module created
// during the thin link.
ModPath.second.first == -1u ? RegularLTOModuleName
: (std::string)std::string(ModPath.first()),
ModPath.second.second);
ModId.first == -1u ? RegularLTOModuleName : std::string(ModPath),
ModId.second);
unsigned i = 0;
for (auto &ModPair : moduleVec) {

View File

@ -258,8 +258,8 @@ char *LLVMGetHostCPUFeatures(void) {
StringMap<bool> HostFeatures;
if (sys::getHostCPUFeatures(HostFeatures))
for (auto &F : HostFeatures)
Features.AddFeature(F.first(), F.second);
for (const auto &[Feature, IsEnabled] : HostFeatures)
Features.AddFeature(Feature, IsEnabled);
return strdup(Features.getString().c_str());
}

View File

@ -88,8 +88,8 @@ LogicalResult PatternApplicatorExtension::findAllMatches(
// also used by the following operations.
auto *dialect =
root->getContext()->getLoadedDialect<transform::TransformDialect>();
for (const auto &pair : dialect->getPDLConstraintHooks())
patternModule.registerConstraintFunction(pair.first(), pair.second);
for (const auto &[name, constraintFn] : dialect->getPDLConstraintHooks())
patternModule.registerConstraintFunction(name, constraintFn);
// Register a noop rewriter because PDL requires patterns to end with some
// rewrite call.

View File

@ -145,8 +145,8 @@ bool ExecutionEngine::setupTargetTriple(Module *llvmModule) {
llvm::StringMap<bool> hostFeatures;
if (llvm::sys::getHostCPUFeatures(hostFeatures))
for (auto &f : hostFeatures)
features.AddFeature(f.first(), f.second);
for (const auto &[feature, isEnabled] : hostFeatures)
features.AddFeature(feature, isEnabled);
std::unique_ptr<llvm::TargetMachine> machine(target->createTargetMachine(
targetTriple, cpu, features.getString(), {}, {}));