llvm-project/clang/lib/Format
Daniel Jasper 7ae41cdd22 Don't insert confusing line breaks in comparisons.
In general, clang-format breaks after an operator if the LHS spans
multiple lines. Otherwise, this can lead to confusing effects and
effectively hide the operator precendence, e.g. in

if (aaaaaaaaaaaaaa ==
        bbbbbbbbbbbbbb && c) { ...

This patch removes this rule for comparisons, if the LHS is not a binary
expression itself as many users were wondering why clang-format inserts
an unnecessary linebreak.

Before:
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) >
    5) { ...

After:
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) > 5) { ...

In the long run, we might:
- Want to do this for other binary expressions as well.
- Do this only if the RHS is short or even only if it is a literal.

llvm-svn: 185530
2013-07-03 10:34:47 +00:00
..
BreakableToken.cpp Use static for helper functions instead of an anonymous namespace per coding standards. 2013-07-01 03:38:29 +00:00
BreakableToken.h Don't remove backslashes from block comments. 2013-06-14 11:46:10 +00:00
CMakeLists.txt Unified token breaking logic for strings and block comments. 2013-04-15 14:28:00 +00:00
Encoding.h UTF-8 support for clang-format. 2013-06-05 14:09:10 +00:00
Format.cpp Don't insert confusing line breaks in comparisons. 2013-07-03 10:34:47 +00:00
FormatToken.h Use LLVM_DELETED_FUNCTION on unimplemented copy constructor and assignment operator. 2013-07-01 04:07:34 +00:00
Makefile
TokenAnnotator.cpp Fix formatting of long declarations with const type. 2013-07-02 09:47:29 +00:00
TokenAnnotator.h UTF-8 support for clang-format. 2013-06-05 14:09:10 +00:00
UnwrappedLineParser.cpp Fix incorrect token counting introduced by r185319. 2013-07-01 16:43:38 +00:00
UnwrappedLineParser.h Moved FormatToken to a separate header. 2013-06-03 16:45:03 +00:00
WhitespaceManager.cpp Don't align "} // namespace" comments. 2013-07-01 11:22:57 +00:00
WhitespaceManager.h Insert a space at the start of a line comment in case it starts with an alphanumeric character. 2013-06-11 16:01:49 +00:00