Author: Victor Chernyakin Date: 2025-12-21T12:50:46-07:00 New Revision: e69deb236eb464f56c8229c3c190ca686e4284b6
URL: https://github.com/llvm/llvm-project/commit/e69deb236eb464f56c8229c3c190ca686e4284b6 DIFF: https://github.com/llvm/llvm-project/commit/e69deb236eb464f56c8229c3c190ca686e4284b6.diff LOG: [clang-tidy][NFC] Migrate away from `make_*` functions (#173191) These seem to always have a better alternative (CTAD, braced init-list, etc.) Added: Modified: clang-tools-extra/clang-tidy/ClangTidy.cpp clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp clang-tools-extra/clang-tidy/utils/DesignatedInitializers.cpp clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp clang-tools-extra/clang-tidy/utils/UsingInserter.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp index 970c463029abf..e52794feedd2d 100644 --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -176,7 +176,7 @@ class ErrorReporter { ++AppliedFixes; } FixLoc = getLocation(FixAbsoluteFilePath, Repl.getOffset()); - FixLocations.push_back(std::make_pair(FixLoc, CanBeApplied)); + FixLocations.emplace_back(FixLoc, CanBeApplied); Entry.BuildDir = Error.BuildDirectory; } } diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp index faa568e521f7d..0355eccc397e5 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -659,13 +659,13 @@ void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() { // disallowing the first one. switch (Type) { case ET_Begin: - Priority = std::make_tuple(Begin, Type, -End, -ErrorSize, ErrorId); + Priority = {Begin, Type, -End, -ErrorSize, ErrorId}; break; case ET_Insert: - Priority = std::make_tuple(Begin, Type, -End, ErrorSize, ErrorId); + Priority = {Begin, Type, -End, ErrorSize, ErrorId}; break; case ET_End: - Priority = std::make_tuple(End, Type, -Begin, ErrorSize, ErrorId); + Priority = {End, Type, -Begin, ErrorSize, ErrorId}; break; } } diff --git a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp index 9e403fb8be3dd..b29fd3a0b94ee 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp @@ -51,40 +51,40 @@ getNewScaleSingleStep(DurationScale OldScale, double Multiplier) { switch (OldScale) { case DurationScale::Hours: if (Multiplier <= 1.0 / 60.0) - return std::make_tuple(DurationScale::Minutes, Multiplier * 60.0); + return {{DurationScale::Minutes, Multiplier * 60.0}}; break; case DurationScale::Minutes: if (Multiplier >= 60.0) - return std::make_tuple(DurationScale::Hours, Multiplier / 60.0); + return {{DurationScale::Hours, Multiplier / 60.0}}; if (Multiplier <= 1.0 / 60.0) - return std::make_tuple(DurationScale::Seconds, Multiplier * 60.0); + return {{DurationScale::Seconds, Multiplier * 60.0}}; break; case DurationScale::Seconds: if (Multiplier >= 60.0) - return std::make_tuple(DurationScale::Minutes, Multiplier / 60.0); + return {{DurationScale::Minutes, Multiplier / 60.0}}; if (Multiplier <= 1e-3) - return std::make_tuple(DurationScale::Milliseconds, Multiplier * 1e3); + return {{DurationScale::Milliseconds, Multiplier * 1e3}}; break; case DurationScale::Milliseconds: if (Multiplier >= 1e3) - return std::make_tuple(DurationScale::Seconds, Multiplier / 1e3); + return {{DurationScale::Seconds, Multiplier / 1e3}}; if (Multiplier <= 1e-3) - return std::make_tuple(DurationScale::Microseconds, Multiplier * 1e3); + return {{DurationScale::Microseconds, Multiplier * 1e3}}; break; case DurationScale::Microseconds: if (Multiplier >= 1e3) - return std::make_tuple(DurationScale::Milliseconds, Multiplier / 1e3); + return {{DurationScale::Milliseconds, Multiplier / 1e3}}; if (Multiplier <= 1e-3) - return std::make_tuple(DurationScale::Nanoseconds, Multiplier * 1e-3); + return {{DurationScale::Nanoseconds, Multiplier * 1e-3}}; break; case DurationScale::Nanoseconds: if (Multiplier >= 1e3) - return std::make_tuple(DurationScale::Microseconds, Multiplier / 1e3); + return {{DurationScale::Microseconds, Multiplier / 1e3}}; break; } diff --git a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp index 830913a8c237a..0fd965f88e0d5 100644 --- a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp @@ -192,7 +192,7 @@ bool VirtualNearMissCheck::isPossibleToBeOverridden( bool VirtualNearMissCheck::isOverriddenByDerivedClass( const CXXMethodDecl *BaseMD, const CXXRecordDecl *DerivedRD) { - auto Key = std::make_pair(BaseMD, DerivedRD); + const std::pair Key(BaseMD, DerivedRD); auto Iter = OverriddenMap.find(Key); if (Iter != OverriddenMap.end()) return Iter->second; diff --git a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp index e9a5819a939f9..18d5aa44a6a95 100644 --- a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp @@ -60,7 +60,7 @@ static std::pair<std::size_t, bool> countCaseLabels(const SwitchStmt *Switch) { CurrentCase = CurrentCase->getNextSwitchCase(); } - return std::make_pair(CaseCount, HasDefault); + return {CaseCount, HasDefault}; } /// This function calculate 2 ** Bits and returns diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp index fcac40067a6af..7343557ccb722 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp @@ -424,7 +424,7 @@ getContainerFromBeginEndCall(const Expr *Init, bool IsBegin, bool *IsArrow, return {}; if (!Call->Name.empty() && Call->Name != "c") return {}; - return std::make_pair(Call->Container, Call->CallKind); + return {Call->Container, Call->CallKind}; } /// Determines the container whose begin() and end() functions are called @@ -734,7 +734,7 @@ void LoopConvertCheck::doConversion( ? "&" + VarNameOrStructuredBinding : VarNameOrStructuredBinding; } - TUInfo->getReplacedVars().insert(std::make_pair(Loop, IndexVar)); + TUInfo->getReplacedVars().try_emplace(Loop, IndexVar); FixIts.push_back(FixItHint::CreateReplacement( CharSourceRange::getTokenRange(Range), ReplaceText)); } @@ -796,8 +796,7 @@ void LoopConvertCheck::doConversion( FixIts.push_back(*Insertion); } diag(Loop->getForLoc(), "use range-based for loop instead") << FixIts; - TUInfo->getGeneratedDecls().insert( - make_pair(Loop, VarNameOrStructuredBinding)); + TUInfo->getGeneratedDecls().try_emplace(Loop, VarNameOrStructuredBinding); } /// Returns a string which refers to the container iterated over. diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp index e6392ccc8ac3b..c899018ba439e 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp @@ -35,7 +35,7 @@ namespace clang::tidy::modernize { /// the stack is the parent of the current statement (NULL for the topmost /// statement). bool StmtAncestorASTVisitor::TraverseStmt(Stmt *Statement) { - StmtAncestors.insert(std::make_pair(Statement, StmtStack.back())); + StmtAncestors.try_emplace(Statement, StmtStack.back()); StmtStack.push_back(Statement); RecursiveASTVisitor<StmtAncestorASTVisitor>::TraverseStmt(Statement); StmtStack.pop_back(); @@ -50,7 +50,7 @@ bool StmtAncestorASTVisitor::TraverseStmt(Stmt *Statement) { bool StmtAncestorASTVisitor::VisitDeclStmt(DeclStmt *Statement) { for (const auto *Decl : Statement->decls()) if (const auto *V = dyn_cast<VarDecl>(Decl)) - DeclParents.insert(std::make_pair(V, Statement)); + DeclParents.try_emplace(V, Statement); return true; } @@ -469,7 +469,7 @@ void ForLoopIndexUseVisitor::addComponent(const Expr *E) { llvm::FoldingSetNodeID ID; const Expr *Node = E->IgnoreParenImpCasts(); Node->Profile(ID, *Context, true); - DependentExprs.push_back(std::make_pair(Node, ID)); + DependentExprs.emplace_back(Node, ID); } void ForLoopIndexUseVisitor::addUsage(const Usage &U) { diff --git a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp index f1216e0a39f0b..43b98faaf6149 100644 --- a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp @@ -118,7 +118,7 @@ struct CognitiveComplexity final { } else llvm_unreachable("should not get to here."); - return std::make_pair(MsgId, Increment); + return {MsgId, Increment}; } }; diff --git a/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp b/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp index 1283632a91bb1..46f11027c970e 100644 --- a/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp @@ -83,7 +83,7 @@ void NamedParameterCheck::check(const MatchFinder::MatchResult &Result) { if (Data.contains("/*")) continue; - UnnamedParams.push_back(std::make_pair(Function, I)); + UnnamedParams.emplace_back(Function, I); } // Emit only one warning per function but fixits for all unnamed parameters. diff --git a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp index 8fa20e224833e..e1a73aa47919e 100644 --- a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp @@ -521,17 +521,15 @@ SuspiciousCallArgumentCheck::SuspiciousCallArgumentCheck( auto H = static_cast<Heuristic>(Idx); if (GetToggleOpt(H)) AppliedHeuristics.emplace_back(H); - ConfiguredBounds.emplace_back( - std::make_pair(GetBoundOpt(H, BoundKind::DissimilarBelow), - GetBoundOpt(H, BoundKind::SimilarAbove))); + ConfiguredBounds.emplace_back(GetBoundOpt(H, BoundKind::DissimilarBelow), + GetBoundOpt(H, BoundKind::SimilarAbove)); } for (const StringRef Abbreviation : optutils::parseStringList( Options.get("Abbreviations", DefaultAbbreviations))) { - auto KeyAndValue = Abbreviation.split("="); - assert(!KeyAndValue.first.empty() && !KeyAndValue.second.empty()); - AbbreviationDictionary.insert( - std::make_pair(KeyAndValue.first, KeyAndValue.second.str())); + const auto [Key, Value] = Abbreviation.split("="); + assert(!Key.empty() && !Value.empty()); + AbbreviationDictionary.try_emplace(Key, Value.str()); } } diff --git a/clang-tools-extra/clang-tidy/utils/DesignatedInitializers.cpp b/clang-tools-extra/clang-tidy/utils/DesignatedInitializers.cpp index b068ae24a391b..e22ae8a5095be 100644 --- a/clang-tools-extra/clang-tidy/utils/DesignatedInitializers.cpp +++ b/clang-tools-extra/clang-tidy/utils/DesignatedInitializers.cpp @@ -142,7 +142,7 @@ static void collectDesignators( if (!Fields) return; for (const Expr *Init : Sem->inits()) { - auto Next = llvm::make_scope_exit([&, Size(Prefix.size())] { + const llvm::scope_exit Next([&, Size(Prefix.size())] { Fields.next(); // Always advance to the next subobject name. Prefix.resize(Size); // Erase any designator we appended. }); diff --git a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp index d36b187b1da14..59cae88708377 100644 --- a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp +++ b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp @@ -48,8 +48,8 @@ class HeaderGuardPPCallbacks : public PPCallbacks { return; // Record #ifndefs that succeeded. We also need the Location of the Name. - Ifndefs[MacroNameTok.getIdentifierInfo()] = - std::make_pair(Loc, MacroNameTok.getLocation()); + Ifndefs[MacroNameTok.getIdentifierInfo()] = {Loc, + MacroNameTok.getLocation()}; } void MacroDefined(const Token &MacroNameTok, diff --git a/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp b/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp index 6a591c1a84a47..2040f42231118 100644 --- a/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp +++ b/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp @@ -35,7 +35,7 @@ std::optional<FixItHint> UsingInserter::createUsingDeclaration( if (!Function) return std::nullopt; - if (AddedUsing.count(std::make_pair(Function, QualifiedName.str())) != 0) + if (AddedUsing.count({Function, QualifiedName.str()}) != 0) return std::nullopt; const SourceLocation InsertLoc = Lexer::getLocForEndOfToken( _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
