[llvm] r250766 - CppBackend: Remove implicit ilist iterator conversions, NFC
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 19 17:06:41 PDT 2015
Author: dexonsmith
Date: Mon Oct 19 19:06:41 2015
New Revision: 250766
URL: http://llvm.org/viewvc/llvm-project?rev=250766&view=rev
Log:
CppBackend: Remove implicit ilist iterator conversions, NFC
Mostly just converted to range-based for loops. May have converted a
couple of extra loops as a drive-by (not sure).
Modified:
llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=250766&r1=250765&r2=250766&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original)
+++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Mon Oct 19 19:06:41 2015
@@ -1799,13 +1799,12 @@ void CppWriter::printFunctionBody(const
<< "->arg_begin();";
nl(Out);
}
- for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
- AI != AE; ++AI) {
- Out << "Value* " << getCppName(AI) << " = args++;";
+ for (const Argument &AI : F->args()) {
+ Out << "Value* " << getCppName(&AI) << " = args++;";
nl(Out);
- if (AI->hasName()) {
- Out << getCppName(AI) << "->setName(\"";
- printEscapedString(AI->getName());
+ if (AI.hasName()) {
+ Out << getCppName(&AI) << "->setName(\"";
+ printEscapedString(AI.getName());
Out << "\");";
nl(Out);
}
@@ -1814,29 +1813,25 @@ void CppWriter::printFunctionBody(const
// Create all the basic blocks
nl(Out);
- for (Function::const_iterator BI = F->begin(), BE = F->end();
- BI != BE; ++BI) {
- std::string bbname(getCppName(BI));
+ for (const BasicBlock &BI : *F) {
+ std::string bbname(getCppName(&BI));
Out << "BasicBlock* " << bbname <<
" = BasicBlock::Create(mod->getContext(), \"";
- if (BI->hasName())
- printEscapedString(BI->getName());
- Out << "\"," << getCppName(BI->getParent()) << ",0);";
+ if (BI.hasName())
+ printEscapedString(BI.getName());
+ Out << "\"," << getCppName(BI.getParent()) << ",0);";
nl(Out);
}
// Output all of its basic blocks... for the function
- for (Function::const_iterator BI = F->begin(), BE = F->end();
- BI != BE; ++BI) {
- std::string bbname(getCppName(BI));
- nl(Out) << "// Block " << BI->getName() << " (" << bbname << ")";
+ for (const BasicBlock &BI : *F) {
+ std::string bbname(getCppName(&BI));
+ nl(Out) << "// Block " << BI.getName() << " (" << bbname << ")";
nl(Out);
// Output all of the instructions in the basic block...
- for (BasicBlock::const_iterator I = BI->begin(), E = BI->end();
- I != E; ++I) {
- printInstruction(I,bbname);
- }
+ for (const Instruction &I : BI)
+ printInstruction(&I, bbname);
}
// Loop over the ForwardRefs and resolve them now that all instructions
@@ -1879,7 +1874,7 @@ void CppWriter::printInline(const std::s
printFunctionUses(F);
printFunctionBody(F);
is_inline = false;
- Out << "return " << getCppName(F->begin()) << ";";
+ Out << "return " << getCppName(&F->front()) << ";";
nl(Out) << "}";
nl(Out);
}
@@ -1892,17 +1887,14 @@ void CppWriter::printModuleBody() {
// Functions can call each other and global variables can reference them so
// define all the functions first before emitting their function bodies.
nl(Out) << "// Function Declarations"; nl(Out);
- for (Module::const_iterator I = TheModule->begin(), E = TheModule->end();
- I != E; ++I)
- printFunctionHead(I);
+ for (const Function &I : *TheModule)
+ printFunctionHead(&I);
// Process the global variables declarations. We can't initialze them until
// after the constants are printed so just print a header for each global
nl(Out) << "// Global Variable Declarations\n"; nl(Out);
- for (Module::const_global_iterator I = TheModule->global_begin(),
- E = TheModule->global_end(); I != E; ++I) {
- printVariableHead(I);
- }
+ for (const GlobalVariable &I : TheModule->globals())
+ printVariableHead(&I);
// Print out all the constants definitions. Constants don't recurse except
// through GlobalValues. All GlobalValues have been declared at this point
@@ -1914,21 +1906,18 @@ void CppWriter::printModuleBody() {
// been emitted. These definitions just couple the gvars with their constant
// initializers.
nl(Out) << "// Global Variable Definitions"; nl(Out);
- for (Module::const_global_iterator I = TheModule->global_begin(),
- E = TheModule->global_end(); I != E; ++I) {
- printVariableBody(I);
- }
+ for (const GlobalVariable &I : TheModule->globals())
+ printVariableBody(&I);
// Finally, we can safely put out all of the function bodies.
nl(Out) << "// Function Definitions"; nl(Out);
- for (Module::const_iterator I = TheModule->begin(), E = TheModule->end();
- I != E; ++I) {
- if (!I->isDeclaration()) {
- nl(Out) << "// Function: " << I->getName() << " (" << getCppName(I)
+ for (const Function &I : *TheModule) {
+ if (!I.isDeclaration()) {
+ nl(Out) << "// Function: " << I.getName() << " (" << getCppName(&I)
<< ")";
nl(Out) << "{";
nl(Out,1);
- printFunctionBody(I);
+ printFunctionBody(&I);
nl(Out,-1) << "}";
nl(Out);
}
More information about the llvm-commits
mailing list