[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 07:31:49 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) {
+ const bool IsPedantic = Name == "pedantic";
+ const std::vector<std::string> &SubGroups = Group.SubGroups;
if (!SubGroups.empty() || (IsPedantic && !GroupsInPedantic.empty())) {
- OS << " /* DiagSubGroup" << I.second.IDNo << " */ ";
+ OS << " /* DiagSubGroup" << Group.IDNo << " */ ";
for (auto const &SubGroup : SubGroups) {
- std::map<std::string, GroupInfo>::const_iterator RI =
- DiagsInGroup.find(SubGroup);
+ auto RI = DiagsInGroup.find(SubGroup);
----------------
jurahul wrote:
Is it prohibited? Reading the coding standard, I see:
```
Another time when auto works well for these purposes is when the type would have been abstracted away anyways, often behind a container’s typedef such as std::vector<T>::iterator.
```
I've seen auto used for such iterators all over the place in LLVM codebase.
https://github.com/llvm/llvm-project/pull/115573
More information about the cfe-commits
mailing list