r273650 - Use even more ArrayRefs
David Majnemer via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 23 22:33:45 PDT 2016
Author: majnemer
Date: Fri Jun 24 00:33:44 2016
New Revision: 273650
URL: http://llvm.org/viewvc/llvm-project?rev=273650&view=rev
Log:
Use even more ArrayRefs
No functional change is intended, just a small refactoring.
Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/Frontend/ASTConsumers.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=273650&r1=273649&r2=273650&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Jun 24 00:33:44 2016
@@ -1429,9 +1429,8 @@ DEF_TRAVERSE_DECL(ObjCMethodDecl, {
if (D->getReturnTypeSourceInfo()) {
TRY_TO(TraverseTypeLoc(D->getReturnTypeSourceInfo()->getTypeLoc()));
}
- for (ObjCMethodDecl::param_iterator I = D->param_begin(), E = D->param_end();
- I != E; ++I) {
- TRY_TO(TraverseDecl(*I));
+ for (ParmVarDecl *Parameter : D->parameters()) {
+ TRY_TO(TraverseDecl(Parameter));
}
if (D->isThisDeclarationADefinition()) {
TRY_TO(TraverseStmt(D->getBody()));
@@ -1832,10 +1831,8 @@ bool RecursiveASTVisitor<Derived>::Trave
// if the traverser is visiting implicit code. Parameter variable
// declarations do not have valid TypeSourceInfo, so to visit them
// we need to traverse the declarations explicitly.
- for (FunctionDecl::param_const_iterator I = D->param_begin(),
- E = D->param_end();
- I != E; ++I)
- TRY_TO(TraverseDecl(*I));
+ for (ParmVarDecl *Parameter : D->parameters())
+ TRY_TO(TraverseDecl(Parameter));
}
if (CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
Modified: cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h?rev=273650&r1=273649&r2=273650&view=diff
==============================================================================
--- cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h (original)
+++ cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h Fri Jun 24 00:33:44 2016
@@ -400,10 +400,10 @@ public:
const FunctionDecl *FD) {
if (!prototype->isVariadic()) return All;
if (FD)
- additional += std::count_if(FD->param_begin(), FD->param_end(),
- [](const ParmVarDecl *PVD) {
- return PVD->hasAttr<PassObjectSizeAttr>();
- });
+ additional +=
+ llvm::count_if(FD->parameters(), [](const ParmVarDecl *PVD) {
+ return PVD->hasAttr<PassObjectSizeAttr>();
+ });
return RequiredArgs(prototype->getNumParams() + additional);
}
Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=273650&r1=273649&r2=273650&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Fri Jun 24 00:33:44 2016
@@ -1154,10 +1154,8 @@ void ASTDumper::VisitFunctionDecl(const
if (!D->param_begin() && D->getNumParams())
dumpChild([=] { OS << "<<NULL params x " << D->getNumParams() << ">>"; });
else
- for (FunctionDecl::param_const_iterator I = D->param_begin(),
- E = D->param_end();
- I != E; ++I)
- dumpDecl(*I);
+ for (const ParmVarDecl *Parameter : D->parameters())
+ dumpDecl(Parameter);
if (const CXXConstructorDecl *C = dyn_cast<CXXConstructorDecl>(D))
for (CXXConstructorDecl::init_const_iterator I = C->init_begin(),
@@ -1548,10 +1546,8 @@ void ASTDumper::VisitObjCMethodDecl(cons
if (D->isThisDeclarationADefinition()) {
dumpDeclContext(D);
} else {
- for (ObjCMethodDecl::param_const_iterator I = D->param_begin(),
- E = D->param_end();
- I != E; ++I)
- dumpDecl(*I);
+ for (const ParmVarDecl *Parameter : D->parameters())
+ dumpDecl(Parameter);
}
if (D->isVariadic())
Modified: cfe/trunk/lib/Frontend/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTConsumers.cpp?rev=273650&r1=273649&r2=273650&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTConsumers.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTConsumers.cpp Fri Jun 24 00:33:44 2016
@@ -290,13 +290,12 @@ void DeclContextPrinter::PrintDeclContex
// Print the parameters.
Out << "(";
bool PrintComma = false;
- for (FunctionDecl::param_const_iterator I = D->param_begin(),
- E = D->param_end(); I != E; ++I) {
+ for (ParmVarDecl *Parameter : D->parameters()) {
if (PrintComma)
Out << ", ";
else
PrintComma = true;
- Out << **I;
+ Out << *Parameter;
}
Out << ")";
@@ -320,13 +319,12 @@ void DeclContextPrinter::PrintDeclContex
// Print the parameters.
Out << "(";
bool PrintComma = false;
- for (FunctionDecl::param_const_iterator I = D->param_begin(),
- E = D->param_end(); I != E; ++I) {
+ for (ParmVarDecl *Parameter : D->parameters()) {
if (PrintComma)
Out << ", ";
else
PrintComma = true;
- Out << **I;
+ Out << *Parameter;
}
Out << ")";
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=273650&r1=273649&r2=273650&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Jun 24 00:33:44 2016
@@ -2961,11 +2961,11 @@ bool Sema::SemaBuiltinVAStartImpl(CallEx
// Get the last formal in the current function.
const ParmVarDecl *LastArg;
if (CurBlock)
- LastArg = *(CurBlock->TheDecl->param_end()-1);
+ LastArg = CurBlock->TheDecl->parameters().back();
else if (FunctionDecl *FD = getCurFunctionDecl())
- LastArg = *(FD->param_end()-1);
+ LastArg = FD->parameters().back();
else
- LastArg = *(getCurMethodDecl()->param_end()-1);
+ LastArg = getCurMethodDecl()->parameters().back();
SecondArgIsLastNamedArgument = PV == LastArg;
Type = PV->getType();
@@ -8499,7 +8499,7 @@ void Sema::DiagnoseAlwaysNonNullPointer(
}
if (const auto *FD = dyn_cast<FunctionDecl>(PV->getDeclContext())) {
- auto ParamIter = std::find(FD->param_begin(), FD->param_end(), PV);
+ auto ParamIter = llvm::find(FD->parameters(), PV);
assert(ParamIter != FD->param_end());
unsigned ParamNo = std::distance(FD->param_begin(), ParamIter);
Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=273650&r1=273649&r2=273650&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Fri Jun 24 00:33:44 2016
@@ -1150,8 +1150,8 @@ static void addFunctionPointerConversion
CXXMethodDecl *CallOperator) {
// This conversion is explicitly disabled if the lambda's function has
// pass_object_size attributes on any of its parameters.
- if (std::any_of(CallOperator->param_begin(), CallOperator->param_end(),
- std::mem_fn(&ParmVarDecl::hasAttr<PassObjectSizeAttr>)))
+ if (llvm::any_of(CallOperator->parameters(),
+ std::mem_fn(&ParmVarDecl::hasAttr<PassObjectSizeAttr>)))
return;
// Add the conversion to function pointer.
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=273650&r1=273649&r2=273650&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Jun 24 00:33:44 2016
@@ -39,8 +39,8 @@ using namespace clang;
using namespace sema;
static bool functionHasPassObjectSizeParams(const FunctionDecl *FD) {
- return std::any_of(FD->param_begin(), FD->param_end(),
- std::mem_fn(&ParmVarDecl::hasAttr<PassObjectSizeAttr>));
+ return llvm::any_of(FD->parameters(),
+ std::mem_fn(&ParmVarDecl::hasAttr<PassObjectSizeAttr>));
}
/// A convenience routine for creating a decayed reference to a function.
@@ -8935,8 +8935,8 @@ static bool checkAddressOfFunctionIsAvai
return false;
}
- auto I = std::find_if(FD->param_begin(), FD->param_end(),
- std::mem_fn(&ParmVarDecl::hasAttr<PassObjectSizeAttr>));
+ auto I = llvm::find_if(
+ FD->parameters(), std::mem_fn(&ParmVarDecl::hasAttr<PassObjectSizeAttr>));
if (I == FD->param_end())
return true;
Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=273650&r1=273649&r2=273650&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Fri Jun 24 00:33:44 2016
@@ -1019,9 +1019,8 @@ void ASTDeclWriter::VisitBlockDecl(Block
Record.AddStmt(D->getBody());
Record.AddTypeSourceInfo(D->getSignatureAsWritten());
Record.push_back(D->param_size());
- for (FunctionDecl::param_iterator P = D->param_begin(), PEnd = D->param_end();
- P != PEnd; ++P)
- Record.AddDeclRef(*P);
+ for (ParmVarDecl *P : D->parameters())
+ Record.AddDeclRef(P);
Record.push_back(D->isVariadic());
Record.push_back(D->blockMissingReturnType());
Record.push_back(D->isConversionFromLambda());
More information about the cfe-commits
mailing list