New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 722563 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 quality problem: 3 spaces following #else

Project Member Reported by mcnee@chromium.org, May 15 2017

Issue description

clang-format produced code that (choose all that apply): 
- Doesn't match Chromium style
- Riles my finely honed stylistic dander

clang-format uses 3 spaces between #else and an end-of-line comment.
From the style guide: "end-of-line comments should be separated from the code by 2 spaces"

Here's the code before formatting:
#if BUILDFLAG(ENABLE_FOO)
    DoFoo();
#else  // !BUILDFLAG(ENABLE_FOO)  <-- 2 spaces before comment
    DoBar();
#endif  // BUILDFLAG(ENABLE_FOO)

Here's the code after formatting:
#if BUILDFLAG(ENABLE_FOO)
    DoFoo();
#else   // !BUILDFLAG(ENABLE_FOO)  <-- 3 spaces before comment
    DoBar();
#endif  // BUILDFLAG(ENABLE_FOO)

Here's how it ought to look:
(The code before formatting.)

Code review link for full files/context:
This was noticed in https://codereview.chromium.org/2874833002/diff/20001/chrome/browser/ui/tab_contents/core_tab_helper.cc

 

Comment 1 by thakis@chromium.org, May 15 2017

I guess it tries to align the comments maybe? Does it still do this if you don't put the commend after the #endif?

Comment 2 by thakis@chromium.org, May 15 2017

But if there's only 1 or 2 lines in between the #else I think you should just omit the comment; it adds more noise than it helps with readability.

Comment 3 by mcnee@chromium.org, May 15 2017

Without the #endif comment, it produces the correct spacing for the #else. So, yeah, it's probably alignment.
Components: Tools
Labels: clang-format

Sign in to add a comment