[clang] [NFC][Clang] Use range for loops in ClangDiagnosticsEmitter (PR #115573)
Rahul Joshi via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 12 08:14:41 PST 2024
================
@@ -1553,15 +1526,13 @@ static void emitDiagSubGroups(std::map<std::string, GroupInfo> &DiagsInGroup,
RecordVec &GroupsInPedantic, raw_ostream &OS) {
OS << "static const int16_t DiagSubGroups[] = {\n"
<< " /* Empty */ -1,\n";
- for (auto const &I : DiagsInGroup) {
- const bool IsPedantic = I.first == "pedantic";
-
- const std::vector<std::string> &SubGroups = I.second.SubGroups;
+ for (auto const &[Name, Group] : DiagsInGroup) {
----------------
jurahul wrote:
If I remove the &, I get:
>warning: loop variable '[Name, Group]' creates a copy from type 'std::pair<const std::basic_string<char>, (anonymous > namespace)::GroupInfo> const' [-Wrange-loop-construct
So the & here seems required to prevent copies.
https://github.com/llvm/llvm-project/pull/115573
More information about the cfe-commits
mailing list