Skip to content

Commit e69deb2

Browse files
authored
[clang-tidy][NFC] Migrate away from make_* functions (llvm#173191)
These seem to always have a better alternative (CTAD, braced init-list, etc.)
1 parent e644f06 commit e69deb2

13 files changed

+33
-36
lines changed

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class ErrorReporter {
176176
++AppliedFixes;
177177
}
178178
FixLoc = getLocation(FixAbsoluteFilePath, Repl.getOffset());
179-
FixLocations.push_back(std::make_pair(FixLoc, CanBeApplied));
179+
FixLocations.emplace_back(FixLoc, CanBeApplied);
180180
Entry.BuildDir = Error.BuildDirectory;
181181
}
182182
}

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,13 @@ void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
659659
// disallowing the first one.
660660
switch (Type) {
661661
case ET_Begin:
662-
Priority = std::make_tuple(Begin, Type, -End, -ErrorSize, ErrorId);
662+
Priority = {Begin, Type, -End, -ErrorSize, ErrorId};
663663
break;
664664
case ET_Insert:
665-
Priority = std::make_tuple(Begin, Type, -End, ErrorSize, ErrorId);
665+
Priority = {Begin, Type, -End, ErrorSize, ErrorId};
666666
break;
667667
case ET_End:
668-
Priority = std::make_tuple(End, Type, -Begin, ErrorSize, ErrorId);
668+
Priority = {End, Type, -Begin, ErrorSize, ErrorId};
669669
break;
670670
}
671671
}

clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,40 +51,40 @@ getNewScaleSingleStep(DurationScale OldScale, double Multiplier) {
5151
switch (OldScale) {
5252
case DurationScale::Hours:
5353
if (Multiplier <= 1.0 / 60.0)
54-
return std::make_tuple(DurationScale::Minutes, Multiplier * 60.0);
54+
return {{DurationScale::Minutes, Multiplier * 60.0}};
5555
break;
5656

5757
case DurationScale::Minutes:
5858
if (Multiplier >= 60.0)
59-
return std::make_tuple(DurationScale::Hours, Multiplier / 60.0);
59+
return {{DurationScale::Hours, Multiplier / 60.0}};
6060
if (Multiplier <= 1.0 / 60.0)
61-
return std::make_tuple(DurationScale::Seconds, Multiplier * 60.0);
61+
return {{DurationScale::Seconds, Multiplier * 60.0}};
6262
break;
6363

6464
case DurationScale::Seconds:
6565
if (Multiplier >= 60.0)
66-
return std::make_tuple(DurationScale::Minutes, Multiplier / 60.0);
66+
return {{DurationScale::Minutes, Multiplier / 60.0}};
6767
if (Multiplier <= 1e-3)
68-
return std::make_tuple(DurationScale::Milliseconds, Multiplier * 1e3);
68+
return {{DurationScale::Milliseconds, Multiplier * 1e3}};
6969
break;
7070

7171
case DurationScale::Milliseconds:
7272
if (Multiplier >= 1e3)
73-
return std::make_tuple(DurationScale::Seconds, Multiplier / 1e3);
73+
return {{DurationScale::Seconds, Multiplier / 1e3}};
7474
if (Multiplier <= 1e-3)
75-
return std::make_tuple(DurationScale::Microseconds, Multiplier * 1e3);
75+
return {{DurationScale::Microseconds, Multiplier * 1e3}};
7676
break;
7777

7878
case DurationScale::Microseconds:
7979
if (Multiplier >= 1e3)
80-
return std::make_tuple(DurationScale::Milliseconds, Multiplier / 1e3);
80+
return {{DurationScale::Milliseconds, Multiplier / 1e3}};
8181
if (Multiplier <= 1e-3)
82-
return std::make_tuple(DurationScale::Nanoseconds, Multiplier * 1e-3);
82+
return {{DurationScale::Nanoseconds, Multiplier * 1e-3}};
8383
break;
8484

8585
case DurationScale::Nanoseconds:
8686
if (Multiplier >= 1e3)
87-
return std::make_tuple(DurationScale::Microseconds, Multiplier / 1e3);
87+
return {{DurationScale::Microseconds, Multiplier / 1e3}};
8888
break;
8989
}
9090

clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ bool VirtualNearMissCheck::isPossibleToBeOverridden(
192192

193193
bool VirtualNearMissCheck::isOverriddenByDerivedClass(
194194
const CXXMethodDecl *BaseMD, const CXXRecordDecl *DerivedRD) {
195-
auto Key = std::make_pair(BaseMD, DerivedRD);
195+
const std::pair Key(BaseMD, DerivedRD);
196196
auto Iter = OverriddenMap.find(Key);
197197
if (Iter != OverriddenMap.end())
198198
return Iter->second;

clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static std::pair<std::size_t, bool> countCaseLabels(const SwitchStmt *Switch) {
6060
CurrentCase = CurrentCase->getNextSwitchCase();
6161
}
6262

63-
return std::make_pair(CaseCount, HasDefault);
63+
return {CaseCount, HasDefault};
6464
}
6565

6666
/// This function calculate 2 ** Bits and returns

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ getContainerFromBeginEndCall(const Expr *Init, bool IsBegin, bool *IsArrow,
424424
return {};
425425
if (!Call->Name.empty() && Call->Name != "c")
426426
return {};
427-
return std::make_pair(Call->Container, Call->CallKind);
427+
return {Call->Container, Call->CallKind};
428428
}
429429

430430
/// Determines the container whose begin() and end() functions are called
@@ -734,7 +734,7 @@ void LoopConvertCheck::doConversion(
734734
? "&" + VarNameOrStructuredBinding
735735
: VarNameOrStructuredBinding;
736736
}
737-
TUInfo->getReplacedVars().insert(std::make_pair(Loop, IndexVar));
737+
TUInfo->getReplacedVars().try_emplace(Loop, IndexVar);
738738
FixIts.push_back(FixItHint::CreateReplacement(
739739
CharSourceRange::getTokenRange(Range), ReplaceText));
740740
}
@@ -796,8 +796,7 @@ void LoopConvertCheck::doConversion(
796796
FixIts.push_back(*Insertion);
797797
}
798798
diag(Loop->getForLoc(), "use range-based for loop instead") << FixIts;
799-
TUInfo->getGeneratedDecls().insert(
800-
make_pair(Loop, VarNameOrStructuredBinding));
799+
TUInfo->getGeneratedDecls().try_emplace(Loop, VarNameOrStructuredBinding);
801800
}
802801

803802
/// Returns a string which refers to the container iterated over.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace clang::tidy::modernize {
3535
/// the stack is the parent of the current statement (NULL for the topmost
3636
/// statement).
3737
bool StmtAncestorASTVisitor::TraverseStmt(Stmt *Statement) {
38-
StmtAncestors.insert(std::make_pair(Statement, StmtStack.back()));
38+
StmtAncestors.try_emplace(Statement, StmtStack.back());
3939
StmtStack.push_back(Statement);
4040
RecursiveASTVisitor<StmtAncestorASTVisitor>::TraverseStmt(Statement);
4141
StmtStack.pop_back();
@@ -50,7 +50,7 @@ bool StmtAncestorASTVisitor::TraverseStmt(Stmt *Statement) {
5050
bool StmtAncestorASTVisitor::VisitDeclStmt(DeclStmt *Statement) {
5151
for (const auto *Decl : Statement->decls())
5252
if (const auto *V = dyn_cast<VarDecl>(Decl))
53-
DeclParents.insert(std::make_pair(V, Statement));
53+
DeclParents.try_emplace(V, Statement);
5454
return true;
5555
}
5656

@@ -469,7 +469,7 @@ void ForLoopIndexUseVisitor::addComponent(const Expr *E) {
469469
llvm::FoldingSetNodeID ID;
470470
const Expr *Node = E->IgnoreParenImpCasts();
471471
Node->Profile(ID, *Context, true);
472-
DependentExprs.push_back(std::make_pair(Node, ID));
472+
DependentExprs.emplace_back(Node, ID);
473473
}
474474

475475
void ForLoopIndexUseVisitor::addUsage(const Usage &U) {

clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ struct CognitiveComplexity final {
118118
} else
119119
llvm_unreachable("should not get to here.");
120120

121-
return std::make_pair(MsgId, Increment);
121+
return {MsgId, Increment};
122122
}
123123
};
124124

clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void NamedParameterCheck::check(const MatchFinder::MatchResult &Result) {
8383
if (Data.contains("/*"))
8484
continue;
8585

86-
UnnamedParams.push_back(std::make_pair(Function, I));
86+
UnnamedParams.emplace_back(Function, I);
8787
}
8888

8989
// Emit only one warning per function but fixits for all unnamed parameters.

clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -521,17 +521,15 @@ SuspiciousCallArgumentCheck::SuspiciousCallArgumentCheck(
521521
auto H = static_cast<Heuristic>(Idx);
522522
if (GetToggleOpt(H))
523523
AppliedHeuristics.emplace_back(H);
524-
ConfiguredBounds.emplace_back(
525-
std::make_pair(GetBoundOpt(H, BoundKind::DissimilarBelow),
526-
GetBoundOpt(H, BoundKind::SimilarAbove)));
524+
ConfiguredBounds.emplace_back(GetBoundOpt(H, BoundKind::DissimilarBelow),
525+
GetBoundOpt(H, BoundKind::SimilarAbove));
527526
}
528527

529528
for (const StringRef Abbreviation : optutils::parseStringList(
530529
Options.get("Abbreviations", DefaultAbbreviations))) {
531-
auto KeyAndValue = Abbreviation.split("=");
532-
assert(!KeyAndValue.first.empty() && !KeyAndValue.second.empty());
533-
AbbreviationDictionary.insert(
534-
std::make_pair(KeyAndValue.first, KeyAndValue.second.str()));
530+
const auto [Key, Value] = Abbreviation.split("=");
531+
assert(!Key.empty() && !Value.empty());
532+
AbbreviationDictionary.try_emplace(Key, Value.str());
535533
}
536534
}
537535

0 commit comments

Comments
 (0)