diff --git a/clang-tools-extra/clang-tidy/abseil/DurationFactoryFloatCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationFactoryFloatCheck.cpp --- a/clang-tools-extra/clang-tidy/abseil/DurationFactoryFloatCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/DurationFactoryFloatCheck.cpp @@ -59,10 +59,8 @@ SimpleArg = stripFloatLiteralFraction(Result, *Arg); if (SimpleArg) { - diag(MatchedCall->getBeginLoc(), - (llvm::Twine("use the integer version of absl::") + - MatchedCall->getDirectCallee()->getName()) - .str()) + diag(MatchedCall->getBeginLoc(), "use the integer version of absl::%0") + << MatchedCall->getDirectCallee()->getName() << FixItHint::CreateReplacement(Arg->getSourceRange(), *SimpleArg); } } diff --git a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp --- a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp @@ -83,24 +83,18 @@ Context.getLangOpts()); // Create the StartsWith string, negating if comparison was "!=". - bool Neg = ComparisonExpr->getOpcodeStr() == "!="; - StringRef StartswithStr; - if (Neg) { - StartswithStr = "!absl::StartsWith"; - } else { - StartswithStr = "absl::StartsWith"; - } + bool Neg = ComparisonExpr->getOpcode() == BO_NE; // Create the warning message and a FixIt hint replacing the original expr. - auto Diagnostic = - diag(ComparisonExpr->getBeginLoc(), - (StringRef("use ") + StartswithStr + " instead of find() " + - ComparisonExpr->getOpcodeStr() + " 0") - .str()); + auto Diagnostic = diag(ComparisonExpr->getBeginLoc(), + "use %select{absl::StartsWith|!absl::StartsWith}0 " + "instead of find() %select{==|!=}0 0") + << Neg; Diagnostic << FixItHint::CreateReplacement( ComparisonExpr->getSourceRange(), - (StartswithStr + "(" + HaystackExprCode + ", " + NeedleExprCode + ")") + ((Neg ? "!absl::StartsWith(" : "absl::StartsWith(") + HaystackExprCode + + ", " + NeedleExprCode + ")") .str()); // Create a preprocessor #include FixIt hint (CreateIncludeInsertion checks diff --git a/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp --- a/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp @@ -72,10 +72,8 @@ utils::ExceptionAnalyzer::State::Throwing) // FIXME: We should provide more information about the exact location where // the exception is thrown, maybe the full path the exception escapes - diag(MatchedDecl->getLocation(), - "an exception may be thrown in function %0 " - - "which should not throw exceptions") + diag(MatchedDecl->getLocation(), "an exception may be thrown in function " + "%0 which should not throw exceptions") << MatchedDecl; } diff --git a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp --- a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp @@ -137,9 +137,9 @@ assert(Member->getQualifierLoc().getSourceRange().getBegin().isValid()); auto Diag = diag(Member->getQualifierLoc().getSourceRange().getBegin(), "qualified name '%0' refers to a member overridden " - "in subclass%1; did you mean %2?") + "in %plural{1:subclass|:subclasses}1; did you mean %2?") << getExprAsString(*Member, *Result.Context) - << (Parents.size() > 1 ? "es" : "") << ParentsStr; + << static_cast(Parents.size()) << ParentsStr; // Propose a fix if there's only one parent class... if (Parents.size() == 1 && diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp @@ -439,10 +439,9 @@ DiagnosticBuilder Diag = diag(Ctor ? Ctor->getBeginLoc() : ClassDecl.getLocation(), - IsUnion - ? "union constructor should initialize one of these fields: %0" - : "constructor does not initialize these fields: %0") - << toCommaSeparatedString(OrderedFields, AllFieldsToInit); + "%select{|union }0constructor %select{does not|should}0 initialize " + "%select{|one of }0these fields: %1") + << IsUnion << toCommaSeparatedString(OrderedFields, AllFieldsToInit); // Do not propose fixes for constructors in macros since we cannot place them // correctly. diff --git a/clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp b/clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp --- a/clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp +++ b/clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp @@ -38,27 +38,27 @@ const auto *VarType = Result.Nodes.getNodeAs("varType"); const auto *UserVarDecl = Result.Nodes.getNodeAs("var"); - StringRef Replacement = "llvm::Register"; + bool NeedsQualification = true; const DeclContext *Context = UserVarDecl->getDeclContext(); while (Context) { if (const auto *Namespace = dyn_cast(Context)) if (isa(Namespace->getDeclContext()) && Namespace->getName() == "llvm") - Replacement = "Register"; + NeedsQualification = false; for (const auto *UsingDirective : Context->using_directives()) { const NamespaceDecl *Namespace = UsingDirective->getNominatedNamespace(); if (isa(Namespace->getDeclContext()) && Namespace->getName() == "llvm") - Replacement = "Register"; + NeedsQualification = false; } Context = Context->getParent(); } diag(UserVarDecl->getLocation(), - "variable %0 declared as %1; use '%2' instead") - << UserVarDecl << *VarType << Replacement + "variable %0 declared as %1; use '%select{|llvm::}2Register' instead") + << UserVarDecl << *VarType << NeedsQualification << FixItHint::CreateReplacement( UserVarDecl->getTypeSourceInfo()->getTypeLoc().getSourceRange(), - Replacement); + NeedsQualification ? "llvm::Register" : "Register"); } } // namespace llvm_check diff --git a/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp --- a/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp @@ -73,21 +73,18 @@ if (const auto *RetStmt = Result.Nodes.getNodeAs("returnStmt")) { diag(RetStmt->getBeginLoc(), "operator=() should always return '*this'"); } else { - static const char *const Messages[][2] = { - {"ReturnType", "operator=() should return '%0&'"}, - {"ArgumentType", - getLangOpts().CPlusPlus11 - ? "operator=() should take '%0 const&', '%0&&' or '%0'" - : "operator=() should take '%0 const&' or '%0'"}, - {"cv", "operator=() should not be marked '%1'"}}; - const auto *Method = Result.Nodes.getNodeAs("method"); - for (const auto &Message : Messages) { - if (Result.Nodes.getNodeAs(Message[0])) - diag(Method->getBeginLoc(), Message[1]) - << Method->getParent()->getName() - << (Method->isConst() ? "const" : "virtual"); - } + if (Result.Nodes.getNodeAs("ReturnType")) + diag(Method->getBeginLoc(), "operator=() should return '%0&'") + << Method->getParent()->getName(); + if (Result.Nodes.getNodeAs("ArgumentType")) + diag(Method->getBeginLoc(), + "operator=() should take '%0 const&'%select{|, '%0&&'}1 or '%0'") + << Method->getParent()->getName() << getLangOpts().CPlusPlus11; + if (Result.Nodes.getNodeAs("cv")) + diag(Method->getBeginLoc(), + "operator=() should not be marked '%select{const|virtual}0'") + << !Method->isConst(); } } diff --git a/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp b/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp --- a/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp @@ -110,19 +110,22 @@ LeftText = "*" + LeftText; if (ReleaseMember->isArrow()) RightText = "*" + RightText; - std::string DiagText; + bool IsMove = false; // Even if x was rvalue, *x is not rvalue anymore. if (!Right->isRValue() || ReleaseMember->isArrow()) { RightText = "std::move(" + RightText + ")"; - DiagText = "prefer ptr1 = std::move(ptr2) over ptr1.reset(ptr2.release())"; - } else { - DiagText = - "prefer ptr = ReturnUnique() over ptr.reset(ReturnUnique().release())"; + IsMove = true; } + std::string NewText = LeftText + " = " + RightText; - diag(ResetMember->getExprLoc(), DiagText) << FixItHint::CreateReplacement( - CharSourceRange::getTokenRange(ResetCall->getSourceRange()), NewText); + diag(ResetMember->getExprLoc(), + "prefer ptr = %select{std::move(ptr2)|ReturnUnique()}0 over " + "ptr.reset(%select{ptr2|ReturnUnique()}0.release())") + << !IsMove + << FixItHint::CreateReplacement( + CharSourceRange::getTokenRange(ResetCall->getSourceRange()), + NewText); } } // namespace misc diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp --- a/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp @@ -57,13 +57,10 @@ void AvoidCArraysCheck::check(const MatchFinder::MatchResult &Result) { const auto *ArrayType = Result.Nodes.getNodeAs("typeloc"); - static constexpr llvm::StringLiteral UseArray = llvm::StringLiteral( - "do not declare C-style arrays, use std::array<> instead"); - static constexpr llvm::StringLiteral UseVector = llvm::StringLiteral( - "do not declare C VLA arrays, use std::vector<> instead"); - diag(ArrayType->getBeginLoc(), - ArrayType->getTypePtr()->isVariableArrayType() ? UseVector : UseArray); + "do not declare %select{C-style|C VLA}0 arrays, use " + "%select{std::array<>|std::vector<>}0 instead") + << ArrayType->getTypePtr()->isVariableArrayType(); } } // namespace modernize diff --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp --- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp @@ -245,8 +245,6 @@ } void UseEqualsDefaultCheck::check(const MatchFinder::MatchResult &Result) { - std::string SpecialFunctionName; - // Both CXXConstructorDecl and CXXDestructorDecl inherit from CXXMethodDecl. const auto *SpecialFunctionDecl = Result.Nodes.getNodeAs(SpecialFunction); @@ -276,14 +274,14 @@ bodyEmpty(Result.Context, Body); std::vector RemoveInitializers; - + unsigned MemberType; if (const auto *Ctor = dyn_cast(SpecialFunctionDecl)) { if (Ctor->getNumParams() == 0) { - SpecialFunctionName = "default constructor"; + MemberType = 0; } else { if (!isCopyConstructorAndCanBeDefaulted(Result.Context, Ctor)) return; - SpecialFunctionName = "copy constructor"; + MemberType = 1; // If there are constructor initializers, they must be removed. for (const auto *Init : Ctor->inits()) { RemoveInitializers.emplace_back( @@ -291,11 +289,11 @@ } } } else if (isa(SpecialFunctionDecl)) { - SpecialFunctionName = "destructor"; + MemberType = 2; } else { if (!isCopyAssignmentAndCanBeDefaulted(Result.Context, SpecialFunctionDecl)) return; - SpecialFunctionName = "copy-assignment operator"; + MemberType = 3; } // The location of the body is more useful inside a macro as spelling and @@ -304,8 +302,11 @@ if (Location.isMacroID()) Location = Body->getBeginLoc(); - auto Diag = diag(Location, "use '= default' to define a trivial " + - SpecialFunctionName); + auto Diag = diag( + Location, + "use '= default' to define a trivial %select{default constructor|copy " + "constructor|destructor|copy-assignment operator}0"); + Diag << MemberType; if (ApplyFix) { // Skipping comments, check for a semicolon after Body->getSourceRange() diff --git a/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp --- a/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp @@ -120,8 +120,8 @@ ASTContext &Context = *Result.Context; - auto Diag = diag(RetLoc, "function %0 should be marked " + NoDiscardMacro) - << MatchedDecl; + auto Diag = diag(RetLoc, "function %0 should be marked %1") + << MatchedDecl << NoDiscardMacro; // Check for the existence of the keyword being used as the ``[[nodiscard]]``. if (!doesNoDiscardMacroExist(Context, NoDiscardMacro)) diff --git a/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp --- a/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp @@ -64,7 +64,7 @@ this); } -static const StringRef Message = "prefer transparent functors '%0'"; +static const StringRef Message = "prefer transparent functors '%0<>'"; template static T getInnerTypeLocAs(TypeLoc Loc) { T Result; @@ -81,8 +81,7 @@ Result.Nodes.getNodeAs("FunctorClass"); if (const auto *FuncInst = Result.Nodes.getNodeAs("FuncInst")) { - diag(FuncInst->getBeginLoc(), Message) - << (FuncClass->getName() + "<>").str(); + diag(FuncInst->getBeginLoc(), Message) << FuncClass->getName(); return; } @@ -119,7 +118,7 @@ SourceLocation ReportLoc = FunctorLoc.getLocation(); if (ReportLoc.isInvalid()) return; - diag(ReportLoc, Message) << (FuncClass->getName() + "<>").str() + diag(ReportLoc, Message) << FuncClass->getName() << FixItHint::CreateRemoval( FunctorTypeLoc.getArgLoc(0).getSourceRange()); } diff --git a/clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp b/clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp --- a/clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp @@ -74,8 +74,9 @@ // There's a move constructor candidate that the caller probably intended // to call instead. diag(Initializer->getSourceLocation(), - "move constructor initializes %0 by calling a copy constructor") - << (Initializer->isBaseInitializer() ? "base class" : "class member"); + "move constructor initializes %select{class member|base class}0 by " + "calling a copy constructor") + << Initializer->isBaseInitializer(); diag(CopyCtor->getLocation(), "copy constructor being called", DiagnosticIDs::Note); diag(Candidate->getLocation(), "candidate move constructor here", diff --git a/clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp b/clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp --- a/clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp @@ -29,11 +29,11 @@ void NoexceptMoveConstructorCheck::check( const MatchFinder::MatchResult &Result) { if (const auto *Decl = Result.Nodes.getNodeAs("decl")) { - StringRef MethodType = "assignment operator"; + bool IsConstructor = false; if (const auto *Ctor = dyn_cast(Decl)) { if (!Ctor->isMoveConstructor()) return; - MethodType = "constructor"; + IsConstructor = true; } else if (!Decl->isMoveAssignmentOperator()) { return; } @@ -44,9 +44,10 @@ return; if (!isNoexceptExceptionSpec(ProtoType->getExceptionSpecType())) { - auto Diag = - diag(Decl->getLocation(), "move %0s should be marked noexcept") - << MethodType; + auto Diag = diag(Decl->getLocation(), + "move %select{assignment operator|constructor}0s should " + "be marked noexcept") + << IsConstructor; // Add FixIt hints. SourceManager &SM = *Result.SourceManager; assert(Decl->getNumParams() > 0); @@ -68,8 +69,9 @@ E = E->IgnoreImplicit(); if (!isa(E)) { diag(E->getExprLoc(), - "noexcept specifier on the move %0 evaluates to 'false'") - << MethodType; + "noexcept specifier on the move %select{assignment " + "operator|constructor}0 evaluates to 'false'") + << IsConstructor; } } } diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp --- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp +++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp @@ -206,13 +206,10 @@ auto Diagnostic = diag(Var.getLocation(), - IsConstQualified ? "the const qualified variable %0 is " - "copy-constructed from a const reference; " - "consider making it a const reference" - : "the variable %0 is copy-constructed from a " - "const reference but is only used as const " - "reference; consider making it a const reference") - << &Var; + "the %select{|const qualified }0variable %1 is copy-constructed " + "from a const reference%select{ but is only used as const " + "reference|}0; consider making it a const reference") + << IsConstQualified << &Var; if (IssueFix) recordFixes(Var, Context, Diagnostic); } diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp --- a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -137,13 +137,10 @@ auto Diag = diag(Param->getLocation(), - IsConstQualified ? "the const qualified parameter %0 is " - "copied for each invocation; consider " - "making it a reference" - : "the parameter %0 is copied for each " - "invocation but only used as a const reference; " - "consider making it a const reference") - << paramNameOrIndex(Param->getName(), Index); + "the %select{|const qualified }0parameter %1 is copied for each " + "invocation%select{ but only used as a const reference|}0; consider " + "making it a %select{const |}0reference") + << IsConstQualified << paramNameOrIndex(Param->getName(), Index); // Do not propose fixes when: // 1. the ParmVarDecl is in a macro, since we cannot place them correctly // 2. the function is virtual as it might break overrides diff --git a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp --- a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp @@ -209,10 +209,11 @@ }(); DiagnosticBuilder Diag = - diag(FixitLoc, "'%0%1%2auto %3' can be declared as '%4%3'") - << (IsLocalConst ? "const " : "") - << (IsLocalVolatile ? "volatile " : "") - << (IsLocalRestrict ? "__restrict " : "") << Var->getName() << ReplStr; + diag(FixitLoc, + "'%select{|const }0%select{|volatile }1%select{|__restrict }2auto " + "%3' can be declared as '%4%3'") + << IsLocalConst << IsLocalVolatile << IsLocalRestrict << Var->getName() + << ReplStr; for (SourceRange &Range : RemoveQualifiersRange) { Diag << FixItHint::CreateRemoval(CharSourceRange::getCharRange(Range)); @@ -253,10 +254,12 @@ TypeSpec->getEnd().isMacroID()) return; SourceLocation InsertPos = TypeSpec->getBegin(); - diag(InsertPos, "'auto *%0%1%2' can be declared as 'const auto *%0%1%2'") - << (Var->getType().isLocalConstQualified() ? "const " : "") - << (Var->getType().isLocalVolatileQualified() ? "volatile " : "") - << Var->getName() << FixItHint::CreateInsertion(InsertPos, "const "); + diag(InsertPos, + "'auto *%select{|const }0%select{|volatile }1%2' can be declared as " + "'const auto *%select{|const }0%select{|volatile }1%2'") + << Var->getType().isLocalConstQualified() + << Var->getType().isLocalVolatileQualified() << Var->getName() + << FixItHint::CreateInsertion(InsertPos, "const "); } return; } diff --git a/clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp b/clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp --- a/clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp @@ -88,19 +88,20 @@ } void UseAnyOfAllOfCheck::check(const MatchFinder::MatchResult &Result) { - StringRef Ranges = getLangOpts().CPlusPlus20 ? "::ranges" : ""; if (const auto *S = Result.Nodes.getNodeAs("any_of_loop")) { if (!isViableLoop(*S, *Result.Context)) return; - diag(S->getForLoc(), "replace loop by 'std%0::any_of()'") << Ranges; + diag(S->getForLoc(), "replace loop by 'std%select{|::ranges}0::any_of()'") + << getLangOpts().CPlusPlus20; } else if (const auto *S = Result.Nodes.getNodeAs("all_of_loop")) { if (!isViableLoop(*S, *Result.Context)) return; - diag(S->getForLoc(), "replace loop by 'std%0::all_of()'") << Ranges; + diag(S->getForLoc(), "replace loop by 'std%select{|::ranges}0::all_of()'") + << getLangOpts().CPlusPlus20; } } diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc-uniqueptr-reset-release.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc-uniqueptr-reset-release.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/misc-uniqueptr-reset-release.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc-uniqueptr-reset-release.cpp @@ -33,27 +33,27 @@ std::unique_ptr *y = &b; a.reset(b.release()); - // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: prefer ptr1 = std::move(ptr2) over ptr1.reset(ptr2.release()) [misc-uniqueptr-reset-release] + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: prefer ptr = std::move(ptr2) over ptr.reset(ptr2.release()) [misc-uniqueptr-reset-release] // CHECK-FIXES: a = std::move(b); a.reset(c.release()); - // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: prefer ptr1 = std::move(ptr2) + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: prefer ptr = std::move(ptr2) // CHECK-FIXES: a = std::move(c); a.reset(Create().release()); // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: prefer ptr = ReturnUnique() over ptr.reset(ReturnUnique().release()) [misc-uniqueptr-reset-release] // CHECK-FIXES: a = Create(); x->reset(y->release()); - // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: prefer ptr1 = std::move(ptr2) + // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: prefer ptr = std::move(ptr2) // CHECK-FIXES: *x = std::move(*y); Look().reset(Look().release()); - // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: prefer ptr1 = std::move(ptr2) + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: prefer ptr = std::move(ptr2) // CHECK-FIXES: Look() = std::move(Look()); Get()->reset(Get()->release()); - // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: prefer ptr1 = std::move(ptr2) + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: prefer ptr = std::move(ptr2) // CHECK-FIXES: *Get() = std::move(*Get()); std::unique_ptr func_a, func_b; func_a.reset(func_b.release()); - // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: prefer ptr1 = std::move(ptr2) + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: prefer ptr = std::move(ptr2) // CHECK-FIXES: func_a = std::move(func_b); }