<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">AFAIK we don’t have a column limit. I certainly don’t enforce one on myself, though I break lines when they don’t “look nice” anymore.<div class="">I try to stick with a separator between the function name and the open parenthesis when declaring a function/method but not when calling one. I try to add spaces after “for”, “if”, “while”, “switch,” etc.</div><div class=""><div class="">In general I prefer to wrap even single line for/else blocks in braces, but in code where pre-existing logic doesn’t have braces, I’ll follow suit. (This is particularly prevalent when using logs: if(log) log->Printf(“…”);)</div><div class=""><br class=""></div><div class="">As far as case statements:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">switch (foo) {</font></div><div class=""><font face="Menlo" class="">case A:</font></div><div class=""><font face="Menlo" class=""> {</font></div><div class=""><font face="Menlo" class=""> }</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><br class=""></div><div class="">is what I’d prefer. It really bugs me when there isn’t a clean staircase of close-braces.</div><div class=""><br class=""></div><div class="">For instance variables of a class, I try to align them on a 4-space tab, and the * in a pointer or & in a reference sticks with the name and extends to the left of the alignment tab, e.g.:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">A m_a</font></div><div class=""><font face="Menlo" class="">B *m_b</font></div><div class=""><br class=""></div><div class=""><div class="">Enrico’s point about naming applies here, too: m_ should mean an instance variable and g_ should mean a global (or class-level static).</div><div class="">In general, if I use a std::vector or std::map in a class, I’ll typedef it so that making iterators etc. doesn’t look horrid. Unless the expression on the right hand side has its type explicitly named (typically in a cast, but I’d accept a constructor too) I do not use the “auto” keyword.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">
<div class="">Sean</div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Aug 19, 2014, at 10:16 AM, Zachary Turner <<a href="mailto:zturner@google.com" class="">zturner@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I brought this up in a thread on lldb-commits, but since it is of more general interest, I want to make a thread here as well.<div class=""><br class=""></div><div class="">Can we have clear direction on LLDB coding style? Ideally in the form of an update to <a href="http://lldb.llvm.org/" class="">lldb.llvm.org</a>, but as that might require a little more effort, even some details in a response to this thread would be a help. Some things I've deduced from looking at the code, and other things I'm not so sure about, because of inconsistencies in the code or just no clear rule.</div>
<div class=""><br class=""></div><div class="">Indentation width: 4</div><div class="">Column limit: 140 (does this apply to comments too? Most function-declaration comments seem to wrap at 80)</div><div class="">Brace style: Allman</div><div class=""> if (foo)</div><div class="">
{</div><div class=""> // code here</div><div class=""> }</div><div class=""><br class=""></div><div class="">Break after function return type: Always, only on declarations, only on definitions, only in headers, or never?</div><div class=""><br class=""></div><div class="">Space before function parentheses: When?</div>
<div class=""><br class=""></div><div class="">Indent case labels inside switch: A or B below?</div><div class=""> switch (foo)</div><div class=""> {</div><div class=""> case A:</div><div class=""> case B:</div><div class=""> }</div><div class=""><br class=""></div><div class="">Indent braces inside of a case: A or B below?</div>
<div class=""> switch (foo)</div><div class=""> {</div><div class=""> case A:</div><div class=""> {</div><div class=""> }</div><div class=""> case B:</div><div class=""> {</div><div class=""> }</div><div class=""> }</div><div class=""><br class=""></div><div class="">Any other rules I should be cognizant of?</div>
</div>
_______________________________________________<br class="">lldb-dev mailing list<br class=""><a href="mailto:lldb-dev@cs.uiuc.edu" class="">lldb-dev@cs.uiuc.edu</a><br class="">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev<br class=""></div></blockquote></div><br class=""></div></div></body></html>