llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tools-extra @llvm/pr-subscribers-clang-tidy Author: Victor Chernyakin (localspook) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/173191.diff 13 Files Affected: - (modified) clang-tools-extra/clang-tidy/ClangTidy.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp (+3-3) - (modified) clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp (+10-10) - (modified) clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp (+3-4) - (modified) clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp (+3-3) - (modified) clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp (+5-7) - (modified) clang-tools-extra/clang-tidy/utils/DesignatedInitializers.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp (+2-2) - (modified) clang-tools-extra/clang-tidy/utils/UsingInserter.cpp (+1-1) ``````````diff diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp index 0893884f937d3..bd09031f0c8ea 100644 --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -178,7 +178,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 16a4d13b9aadb..af70ed7c5665f 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 0d69b9fd88213..3e122b7e35f67 100644 --- a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp @@ -194,7 +194,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 ce01a85f70fde..24eb6a67b0996 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp @@ -420,7 +420,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 @@ -731,7 +731,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)); } @@ -793,8 +793,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 f6685dda7e09e..4843a7ab925cb 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; } @@ -470,7 +470,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 a966f1f6e24c5..7b0651a328b27 100644 --- a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp @@ -116,7 +116,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 0b52a9664a7a5..c7ab1d283db3e 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( `````````` </details> https://github.com/llvm/llvm-project/pull/173191 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
