]> granicus.if.org Git - clang/commit
Change indentation when breaking after a type.
authorDaniel Jasper <djasper@google.com>
Mon, 6 May 2013 08:27:33 +0000 (08:27 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 6 May 2013 08:27:33 +0000 (08:27 +0000)
commit53e72cdcc0bc217cab33fa56858a0fe5b94ca453
treeb3991f8bbdda8776b6421feae5fd14ba7bbb6e19
parent10f6f065456a2cfb6c2ab5dfedefb930e5e52e9d
Change indentation when breaking after a type.

clang-format did not indent any declarations/definitions when breaking
after the type. With this change, it indents for all declarations but
does not indent for function definitions, i.e.:

Before:
const SomeLongTypeName&
some_long_variable_name;
typedef SomeLongTypeName
SomeLongTypeAlias;
const SomeLongReturnType*
SomeLongFunctionName();
const SomeLongReturnType*
SomeLongFunctionName() { ... }

After:
const SomeLongTypeName&
    some_long_variable_name;
typedef SomeLongTypeName
    SomeLongTypeAlias;
const SomeLongReturnType*
    SomeLongFunctionName();
const SomeLongReturnType*
SomeLongFunctionName() { ... }

While it might seem inconsistent to indent function declarations, but
not definitions, there are two reasons for that:
- Function declarations are very similar to declarations of function
type variables, so there is another side to consistency to consider.
- There can be many function declarations on subsequent lines and not
indenting can make them harder to identify. Function definitions
are already separated by their body and not indenting
makes the function name slighly easier to find.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181187 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/Format.cpp
lib/Format/TokenAnnotator.cpp
lib/Format/TokenAnnotator.h
unittests/Format/FormatTest.cpp