[PATCH] D82594: Clarify a bit the guideline on omitting braces, including more examples (NFC)

Chris Lattner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 1 22:11:13 PDT 2020


lattner added inline comments.


================
Comment at: llvm/docs/CodingStandards.rst:1657
+  if (auto *D = dyn_cast<FunctionDecl>(D)) {
+    if(shouldProcess(D))
+      handleVarDecl(D);
----------------
mehdi_amini wrote:
> lattner wrote:
> > MaskRay wrote:
> > > Add a space after `if`
> > and after the for.  Also, I'd recommend using size_t instead of 'int', and != instead of <.  
> Why the `size_t` here? I thought best practice was rather to write for loops with `int`?
size_t is technically correct and the best type to use.  LLVM historically has used 'unsigned' for most counted loops (this was my fault) which isn't great for induction variable optimizations on 64-bit machines.  "int" is better for 64-bit machines because UB-on-overflow permits the important transformations, but this is technically incorrect and there is no obvious reason to prefer it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82594/new/

https://reviews.llvm.org/D82594





More information about the llvm-commits mailing list