Skip to content

Commit 079f1d9

Browse files
committed
Addressing 5chmidti final suggestions.
1 parent 65079e0 commit 079f1d9

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static FindArgsResult findArgs(const CallExpr *Call) {
7777
}
7878

7979
static SmallVector<FixItHint>
80-
generateReplacement(const MatchFinder::MatchResult &Match,
80+
generateReplacements(const MatchFinder::MatchResult &Match,
8181
const CallExpr *TopCall, const FindArgsResult &Result) {
8282
SmallVector<FixItHint> FixItHints;
8383

@@ -158,12 +158,9 @@ generateReplacement(const MatchFinder::MatchResult &Match,
158158
}
159159

160160
const SmallVector<FixItHint> InnerReplacements =
161-
generateReplacement(Match, InnerCall, InnerResult);
161+
generateReplacements(Match, InnerCall, InnerResult);
162162

163-
FixItHints.insert(FixItHints.end(),
164-
// ignore { and } insertions for the inner call if it does
165-
// not have an initializer list arg
166-
InnerReplacements.begin(), InnerReplacements.end());
163+
FixItHints.append(InnerReplacements);
167164

168165
if (InnerResult.Compare) {
169166
// find the comma after the value arguments
@@ -222,10 +219,10 @@ void MinMaxUseInitializerListCheck::check(
222219
const auto *TopCall = Match.Nodes.getNodeAs<CallExpr>("topCall");
223220

224221
const FindArgsResult Result = findArgs(TopCall);
225-
const SmallVector<FixItHint> Replacement =
226-
generateReplacement(Match, TopCall, Result);
222+
const SmallVector<FixItHint> Replacements =
223+
generateReplacements(Match, TopCall, Result);
227224

228-
if (Replacement.empty())
225+
if (Replacements.empty())
229226
return;
230227

231228
const DiagnosticBuilder Diagnostic =
@@ -248,8 +245,7 @@ void MinMaxUseInitializerListCheck::check(
248245
"}");
249246
}
250247

251-
for (const auto &FixIt : Replacement)
252-
Diagnostic << FixIt;
248+
Diagnostic << Replacements;
253249
}
254250

255251
} // namespace clang::tidy::modernize

0 commit comments

Comments
 (0)