summaryrefslogtreecommitdiffstats
path: root/clang/lib/Rewrite
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-01-20 20:26:09 +0000
committerAlp Toker <alp@nuanti.com>2014-01-20 20:26:09 +0000
commit9cacbabd33eea88e9c416e4bc8abf58eebf5589d (patch)
tree74755c65f472ae14b820aa71f77069e69a1a91c4 /clang/lib/Rewrite
parent8ff1610f06646b0f62060df06c194214bd992260 (diff)
downloadbcm5719-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/Rewrite')
-rw-r--r--clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp51
-rw-r--r--clang/lib/Rewrite/Frontend/RewriteObjC.cpp51
2 files changed, 58 insertions, 44 deletions
diff --git a/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp b/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp
index 6ec37f80487..759e57e32b5 100644
--- a/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp
+++ b/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp
@@ -615,8 +615,9 @@ void RewriteModernObjC::RewriteBlocksInFunctionProtoType(QualType funcType,
NamedDecl *D) {
if (const FunctionProtoType *fproto
= dyn_cast<FunctionProtoType>(funcType.IgnoreParens())) {
- for (FunctionProtoType::arg_type_iterator I = fproto->arg_type_begin(),
- E = fproto->arg_type_end(); I && (I != E); ++I)
+ for (FunctionProtoType::param_type_iterator I = fproto->param_type_begin(),
+ E = fproto->param_type_end();
+ I && (I != E); ++I)
if (isTopLevelBlockPointerType(*I)) {
// All the args are checked/rewritten. Don't call twice!
RewriteBlockPointerDecl(D);
@@ -984,14 +985,15 @@ void RewriteModernObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
// Now, emit the argument types (if any).
if (const FunctionProtoType *FT = dyn_cast<FunctionProtoType>(FPRetType)){
Getr += "(";
- for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i) {
+ for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
if (i) Getr += ", ";
- std::string ParamStr = FT->getArgType(i).getAsString(
- Context->getPrintingPolicy());
+ std::string ParamStr =
+ FT->getParamType(i).getAsString(Context->getPrintingPolicy());
Getr += ParamStr;
}
if (FT->isVariadic()) {
- if (FT->getNumArgs()) Getr += ", ";
+ if (FT->getNumParams())
+ Getr += ", ";
Getr += "...";
}
Getr += ")";
@@ -1353,14 +1355,15 @@ void RewriteModernObjC::RewriteObjCMethodDecl(const ObjCInterfaceDecl *IDecl,
// Now, emit the argument types (if any).
if (const FunctionProtoType *FT = dyn_cast<FunctionProtoType>(FPRetType)) {
ResultStr += "(";
- for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i) {
+ for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
if (i) ResultStr += ", ";
- std::string ParamStr = FT->getArgType(i).getAsString(
- Context->getPrintingPolicy());
+ std::string ParamStr =
+ FT->getParamType(i).getAsString(Context->getPrintingPolicy());
ResultStr += ParamStr;
}
if (FT->isVariadic()) {
- if (FT->getNumArgs()) ResultStr += ", ";
+ if (FT->getNumParams())
+ ResultStr += ", ";
ResultStr += "...";
}
ResultStr += ")";
@@ -2304,8 +2307,8 @@ void RewriteModernObjC::RewriteObjCQualifiedInterfaceTypes(Decl *Dcl) {
// Now check arguments.
const char *startBuf = SM->getCharacterData(Loc);
const char *startFuncBuf = startBuf;
- for (unsigned i = 0; i < proto->getNumArgs(); i++) {
- if (needToScanForQualifiers(proto->getArgType(i))) {
+ for (unsigned i = 0; i < proto->getNumParams(); i++) {
+ if (needToScanForQualifiers(proto->getParamType(i))) {
// Since types are unique, we need to scan the buffer.
const char *endBuf = startBuf;
@@ -2448,9 +2451,9 @@ void RewriteModernObjC::RewriteBlockLiteralFunctionDecl(FunctionDecl *FD) {
FdStr += " ";
FdStr += FD->getName();
FdStr += "(";
- unsigned numArgs = proto->getNumArgs();
+ unsigned numArgs = proto->getNumParams();
for (unsigned i = 0; i < numArgs; i++) {
- QualType ArgType = proto->getArgType(i);
+ QualType ArgType = proto->getParamType(i);
RewriteBlockPointerType(FdStr, ArgType);
if (i+1 < numArgs)
FdStr += ", ";
@@ -4732,8 +4735,9 @@ QualType RewriteModernObjC::convertFunctionTypeOfBlocks(const FunctionType *FT)
bool modified = convertObjCTypeToCStyleType(Res);
if (FTP) {
- for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
- E = FTP->arg_type_end(); I && (I != E); ++I) {
+ for (FunctionProtoType::param_type_iterator I = FTP->param_type_begin(),
+ E = FTP->param_type_end();
+ I && (I != E); ++I) {
QualType t = *I;
// Make sure we convert "t (^)(...)" to "t (*)(...)".
if (convertObjCTypeToCStyleType(t))
@@ -4800,8 +4804,9 @@ Stmt *RewriteModernObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp
// Push the block argument type.
ArgTypes.push_back(PtrBlock);
if (FTP) {
- for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
- E = FTP->arg_type_end(); I && (I != E); ++I) {
+ for (FunctionProtoType::param_type_iterator I = FTP->param_type_begin(),
+ E = FTP->param_type_end();
+ I && (I != E); ++I) {
QualType t = *I;
// Make sure we convert "t (^)(...)" to "t (*)(...)".
if (!convertBlockPointerToFunctionPointer(t))
@@ -5020,8 +5025,9 @@ bool RewriteModernObjC::PointerTypeTakesAnyBlockArguments(QualType QT) {
FTP = BPT->getPointeeType()->getAs<FunctionProtoType>();
}
if (FTP) {
- for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
- E = FTP->arg_type_end(); I != E; ++I)
+ for (FunctionProtoType::param_type_iterator I = FTP->param_type_begin(),
+ E = FTP->param_type_end();
+ I != E; ++I)
if (isTopLevelBlockPointerType(*I))
return true;
}
@@ -5039,8 +5045,9 @@ bool RewriteModernObjC::PointerTypeTakesAnyObjCQualifiedType(QualType QT) {
FTP = BPT->getPointeeType()->getAs<FunctionProtoType>();
}
if (FTP) {
- for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
- E = FTP->arg_type_end(); I != E; ++I) {
+ for (FunctionProtoType::param_type_iterator I = FTP->param_type_begin(),
+ E = FTP->param_type_end();
+ I != E; ++I) {
if ((*I)->isObjCQualifiedIdType())
return true;
if ((*I)->isObjCObjectPointerType() &&
diff --git a/clang/lib/Rewrite/Frontend/RewriteObjC.cpp b/clang/lib/Rewrite/Frontend/RewriteObjC.cpp
index b6109697285..48649574c03 100644
--- a/clang/lib/Rewrite/Frontend/RewriteObjC.cpp
+++ b/clang/lib/Rewrite/Frontend/RewriteObjC.cpp
@@ -547,8 +547,9 @@ void RewriteObjC::RewriteBlocksInFunctionProtoType(QualType funcType,
NamedDecl *D) {
if (const FunctionProtoType *fproto
= dyn_cast<FunctionProtoType>(funcType.IgnoreParens())) {
- for (FunctionProtoType::arg_type_iterator I = fproto->arg_type_begin(),
- E = fproto->arg_type_end(); I && (I != E); ++I)
+ for (FunctionProtoType::param_type_iterator I = fproto->param_type_begin(),
+ E = fproto->param_type_end();
+ I && (I != E); ++I)
if (isTopLevelBlockPointerType(*I)) {
// All the args are checked/rewritten. Don't call twice!
RewriteBlockPointerDecl(D);
@@ -818,14 +819,15 @@ void RewriteObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
// Now, emit the argument types (if any).
if (const FunctionProtoType *FT = dyn_cast<FunctionProtoType>(FPRetType)){
Getr += "(";
- for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i) {
+ for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
if (i) Getr += ", ";
- std::string ParamStr = FT->getArgType(i).getAsString(
- Context->getPrintingPolicy());
+ std::string ParamStr =
+ FT->getParamType(i).getAsString(Context->getPrintingPolicy());
Getr += ParamStr;
}
if (FT->isVariadic()) {
- if (FT->getNumArgs()) Getr += ", ";
+ if (FT->getNumParams())
+ Getr += ", ";
Getr += "...";
}
Getr += ")";
@@ -1157,14 +1159,15 @@ void RewriteObjC::RewriteObjCMethodDecl(const ObjCInterfaceDecl *IDecl,
// Now, emit the argument types (if any).
if (const FunctionProtoType *FT = dyn_cast<FunctionProtoType>(FPRetType)) {
ResultStr += "(";
- for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i) {
+ for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
if (i) ResultStr += ", ";
- std::string ParamStr = FT->getArgType(i).getAsString(
- Context->getPrintingPolicy());
+ std::string ParamStr =
+ FT->getParamType(i).getAsString(Context->getPrintingPolicy());
ResultStr += ParamStr;
}
if (FT->isVariadic()) {
- if (FT->getNumArgs()) ResultStr += ", ";
+ if (FT->getNumParams())
+ ResultStr += ", ";
ResultStr += "...";
}
ResultStr += ")";
@@ -2190,8 +2193,8 @@ void RewriteObjC::RewriteObjCQualifiedInterfaceTypes(Decl *Dcl) {
// Now check arguments.
const char *startBuf = SM->getCharacterData(Loc);
const char *startFuncBuf = startBuf;
- for (unsigned i = 0; i < proto->getNumArgs(); i++) {
- if (needToScanForQualifiers(proto->getArgType(i))) {
+ for (unsigned i = 0; i < proto->getNumParams(); i++) {
+ if (needToScanForQualifiers(proto->getParamType(i))) {
// Since types are unique, we need to scan the buffer.
const char *endBuf = startBuf;
@@ -2335,9 +2338,9 @@ void RewriteObjC::RewriteBlockLiteralFunctionDecl(FunctionDecl *FD) {
FdStr += " ";
FdStr += FD->getName();
FdStr += "(";
- unsigned numArgs = proto->getNumArgs();
+ unsigned numArgs = proto->getNumParams();
for (unsigned i = 0; i < numArgs; i++) {
- QualType ArgType = proto->getArgType(i);
+ QualType ArgType = proto->getParamType(i);
RewriteBlockPointerType(FdStr, ArgType);
if (i+1 < numArgs)
FdStr += ", ";
@@ -3788,8 +3791,9 @@ QualType RewriteObjC::convertFunctionTypeOfBlocks(const FunctionType *FT) {
bool HasBlockType = convertBlockPointerToFunctionPointer(Res);
if (FTP) {
- for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
- E = FTP->arg_type_end(); I && (I != E); ++I) {
+ for (FunctionProtoType::param_type_iterator I = FTP->param_type_begin(),
+ E = FTP->param_type_end();
+ I && (I != E); ++I) {
QualType t = *I;
// Make sure we convert "t (^)(...)" to "t (*)(...)".
if (convertBlockPointerToFunctionPointer(t))
@@ -3858,8 +3862,9 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) {
// Push the block argument type.
ArgTypes.push_back(PtrBlock);
if (FTP) {
- for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
- E = FTP->arg_type_end(); I && (I != E); ++I) {
+ for (FunctionProtoType::param_type_iterator I = FTP->param_type_begin(),
+ E = FTP->param_type_end();
+ I && (I != E); ++I) {
QualType t = *I;
// Make sure we convert "t (^)(...)" to "t (*)(...)".
if (!convertBlockPointerToFunctionPointer(t))
@@ -4061,8 +4066,9 @@ bool RewriteObjC::PointerTypeTakesAnyBlockArguments(QualType QT) {
FTP = BPT->getPointeeType()->getAs<FunctionProtoType>();
}
if (FTP) {
- for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
- E = FTP->arg_type_end(); I != E; ++I)
+ for (FunctionProtoType::param_type_iterator I = FTP->param_type_begin(),
+ E = FTP->param_type_end();
+ I != E; ++I)
if (isTopLevelBlockPointerType(*I))
return true;
}
@@ -4080,8 +4086,9 @@ bool RewriteObjC::PointerTypeTakesAnyObjCQualifiedType(QualType QT) {
FTP = BPT->getPointeeType()->getAs<FunctionProtoType>();
}
if (FTP) {
- for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
- E = FTP->arg_type_end(); I != E; ++I) {
+ for (FunctionProtoType::param_type_iterator I = FTP->param_type_begin(),
+ E = FTP->param_type_end();
+ I != E; ++I) {
if ((*I)->isObjCQualifiedIdType())
return true;
if ((*I)->isObjCObjectPointerType() &&
OpenPOWER on IntegriCloud