[all-commits] [llvm/llvm-project] 072ae7: [clang-format] Always break line after enum openin...

MyDeveloperDay via All-commits all-commits at lists.llvm.org
Mon Apr 13 07:04:26 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 072ae7c1e64f8dd1b5e9db17838c93b150f8b487
      https://github.com/llvm/llvm-project/commit/072ae7c1e64f8dd1b5e9db17838c93b150f8b487
  Author: mydeveloperday <mydeveloperday at gmail.com>
  Date:   2020-04-13 (Mon, 13 Apr 2020)

  Changed paths:
    M clang/lib/Format/ContinuationIndenter.cpp
    M clang/unittests/Format/FormatTest.cpp

  Log Message:
  -----------
  [clang-format] Always break line after enum opening brace

Summary:
clang-format currently puts the first enumerator on the same line as the
enum keyword and opening brace if it fits (for example, for anonymous
enums if IndentWidth is 8):

  $ echo "enum { RED, GREEN, BLUE };" | clang-format -style="{BasedOnStyle: llvm, ColumnLimit: 15, IndentWidth: 8}"
  enum { RED,
         GREEN,
         BLUE };

This doesn't seem to be intentional, as I can't find any style guide that
suggests wrapping enums this way. Always force the enumerator to be on a new
line, which gets us the desired result:

  $ echo "enum { RED, GREEN, BLUE };" | ./bin/clang-format -style="{BasedOnStyle: llvm, ColumnLimit: 15, IndentWidth: 8}"
  enum {
          RED,
          GREEN,
          BLUE
  };

Test Plan:

New test added. Confirmed test failed without change and passed with change by
running:

  $ ninja FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewed By: MyDeveloperDay

Patch By: osandov

Tags: #clang-format, #clang

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




More information about the All-commits mailing list