diff options
author | Alp Toker <alp@nuanti.com> | 2014-01-20 20:26:09 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-01-20 20:26:09 +0000 |
commit | 9cacbabd33eea88e9c416e4bc8abf58eebf5589d (patch) | |
tree | 74755c65f472ae14b820aa71f77069e69a1a91c4 /clang/lib/Sema/SemaDecl.cpp | |
parent | 8ff1610f06646b0f62060df06c194214bd992260 (diff) | |
download | bcm5719-llvm-9cacbabd33eea88e9c416e4bc8abf58eebf5589d.tar.gz bcm5719-llvm-9cacbabd33eea88e9c416e4bc8abf58eebf5589d.zip |
Rename FunctionProtoType accessors from 'arguments' to 'parameters'
Fix a perennial source of confusion in the clang type system: Declarations and
function prototypes have parameters to which arguments are supplied, so calling
these 'arguments' was a stretch even in C mode, let alone C++ where default
arguments, templates and overloading make the distinction important to get
right.
Readability win across the board, especially in the casting, ADL and
overloading implementations which make a lot more sense at a glance now.
Will keep an eye on the builders and update dependent projects shortly.
No functional change.
llvm-svn: 199686
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 6d46903c58b..f7b7ac87ec9 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1563,12 +1563,10 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, // FunctionDecl. if (const FunctionProtoType *FT = dyn_cast<FunctionProtoType>(R)) { SmallVector<ParmVarDecl*, 16> Params; - for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i) { + for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) { ParmVarDecl *parm = - ParmVarDecl::Create(Context, New, SourceLocation(), - SourceLocation(), 0, - FT->getArgType(i), /*TInfo=*/0, - SC_None, 0); + ParmVarDecl::Create(Context, New, SourceLocation(), SourceLocation(), + 0, FT->getParamType(i), /*TInfo=*/0, SC_None, 0); parm->setScopeInfo(0, i); Params.push_back(parm); } @@ -2649,8 +2647,8 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, // The old declaration provided a function prototype, but the // new declaration does not. Merge in the prototype. assert(!OldProto->hasExceptionSpec() && "Exception spec in C"); - SmallVector<QualType, 16> ParamTypes(OldProto->arg_type_begin(), - OldProto->arg_type_end()); + SmallVector<QualType, 16> ParamTypes(OldProto->param_type_begin(), + OldProto->param_type_end()); NewQType = Context.getFunctionType(NewFuncType->getResultType(), ParamTypes, OldProto->getExtProtoInfo()); @@ -2659,9 +2657,9 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, // Synthesize a parameter for each argument type. SmallVector<ParmVarDecl*, 16> Params; - for (FunctionProtoType::arg_type_iterator - ParamType = OldProto->arg_type_begin(), - ParamEnd = OldProto->arg_type_end(); + for (FunctionProtoType::param_type_iterator + ParamType = OldProto->param_type_begin(), + ParamEnd = OldProto->param_type_end(); ParamType != ParamEnd; ++ParamType) { ParmVarDecl *Param = ParmVarDecl::Create(Context, New, SourceLocation(), @@ -2711,13 +2709,13 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, ParmVarDecl *OldParm = Old->getParamDecl(Idx); ParmVarDecl *NewParm = New->getParamDecl(Idx); if (Context.typesAreCompatible(OldParm->getType(), - NewProto->getArgType(Idx))) { + NewProto->getParamType(Idx))) { ArgTypes.push_back(NewParm->getType()); } else if (Context.typesAreCompatible(OldParm->getType(), NewParm->getType(), /*CompareUnqualified=*/true)) { - GNUCompatibleParamWarning Warn - = { OldParm, NewParm, NewProto->getArgType(Idx) }; + GNUCompatibleParamWarning Warn = { OldParm, NewParm, + NewProto->getParamType(Idx) }; Warnings.push_back(Warn); ArgTypes.push_back(NewParm->getType()); } else @@ -6735,7 +6733,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, NewFD->getType()->castAs<FunctionProtoType>(); QualType Result = SubstAutoType(FPT->getResultType(), Context.DependentTy); - NewFD->setType(Context.getFunctionType(Result, FPT->getArgTypes(), + NewFD->setType(Context.getFunctionType(Result, FPT->getParamTypes(), FPT->getExtProtoInfo())); } @@ -6854,7 +6852,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.ExceptionSpecType = EST_BasicNoexcept; NewFD->setType(Context.getFunctionType(FPT->getResultType(), - FPT->getArgTypes(), EPI)); + FPT->getParamTypes(), EPI)); } } @@ -6918,8 +6916,9 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // @endcode // Synthesize a parameter for each argument type. - for (FunctionProtoType::arg_type_iterator AI = FT->arg_type_begin(), - AE = FT->arg_type_end(); AI != AE; ++AI) { + for (FunctionProtoType::param_type_iterator AI = FT->param_type_begin(), + AE = FT->param_type_end(); + AI != AE; ++AI) { ParmVarDecl *Param = BuildParmVarDeclForTypedef(NewFD, D.getIdentifierLoc(), *AI); Param->setScopeInfo(0, Params.size()); @@ -7480,7 +7479,7 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.TypeQuals |= Qualifiers::Const; MD->setType(Context.getFunctionType(FPT->getResultType(), - FPT->getArgTypes(), EPI)); + FPT->getParamTypes(), EPI)); // Warn that we did this, if we're not performing template instantiation. // In that case, we'll have warned already when the template was defined. @@ -7740,7 +7739,7 @@ void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) { if (isa<FunctionNoProtoType>(FT)) return; const FunctionProtoType* FTP = cast<const FunctionProtoType>(FT); - unsigned nparams = FTP->getNumArgs(); + unsigned nparams = FTP->getNumParams(); assert(FD->getNumParams() == nparams); bool HasExtraParameters = (nparams > 3); @@ -7765,7 +7764,7 @@ void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) { QualType Expected[] = { Context.IntTy, CharPP, CharPP, CharPP }; for (unsigned i = 0; i < nparams; ++i) { - QualType AT = FTP->getArgType(i); + QualType AT = FTP->getParamType(i); bool mismatch = true; |