LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 15169 - Put types consistently on the same line
Summary: Put types consistently on the same line
Status: NEW
Alias: None
Product: clang
Classification: Unclassified
Component: Formatter (show other bugs)
Version: unspecified
Hardware: PC Linux
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-05 13:04 PST by Tobias Grosser
Modified: 2021-04-12 22:09 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Grosser 2013-02-05 13:04:32 PST
Clang format does a good job in formatting the following global variable definitions by itself. However, the different decisions it takes for each makes it difficult to read a list of such definitions:

static cl::opt<unsigned>                                                        
MaxInsts("bb-vectorize-max-instr-per-group", cl::init(500), cl::Hidden,         
         cl::desc("The maximum number of pairable instructions per group"));    
                                                                                
static cl::opt<unsigned> MaxCandPairsForCycleCheck(                             
    "bb-vectorize-max-cycle-check-pairs", cl::init(200), cl::Hidden,            
    cl::desc("The maximum number of candidate pairs with which to use"          
             " a full cycle check"));                                           
                                                                                
static cl::opt<bool>                                                            
NoBools("bb-vectorize-no-bools", cl::init(false), cl::Hidden,                   
        cl::desc("Don't try to vectorize boolean (i1) values"));                
                                                                                
static cl::opt<bool> NoInts("bb-vectorize-no-ints", cl::init(false), cl::Hidden,
                            cl::desc("Don't try to vectorize integer values")); 
                                                                                
static cl::opt<bool>                                                            
NoFloats("bb-vectorize-no-floats", cl::init(false), cl::Hidden,              
         cl::desc("Don't try to vectorize floating-point values"));

In LLVM there exists both code that breaks after the type of the global and code that keeps
the variable name in the same line of the type. However, within one file I have never seen a mix here.

The very same is true for function definitions and their return types.

I believe choosing one strategy would increase overall readability.
Comment 1 NN 2021-04-12 22:09:50 PDT
https://clang.llvm.org/docs/ClangFormatStyleOptions.html

AlwaysBreakAfterReturnType