[LLVMdev] RFC: variable names

Joshua Cranmer ­čÉž Pidgeot18 at gmail.com
Mon Oct 13 17:31:21 PDT 2014

On 10/13/2014 6:08 PM, Richard Smith wrote:
> 1. Initialisms. It's common in Clang code (also in LLVM?) to use 
> initialisms as variable names. This doesn't really seem to work for 
> names that start with a lower case letter.

In my local use of LLVM code, I tend to follow a lowercase variable 
naming convention. However, I have taking to using Module *M, Function 
*F, Instruction *I, etc. At longer abbreviations... well, I use gep, 
lhs, rhs, but BB, GV, SI, LI, CI. I suppose my convention ends up being 
that I use upper-case letters if it's referring to the current thing 
being processed (and there is no ambiguity as to what is meant). Either 
that, or I do it only for 1- or 2-character initialisms. :-)

This does have the added benefit of making a distinction between i (the 
integer loop index count) and I (the current instruction being 
processed) exceptionally clear.

Joshua Cranmer
Thunderbird and DXR developer
Source code arch├Žologist

More information about the llvm-dev mailing list