Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put types consistently on the same line #15541

Closed
tobiasgrosser opened this issue Feb 5, 2013 · 2 comments
Closed

Put types consistently on the same line #15541

tobiasgrosser opened this issue Feb 5, 2013 · 2 comments
Labels
bugzilla Issues migrated from bugzilla clang-format invalid Resolved as invalid, i.e. not a bug

Comments

@tobiasgrosser
Copy link
Contributor

tobiasgrosser commented Feb 5, 2013

Bugzilla Link 15169
Version unspecified
OS Linux
CC @NN--

Extended Description

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.

@NN--
Copy link
Mannequin

NN-- mannequin commented Apr 13, 2021

https://clang.llvm.org/docs/ClangFormatStyleOptions.html

AlwaysBreakAfterReturnType

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 4, 2021
@HazardyKnusperkeks
Copy link
Contributor

There is the mentioned option. And apart from that clang-format does have one strategy, it minimizes the penalty. Some penalty values can be configured.

So for your return type you can activate AlwaysBreakAfterReturnType or increase PenaltyReturnTypeOnItsOwnLine so that it basically never ends on its own line.

@HazardyKnusperkeks HazardyKnusperkeks closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2022
@HazardyKnusperkeks HazardyKnusperkeks added the invalid Resolved as invalid, i.e. not a bug label Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang-format invalid Resolved as invalid, i.e. not a bug
Projects
None yet
Development

No branches or pull requests

2 participants