Apply some suggestions from clang-tidy's performance-unnecessary-value-param.

No functionality change intended.

llvm-svn: 272789
This commit is contained in:
Benjamin Kramer 2016-06-15 14:20:56 +00:00
parent 771721cb35
commit 7320b99b2c
7 changed files with 32 additions and 39 deletions

View File

@ -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) {

View File

@ -712,7 +712,7 @@ private:
// Returns true if 'TypeNode' has an alias that matches the given matcher.
bool typeHasMatchingAlias(const Type *TypeNode,
const Matcher<NamedDecl> Matcher,
const Matcher<NamedDecl> &Matcher,
BoundNodesTreeBuilder *Builder) {
const Type *const CanonicalType =
ActiveASTContext->getCanonicalType(TypeNode);

View File

@ -3985,12 +3985,11 @@ public:
void HandleNullChar(const char *nullCharacter) override;
template <typename Range>
static void EmitFormatDiagnostic(Sema &S, bool inFunctionCall,
const Expr *ArgumentExpr,
PartialDiagnostic PDiag,
SourceLocation StringLoc,
bool IsStringLocation, Range StringRange,
ArrayRef<FixItHint> Fixit = None);
static void
EmitFormatDiagnostic(Sema &S, bool inFunctionCall, const Expr *ArgumentExpr,
const PartialDiagnostic &PDiag, SourceLocation StringLoc,
bool IsStringLocation, Range StringRange,
ArrayRef<FixItHint> 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<typename Range>
void CheckFormatHandler::EmitFormatDiagnostic(Sema &S, bool InFunctionCall,
const Expr *ArgumentExpr,
PartialDiagnostic PDiag,
SourceLocation Loc,
bool IsStringLocation,
Range StringRange,
ArrayRef<FixItHint> FixIt) {
template <typename Range>
void CheckFormatHandler::EmitFormatDiagnostic(
Sema &S, bool InFunctionCall, const Expr *ArgumentExpr,
const PartialDiagnostic &PDiag, SourceLocation Loc, bool IsStringLocation,
Range StringRange, ArrayRef<FixItHint> 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;

View File

@ -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();

View File

@ -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<DeducedTemplateArgument> &Deduced) {
static Sema::TemplateDeductionResult DeduceNonTypeTemplateArgument(
Sema &S, NonTypeTemplateParmDecl *NTTP, const llvm::APSInt &Value,
QualType ValueType, bool DeducedFromArrayBound, TemplateDeductionInfo &Info,
SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
assert(NTTP->getDepth() == 0 &&
"Cannot deduce non-type template argument with depth > 0");

View File

@ -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<CompileCommand>

View File

@ -50,8 +50,9 @@ FrontendActionFactory::~FrontendActionFactory() {}
static clang::driver::Driver *newDriver(
clang::DiagnosticsEngine *Diagnostics, const char *BinaryName,
IntrusiveRefCntPtr<vfs::FileSystem> 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;
}