Skip to content

Commit 230df4f

Browse files
committed
[NFC] IIFE
1 parent 09f7bcd commit 230df4f

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -339,21 +339,18 @@ void UseStructuredBindingCheck::check(const MatchFinder::MatchResult &Result) {
339339
auto DiagAndFix = [&BeginDS, &EndDS, &FirstVar, &SecondVar, &CFRS,
340340
this](SourceLocation DiagLoc, SourceRange ReplaceRange,
341341
TransferType TT = TT_ByVal) {
342-
StringRef Prefix;
343-
switch (TT) {
344-
case TT_ByVal:
345-
Prefix = "auto";
346-
break;
347-
case TT_ByConstVal:
348-
Prefix = "const auto";
349-
break;
350-
case TT_ByRef:
351-
Prefix = "auto&";
352-
break;
353-
case TT_ByConstRef:
354-
Prefix = "const auto&";
355-
break;
356-
}
342+
const auto Prefix = [&TT]() -> StringRef {
343+
switch (TT) {
344+
case TT_ByVal:
345+
return "auto";
346+
case TT_ByConstVal:
347+
return "const auto";
348+
case TT_ByRef:
349+
return "auto&";
350+
case TT_ByConstRef:
351+
return "const auto&";
352+
}
353+
}();
357354

358355
std::string ReplacementText =
359356
(Twine(Prefix) + " [" + FirstVar->getNameAsString() + ", " +

0 commit comments

Comments
 (0)