Closed Bug 1222666 Opened 5 years ago Closed 5 years ago

./mach clang-format does not indent 'case' label in switch

Categories

(Firefox Build System :: Source Code Analysis, defect)

defect
Not set

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: TYLin, Unassigned)

References

(Blocks 1 open bug)

Details

According to the coding style example in mdn [1], the 'case' label in 'switch' statement should be indented, but clang-format will put the 'case' label at the same level of 'switch'.

[1] https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Control_Structures
You are probably using a very old version of clang-format. Can you check what you have installed with `clang-format --version`?

If you are using a recent version, where is the incorrectly formatted switch block?
I use ./mach clang-format, which uses the clang-format under "~/.mozbuild/clang-format-3.5".

If I delete the clang-format under ~/.mozbuild, it will prompt the following message to install for me. BTW, I need to add "import urllib2" to "tools/mach_commands.py" to avoid "global name 'urllib2' is not defined" exception.

./mach clang-format 
Download clang-format executables from https://people.mozilla.org/~ajones/clang-format/ (yN)? y
Downloading https://people.mozilla.org/~ajones/clang-format/darwin/clang-format-3.5 to /Users/tlin/.mozbuild/clang-format-3.5
Downloading https://people.mozilla.org/~ajones/clang-format/clang-format-diff-3.5 to /Users/tlin/.mozbuild/clang-format-diff-3.5

If I use the clang-format install from brew, the case label is formatted correctly. 
$ clang-format -version
clang-format version 3.8.0 (tags/google/testing/2015-07-31)

Perhaps we should update installation code so that mach installs the upstream version of the clang-format  after bug 961541 is landed. https://dxr.mozilla.org/mozilla-central/rev/e2a910c048dc82fc3be53475f18e7f81f03e377b/tools/mach_commands.py#307-309
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → WORKSFORME
Summary: clang-format does not indent 'case' label in switch → ./mach clang-format does not indent 'case' label in switch
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.