[LLVMdev] reducing indentation

David Blaikie dblaikie at gmail.com
Thu May 9 15:29:52 PDT 2013


On Thu, May 9, 2013 at 2:30 PM, reed kotler <rkotler at mips.com> wrote:
> It occurred to me that a lot of times there is indendation with looping with
> no intervening code, other than the for loops themselves.
>
> For example:
>
>  for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
>     for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
>        Instruction &Inst = *I;
>        .....
>
>
> It would seem that this would better to be just:

Makes it harder to keep track of how many levels of
indentation/bracing are involved. Generally if anyone finds they're
running out of horizontal real estate due to indentation, that should
be a sign they might want to break out some portions of the code into
smaller functions or otherwise restructure the code.

>
> for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
> for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
>    Instruction &Inst = *I;
>    ....
>
>
> Even if there was some code after the first "for", it could be indented but
> still
> the following "for" could appear as is.
>
> For example:
>
> for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
>     xyz();
> for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
>    Instruction &Inst = *I;
>    ....
> }
> }
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list