llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Kazu Hirata (kazutakahirata) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/111228.diff 1 Files Affected: - (modified) clang/lib/Basic/TargetID.cpp (+6-7) ``````````diff diff --git a/clang/lib/Basic/TargetID.cpp b/clang/lib/Basic/TargetID.cpp index fa1bfec2aacb9c..18f649c7137d7d 100644 --- a/clang/lib/Basic/TargetID.cpp +++ b/clang/lib/Basic/TargetID.cpp @@ -92,11 +92,10 @@ parseTargetIDWithFormatCheckingOnly(llvm::StringRef TargetID, if (Sign != '+' && Sign != '-') return std::nullopt; bool IsOn = Sign == '+'; - auto Loc = FeatureMap->find(Feature); + auto [Loc, Inserted] = FeatureMap->try_emplace(Feature, IsOn); // Each feature can only show up at most once in target ID. - if (Loc != FeatureMap->end()) + if (!Inserted) return std::nullopt; - (*FeatureMap)[Feature] = IsOn; Features = Splits.second; } return Processor; @@ -147,15 +146,15 @@ getConflictTargetIDCombination(const std::set<llvm::StringRef> &TargetIDs) { struct Info { llvm::StringRef TargetID; llvm::StringMap<bool> Features; + Info(llvm::StringRef TargetID, const llvm::StringMap<bool> &Features) + : TargetID(TargetID), Features(Features) {} }; llvm::StringMap<Info> FeatureMap; for (auto &&ID : TargetIDs) { llvm::StringMap<bool> Features; llvm::StringRef Proc = *parseTargetIDWithFormatCheckingOnly(ID, &Features); - auto Loc = FeatureMap.find(Proc); - if (Loc == FeatureMap.end()) - FeatureMap[Proc] = Info{ID, Features}; - else { + auto [Loc, Inserted] = FeatureMap.try_emplace(Proc, ID, Features); + if (!Inserted) { auto &ExistingFeatures = Loc->second.Features; if (llvm::any_of(Features, [&](auto &F) { return ExistingFeatures.count(F.first()) == 0; `````````` </details> https://github.com/llvm/llvm-project/pull/111228 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits