[LLVMdev] reducing indentation

Caldarale, Charles R Chuck.Caldarale at unisys.com
Thu May 9 15:24:53 PDT 2013


> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
> On Behalf Of reed kotler
> Subject: [LLVMdev] reducing indentation

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

Just personal opinion, but that's bloody horrible - an accident waiting to happen.  It would be far too easy to misinterpret the second for as not being the target of some outer construct, and erroneously add code between the two for statements.  What would be worse is when someone decides to add a comment preceding the second for statement, making it even easier to commit a blunder.  (This is not idle speculation - I had to fix a Linux kernel bug caused by this exact scenario.)

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

Two closing braces in the same column?  You can't be serious.  That's as bad as the convoluted syntax for anonymous internal classes in Java.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.





More information about the llvm-dev mailing list