New issue
Advanced search Search tips

Issue 683022 link

Starred by 3 users

Issue metadata

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



Sign in to add a comment

git cl format should add parentheses if needs

Project Member Reported by yoichio@chromium.org, Jan 20 2017

Issue description

Suppose we have:
if (condition)
  longLongLongLine(blarblarblar,,,,)
else
  longLongLongLine(blarblarblar,,,,)

git cl format changes it to
if (condition)
  longLongLongLine(
    blarblarblar,,,,)
else
  longLongLongLine(
    blarblarblar,,,,)

However, both lines inside the if-else statement should be wrapped with parentheses.
 

Comment 1 by estaab@chromium.org, Jan 20 2017

Cc: thakis@chromium.org
Components: -Infra>Platform
Labels: Build-Tools
I take it this is for C++? I think this is something that needs to be addressed in with clang format.

Labeling as Build-Tools and cc'ing thakis@ as a best guess for where to triage this.

Comment 2 by thakis@chromium.org, Jan 22 2017

Cc: dcheng@chromium.org
Labels: clang-format
I thought we had a bug for this already, but I can't find it. dcheng might know what I mean.

clang-format (mostly) just does whitespace adjustment and doesn't add new tokens per original design. I think I also remember someone saying that this is a hard problem for some reason.

Comment 3 by dcheng@chromium.org, Jan 22 2017

This is filed upstream as https://llvm.org/bugs/show_bug.cgi?id=26215. I talked with djasper@ about implementing this, and it's definitely non-trivial. However, if someone's interested in poking at this, I have a few notes from djasper@ about how we could proceed. Otherwise... I'll try to poke at it when I have time, but it probably won't be soon =/
When we implement this, it'd be cool if clang-format could try to infer the {} style for single-line ifs (do they have braces or not) from other ifs in that file and then adapt that style, so that ifs in a file get a consistent style too.
Components: Tools

Sign in to add a comment