[PATCH] D26943: [CodingStandards] Add style guide rule about "if" statements and loops.
Mehdi AMINI via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 22 08:39:35 PST 2016
mehdi_amini added subscribers: majnemer, mehdi_amini.
mehdi_amini added a comment.
In https://reviews.llvm.org/D26943#601963, @MatzeB wrote:
> > We do? Elsewhere in the style guide they have unbraced if/else, e.g. following "or better yet (in this case)".
>
> Ok, I grepped around llvm source and the majority of cases is indeed without braces. Then add this to the examples:
>
> if (I.isEven())
> handleEven(I);
> else
> handleOdd(I);
>
I'm OK with all this. But can you clarify for these:
if (I.isEven()) {
handleEven(I);
handleEven(I);
} else // Should we open a brace here?
handleOdd(I);
if (I.isEven()) // Should we open a brace here?
handleEven(I);
else {
handleOdd(I);
handleOdd(I);
}
I remember @majnemer asking for bracing both path when one is braced.
https://reviews.llvm.org/D26943
More information about the llvm-commits
mailing list