use early returns to simplify and de-nest

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171654 91177308-0d34-0410-b5e6-96231b3b80d8
Prepare for the upcoming version of Debian (jessie)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171655 91177308-0d34-0410-b5e6-96231b3b80d8
Clang docs: add some information about the difference between 'clang' and 'clang -cc1'

This is coming up again and again on the mailing list and IRC.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171656 91177308-0d34-0410-b5e6-96231b3b80d8
Fixes handling of unbalances braces.

If we find an unexpected closing brace, we must not stop parsing, as
we'd otherwise not layout anything beyond that point.

If we find a structural error on the highest level we'll not re-indent
anyway, but we'll still want to format within unwrapped lines.

Needed to introduce a differentiation between an expected and unexpected
closing brace.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171666 91177308-0d34-0410-b5e6-96231b3b80d8
ClangTools doc: add ideas for new tools in clang-tools-extra to ensure that
these ideas don't get lost


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171667 91177308-0d34-0410-b5e6-96231b3b80d8
Simplify. No behavior change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171680 91177308-0d34-0410-b5e6-96231b3b80d8
Switch to asking the target machine to add any relevant analysis passses
rather than doing it ourselves. This reflects the API changes in r171681.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171683 91177308-0d34-0410-b5e6-96231b3b80d8
PR14759: Improve/correct support for debug info for C++ member pointers.

Using added LLVM functionality in r171698. This works in GDB for member
variable pointers but not member function pointers. See the LLVM commit and
GDB bug 14998 for details.

Un-xfailing cases in the GDB 7.5 test suite will follow.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171699 91177308-0d34-0410-b5e6-96231b3b80d8
Put a higher penalty on breaking before "." or "->".

This fixes llvm.org/PR14823.

Before:
    local_state->SetString(prefs::kApplicationLocale, parent_local_state
                                ->GetString(prefs::kApplicationLocale));
After:
    local_state->SetString(
        prefs::kApplicationLocale,
        parent_local_state->GetString(prefs::kApplicationLocale));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171705 91177308-0d34-0410-b5e6-96231b3b80d8
Fix layouting of tokens with a leading escaped newline.

If a token follows directly on an escaped newline, the escaped newline
is stored with the token. Since we re-layout escaped newlines, we need
to treat them just like normal whitespace - thus, we need to increase
the whitespace-length of the token, while decreasing the token length
(otherwise the token length contains the length of the escaped newline
and we double-count it while indenting).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171706 91177308-0d34-0410-b5e6-96231b3b80d8
Fix layouting of single-line-comments preceded by an escaped newline.

Previously, we'd format
  int i;\
  // comment
as
  int i; // comment

The problem is that the escaped newline is part of the next token, and
thus the raw token text of the comment doesn't start with "//".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171713 91177308-0d34-0410-b5e6-96231b3b80d8
Do not ever allow using the full line in preprocessor directives.

We would format:
  #define A \
    int f(a); int i;
as
  #define A \
    int f(a);\
    int i

The fix will break up macro definitions that could fit a line, but hit
the last column; fixing that is more involved, though, as it requires
looking at the following line.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171715 91177308-0d34-0410-b5e6-96231b3b80d8
Remove outdated fixme.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171716 91177308-0d34-0410-b5e6-96231b3b80d8
Remove outdated FIXME and add explanation for error handling strategy
while parsing #define's.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171717 91177308-0d34-0410-b5e6-96231b3b80d8
CFG.cpp: Fix wrapping logic when printing block preds/succs.

First check only wrapped with i==8, second wrapped at i==2,8,18,28,...
This fix restores the intended behavior: i==8,18,28,...

Found with -fsanitize=integer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171718 91177308-0d34-0410-b5e6-96231b3b80d8
Fix incorrect FIXME.

The case that we wanted to write a test for cannot happen, as the
UnwrappedLineParser already protects against it. Added an assert to
prevent regressions of that assumption.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171720 91177308-0d34-0410-b5e6-96231b3b80d8
Do not break before "0" in pure virtual function declarations.

Before:
virtual void write(ELFWriter *writer, OwningPtr<FileOutputBuffer> &buffer) =
    0

After:
virtual void write(ELFWriter *writerrr,
                   OwningPtr<FileOutputBuffer> &buffer) = 0;

This addresses llvm.org/PR14815.

To implement this I introduced a line type during parsing and moved the
definition of TokenType out of the struct for increased readability.
Should have done the latter in a separate patch, but it would be hard to
pull apart now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171724 91177308-0d34-0410-b5e6-96231b3b80d8
Add style option for number of spaces before trailing comments.

In LLVM style, a single space should be enough. In Google style, two
spaces are required.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171725 91177308-0d34-0410-b5e6-96231b3b80d8
Prefer not to break after assignments.

This addresses llvm.org/PR14830.

Before:
unsigned Cost =
    TTI.getMemoryOpCost(I->getOpcode(), VectorTy, SI->getAlignment(),
                        SI->getPointerAddressSpace());
CharSourceRange LineRange =
    CharSourceRange::getTokenRange(TheLine.Tokens.front().Tok.getLocation(),
                                   TheLine.Tokens.back().Tok.getLocation());

After:
unsigned Cost = TTI.getMemoryOpCost(I->getOpcode(), VectorTy,
                                    SI->getAlignment(),
                                    SI->getPointerAddressSpace());
CharSourceRange LineRange = CharSourceRange::getTokenRange(
                                TheLine.Tokens.front().Tok.getLocation(),
                                TheLine.Tokens.back().Tok.getLocation());

This required rudimentary changes to static initializer lists, but we
are not yet formatting them in a reasonable way. That will be done in a
subsequent patch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171731 91177308-0d34-0410-b5e6-96231b3b80d8
Reformat clang-formats source code.

All changes done by clang-format itself. No functional changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171732 91177308-0d34-0410-b5e6-96231b3b80d8