[PATCH] CodeGenPrep: rewrite a few loops in C++11 style

Duncan P. N. Exon Smith dexonsmith at apple.com
Thu Jan 8 12:30:43 PST 2015


(Once you have an LGTM, there's no need to repost a review, just
fix it offline and commit.)

Do you need someone to commit this for you?

> On 2015-Jan-08, at 12:29, Ramkumar Ramachandra <artagnon at gmail.com> wrote:
> 
> Fix nit pointed out by Duncan: `BasicBlock*` -> `BasicBlock *`.
> 
> 
> 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));
> +      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.17907.patch>





More information about the llvm-commits mailing list