[PATCH] CodeGenPrep: rewrite a few loops in C++11 style
Duncan P. N. Exon Smith
dexonsmith at apple.com
Thu Jan 8 11:33:38 PST 2015
LGTM (with a nit). Let me know if you need me to commit it for you.
> On 2015-Jan-07, at 15:57, Ramkumar Ramachandra <artagnon at gmail.com> wrote:
>
> Revert last hunk. Thanks to Duncan.
>
>
> http://reviews.llvm.org/D6868
>
> Files:
> lib/CodeGen/CodeGenPrepare.cpp
>
> Index: lib/CodeGen/CodeGenPrepare.cpp
> ===================================================================
> --- lib/CodeGen/CodeGenPrepare.cpp
> +++ lib/CodeGen/CodeGenPrepare.cpp
> @@ -261,9 +261,9 @@
> if (!DisableBranchOpts) {
> MadeChange = false;
> SmallPtrSet<BasicBlock*, 8> WorkList;
> - for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
> - SmallVector<BasicBlock*, 2> Successors(succ_begin(BB), succ_end(BB));
> - MadeChange |= ConstantFoldTerminator(BB, true);
> + for (BasicBlock &BB : F) {
> + SmallVector<BasicBlock*, 2> Successors(succ_begin(&BB), succ_end(&BB));
Since you're touching this line, please change `BasicBlock*` to `BasicBlock *`.
(If you haven't yet integrated clang-format into your workflow, I strongly
recommend it.)
> + MadeChange |= ConstantFoldTerminator(&BB, true);
> if (!MadeChange) continue;
>
> for (SmallVectorImpl<BasicBlock*>::iterator
> @@ -4327,9 +4327,9 @@
> // find a node corresponding to the value.
> bool CodeGenPrepare::PlaceDbgValues(Function &F) {
> bool MadeChange = false;
> - for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) {
> + for (BasicBlock &BB : F) {
> Instruction *PrevNonDbgInst = nullptr;
> - for (BasicBlock::iterator BI = I->begin(), BE = I->end(); BI != BE;) {
> + for (BasicBlock::iterator BI = BB.begin(), BE = BB.end(); BI != BE;) {
> Instruction *Insn = BI; ++BI;
> DbgValueInst *DVI = dyn_cast<DbgValueInst>(Insn);
> // Leave dbg.values that refer to an alloca alone. These
>
> EMAIL PREFERENCES
> http://reviews.llvm.org/settings/panel/emailpreferences/
> <D6868.17878.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list