New issue
Advanced search Search tips

Issue 646352 link

Starred by 1 user

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

clang-format: wrong spacing for pointer-type multiple variable declaration

Project Member Reported by primiano@chromium.org, Sep 13 2016

Issue description

According to our code style [1]:
const uint8_t* cur, *next;

but clang-format does:
const uint8_t *cur, *next;

(note the spacing of * between uint8_t and cur).

Unsurprisingly most of the codebase today violates the code style and uses the clang-format way:
73 results for: type *x, *y [2]
3 results for: type* x, *y [3]


[1] https://google.github.io/styleguide/cppguide.html#Pointer_and_Reference_Expressions
"""
// These are fine, space following.
char* c;    // but remember to do "char* c, *d, *e, ...;"!
"""

[2] https://cs.chromium.org/search/?q=%5Cw%2B%5C+%5C*%5Cw%2B,%5C+%5C*%5Cw%2B+-f:third_party&sq=package:chromium&type=cs

[3] https://cs.chromium.org/search/?q=%5Cw%2B%5C*%5C+%5Cw%2B,%5C+%5C*%5Cw%2B+-f:third_party&sq=package:chromium&type=cs
 

Comment 1 by thakis@chromium.org, Sep 13 2016

I think I discussed this with djasper on IRC a while ago and IIRC he said "don't declare multiple things per line, it's confusing anyhow". I didn't realize the style guide explicitly mentions this though.

Comment 2 by thakis@chromium.org, Sep 21 2016

(current status: started a thread with the style folks; sound like they're going to recommend just a single decl per line if you declare a pointer or ref)
Components: Tools

Sign in to add a comment