[all-commits] [llvm/llvm-project] 14c044: [clang-format] Add IndentCaseBlocks option

MyDeveloperDay via All-commits all-commits at lists.llvm.org
Sun Jan 19 07:53:25 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 14c044756e771eb9160d5809b4381bdeb0fc210c
      https://github.com/llvm/llvm-project/commit/14c044756e771eb9160d5809b4381bdeb0fc210c
  Author: mydeveloperday <mydeveloperday at gmail.com>
  Date:   2020-01-19 (Sun, 19 Jan 2020)

  Changed paths:
    M clang/docs/ClangFormatStyleOptions.rst
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Format/Format.h
    M clang/lib/Format/Format.cpp
    M clang/lib/Format/UnwrappedLineParser.cpp
    M clang/unittests/Format/FormatTest.cpp

  Log Message:
  -----------
  [clang-format] Add IndentCaseBlocks option

Summary:
The documentation for IndentCaseLabels claimed that the "Switch
statement body is always indented one level more than case labels". This
is technically false for the code block immediately following the label.
Its closing bracket aligns with the start of the label.

If the case label are not indented, it leads to a style where the
closing bracket of the block aligns with the closing bracket of the
switch statement, which can be hard to parse.

This change introduces a new option, IndentCaseBlocks, which when true
treats the block as a scope block (which it technically is).

(Note: regenerated ClangFormatStyleOptions.rst using tools/dump_style.py)

Reviewed By: MyDeveloperDay

Patch By: capn

Tags: #clang-format, #clang

Differential Revision: https://reviews.llvm.org/D72276




More information about the All-commits mailing list