[LLVMdev] reducing indentation

reed kotler rkotler at mips.com
Thu May 9 14:30:18 PDT 2013


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:

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;
    ....
}
}





More information about the llvm-dev mailing list