From: Benjamin Kramer Date: Wed, 15 Jun 2016 14:20:56 +0000 (+0000) Subject: Apply some suggestions from clang-tidy's performance-unnecessary-value-param. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b28d528b74212411a229c985c1c83af3540ba9a;p=clang Apply some suggestions from clang-tidy's performance-unnecessary-value-param. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272789 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTDiagnostic.cpp b/lib/AST/ASTDiagnostic.cpp index 658d850b12..f496125073 100644 --- a/lib/AST/ASTDiagnostic.cpp +++ b/lib/AST/ASTDiagnostic.cpp @@ -616,7 +616,7 @@ class TemplateDiff { SetDefault(FromDefault, ToDefault); } - void SetIntegerDiff(llvm::APSInt FromInt, llvm::APSInt ToInt, + void SetIntegerDiff(const llvm::APSInt &FromInt, const llvm::APSInt &ToInt, bool IsValidFromInt, bool IsValidToInt, QualType FromIntType, QualType ToIntType, Expr *FromExpr, Expr *ToExpr, bool FromDefault, @@ -653,7 +653,7 @@ class TemplateDiff { void SetFromDeclarationAndToIntegerDiff( ValueDecl *FromValueDecl, bool FromAddressOf, bool FromNullPtr, - Expr *FromExpr, llvm::APSInt ToInt, bool IsValidToInt, + Expr *FromExpr, const llvm::APSInt &ToInt, bool IsValidToInt, QualType ToIntType, Expr *ToExpr, bool FromDefault, bool ToDefault) { assert(FlatTree[CurrentNode].Kind == Invalid && "Node is not empty."); FlatTree[CurrentNode].Kind = FromDeclarationAndToInteger; @@ -669,7 +669,7 @@ class TemplateDiff { } void SetFromIntegerAndToDeclarationDiff( - llvm::APSInt FromInt, bool IsValidFromInt, QualType FromIntType, + const llvm::APSInt &FromInt, bool IsValidFromInt, QualType FromIntType, Expr *FromExpr, ValueDecl *ToValueDecl, bool ToAddressOf, bool ToNullPtr, Expr *ToExpr, bool FromDefault, bool ToDefault) { assert(FlatTree[CurrentNode].Kind == Invalid && "Node is not empty."); @@ -1705,7 +1705,7 @@ class TemplateDiff { /// PrintAPSInt - Handles printing of integral arguments, highlighting /// argument differences. - void PrintAPSInt(llvm::APSInt FromInt, llvm::APSInt ToInt, + void PrintAPSInt(const llvm::APSInt &FromInt, const llvm::APSInt &ToInt, bool IsValidFromInt, bool IsValidToInt, QualType FromIntType, QualType ToIntType, Expr *FromExpr, Expr *ToExpr, bool FromDefault, bool ToDefault, bool Same) { @@ -1738,8 +1738,8 @@ class TemplateDiff { /// PrintAPSInt - If valid, print the APSInt. If the expression is /// gives more information, print it too. - void PrintAPSInt(llvm::APSInt Val, Expr *E, bool Valid, QualType IntType, - bool PrintType) { + void PrintAPSInt(const llvm::APSInt &Val, Expr *E, bool Valid, + QualType IntType, bool PrintType) { Bold(); if (Valid) { if (HasExtraInfo(E)) { @@ -1850,7 +1850,7 @@ class TemplateDiff { /// APSInt to print a mixed difference. void PrintValueDeclAndInteger(ValueDecl *VD, bool NeedAddressOf, bool IsNullPtr, Expr *VDExpr, bool DefaultDecl, - llvm::APSInt Val, QualType IntType, + const llvm::APSInt &Val, QualType IntType, Expr *IntExpr, bool DefaultInt) { if (!PrintTree) { OS << (DefaultDecl ? "(default) " : ""); @@ -1870,7 +1870,7 @@ class TemplateDiff { /// PrintIntegerAndValueDecl - Uses the print functions for APSInt and /// ValueDecl to print a mixed difference. - void PrintIntegerAndValueDecl(llvm::APSInt Val, QualType IntType, + void PrintIntegerAndValueDecl(const llvm::APSInt &Val, QualType IntType, Expr *IntExpr, bool DefaultInt, ValueDecl *VD, bool NeedAddressOf, bool IsNullPtr, Expr *VDExpr, bool DefaultDecl) { diff --git a/lib/ASTMatchers/ASTMatchFinder.cpp b/lib/ASTMatchers/ASTMatchFinder.cpp index eed1a182b2..19e5743ea1 100644 --- a/lib/ASTMatchers/ASTMatchFinder.cpp +++ b/lib/ASTMatchers/ASTMatchFinder.cpp @@ -712,7 +712,7 @@ private: // Returns true if 'TypeNode' has an alias that matches the given matcher. bool typeHasMatchingAlias(const Type *TypeNode, - const Matcher Matcher, + const Matcher &Matcher, BoundNodesTreeBuilder *Builder) { const Type *const CanonicalType = ActiveASTContext->getCanonicalType(TypeNode); diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 37474b9edb..790ff4c09f 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -3985,12 +3985,11 @@ public: void HandleNullChar(const char *nullCharacter) override; template - static void EmitFormatDiagnostic(Sema &S, bool inFunctionCall, - const Expr *ArgumentExpr, - PartialDiagnostic PDiag, - SourceLocation StringLoc, - bool IsStringLocation, Range StringRange, - ArrayRef Fixit = None); + static void + EmitFormatDiagnostic(Sema &S, bool inFunctionCall, const Expr *ArgumentExpr, + const PartialDiagnostic &PDiag, SourceLocation StringLoc, + bool IsStringLocation, Range StringRange, + ArrayRef Fixit = None); protected: bool HandleInvalidConversionSpecifier(unsigned argIndex, SourceLocation Loc, @@ -4347,14 +4346,11 @@ void CheckFormatHandler::EmitFormatDiagnostic(PartialDiagnostic PDiag, /// templated so it can accept either a CharSourceRange or a SourceRange. /// /// \param FixIt optional fix it hint for the format string. -template -void CheckFormatHandler::EmitFormatDiagnostic(Sema &S, bool InFunctionCall, - const Expr *ArgumentExpr, - PartialDiagnostic PDiag, - SourceLocation Loc, - bool IsStringLocation, - Range StringRange, - ArrayRef FixIt) { +template +void CheckFormatHandler::EmitFormatDiagnostic( + Sema &S, bool InFunctionCall, const Expr *ArgumentExpr, + const PartialDiagnostic &PDiag, SourceLocation Loc, bool IsStringLocation, + Range StringRange, ArrayRef FixIt) { if (InFunctionCall) { const Sema::SemaDiagnosticBuilder &D = S.Diag(Loc, PDiag); D << StringRange; @@ -7225,9 +7221,8 @@ void CheckTrivialUnsignedComparison(Sema &S, BinaryOperator *E) { } } -void DiagnoseOutOfRangeComparison(Sema &S, BinaryOperator *E, - Expr *Constant, Expr *Other, - llvm::APSInt Value, +void DiagnoseOutOfRangeComparison(Sema &S, BinaryOperator *E, Expr *Constant, + Expr *Other, const llvm::APSInt &Value, bool RhsConstant) { // Disable warning in template instantiations. if (!S.ActiveTemplateInstantiations.empty()) @@ -8365,7 +8360,7 @@ void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC) { // Helper function for Sema::DiagnoseAlwaysNonNullPointer. // Returns true when emitting a warning about taking the address of a reference. static bool CheckForReference(Sema &SemaRef, const Expr *E, - PartialDiagnostic PD) { + const PartialDiagnostic &PD) { E = E->IgnoreParenImpCasts(); const FunctionDecl *FD = nullptr; @@ -9320,7 +9315,7 @@ static const Type* getElementType(const Expr *BaseExpr) { /// /// We avoid emitting out-of-bounds access warnings for such arrays as they are /// commonly used to emulate flexible arrays in C89 code. -static bool IsTailPaddedMemberArray(Sema &S, llvm::APInt Size, +static bool IsTailPaddedMemberArray(Sema &S, const llvm::APInt &Size, const NamedDecl *ND) { if (Size != 1 || !ND) return false; diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index d6c16795b1..fdaa005108 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -6647,7 +6647,7 @@ static void CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures( static ExprResult attemptRecovery(Sema &SemaRef, const TypoCorrectionConsumer &Consumer, - TypoCorrection TC) { + const TypoCorrection &TC) { LookupResult R(SemaRef, Consumer.getLookupResult().getLookupNameInfo(), Consumer.getLookupResult().getLookupKind()); const CXXScopeSpec *SS = Consumer.getSS(); diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index 59dc1da49a..e5c24252ed 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -286,13 +286,10 @@ checkDeducedTemplateArguments(ASTContext &Context, /// \brief Deduce the value of the given non-type template parameter /// from the given constant. -static Sema::TemplateDeductionResult -DeduceNonTypeTemplateArgument(Sema &S, - NonTypeTemplateParmDecl *NTTP, - llvm::APSInt Value, QualType ValueType, - bool DeducedFromArrayBound, - TemplateDeductionInfo &Info, - SmallVectorImpl &Deduced) { +static Sema::TemplateDeductionResult DeduceNonTypeTemplateArgument( + Sema &S, NonTypeTemplateParmDecl *NTTP, const llvm::APSInt &Value, + QualType ValueType, bool DeducedFromArrayBound, TemplateDeductionInfo &Info, + SmallVectorImpl &Deduced) { assert(NTTP->getDepth() == 0 && "Cannot deduce non-type template argument with depth > 0"); diff --git a/lib/Tooling/CommonOptionsParser.cpp b/lib/Tooling/CommonOptionsParser.cpp index 7c1e4b9491..5a44061cbd 100644 --- a/lib/Tooling/CommonOptionsParser.cpp +++ b/lib/Tooling/CommonOptionsParser.cpp @@ -62,7 +62,7 @@ public: : Compilations(std::move(Compilations)) {} void appendArgumentsAdjuster(ArgumentsAdjuster Adjuster) { - Adjusters.push_back(Adjuster); + Adjusters.push_back(std::move(Adjuster)); } std::vector diff --git a/lib/Tooling/Tooling.cpp b/lib/Tooling/Tooling.cpp index c8ebc0348f..8dee24dcff 100644 --- a/lib/Tooling/Tooling.cpp +++ b/lib/Tooling/Tooling.cpp @@ -50,8 +50,9 @@ FrontendActionFactory::~FrontendActionFactory() {} static clang::driver::Driver *newDriver( clang::DiagnosticsEngine *Diagnostics, const char *BinaryName, IntrusiveRefCntPtr VFS) { - clang::driver::Driver *CompilerDriver = new clang::driver::Driver( - BinaryName, llvm::sys::getDefaultTargetTriple(), *Diagnostics, VFS); + clang::driver::Driver *CompilerDriver = + new clang::driver::Driver(BinaryName, llvm::sys::getDefaultTargetTriple(), + *Diagnostics, std::move(VFS)); CompilerDriver->setTitle("clang_based_tool"); return CompilerDriver; }