History log of /llvm-project/clang/unittests/Format/FormatTest.cpp (Results 1976 – 2000 of 2034)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 8d1832e0 07-Jan-2013 Daniel Jasper <djasper@google.com>

Reformat clang-formats source code.

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

llvm-svn: 171732


# 206df734 07-Jan-2013 Daniel Jasper <djasper@google.com>

Prefer not to break after assignments.

This addresses llvm.org/PR14830.

Before:
unsigned Cost =
TTI.getMemoryOpCost(I->getOpcode(), VectorTy, SI->getAlignment(),
SI->get

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.

llvm-svn: 171731

show more ...


# 5ad1e199 07-Jan-2013 Daniel Jasper <djasper@google.com>

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.

llvm-svn: 171725


# da16db3f 07-Jan-2013 Daniel Jasper <djasper@google.com>

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 *writer

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.

llvm-svn: 171724

show more ...


# 7872571f 07-Jan-2013 Manuel Klimek <klimek@google.com>

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.

ll

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.

llvm-svn: 171720

show more ...


# 38ba11e4 07-Jan-2013 Manuel Klimek <klimek@google.com>

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 definitio

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.

llvm-svn: 171715

show more ...


# c74d2922 07-Jan-2013 Manuel Klimek <klimek@google.com>

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 ne

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 "//".

llvm-svn: 171713

show more ...


# ef920699 07-Jan-2013 Manuel Klimek <klimek@google.com>

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

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).

llvm-svn: 171706

show more ...


# c7345ccc 07-Jan-2013 Daniel Jasper <djasper@google.com>

Put a higher penalty on breaking before "." or "->".

This fixes llvm.org/PR14823.

Before:
local_state->SetString(prefs::kApplicationLocale, parent_local_state
->

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));

llvm-svn: 171705

show more ...


# 1058d987 06-Jan-2013 Manuel Klimek <klimek@google.com>

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

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.

llvm-svn: 171666

show more ...


# 52d0fd89 05-Jan-2013 Manuel Klimek <klimek@google.com>

Fixes parsing of hash tokens in the middle of a line.

To parse # correctly, we need to know whether it is the first token in a
line - we can deduct this either from the whitespace or seeing that the

Fixes parsing of hash tokens in the middle of a line.

To parse # correctly, we need to know whether it is the first token in a
line - we can deduct this either from the whitespace or seeing that the
token is the first in the file - we already calculate this information.
This patch moves the identification of the first token into the
getNextToken method and stores it inside the FormatToken, so the
UnwrappedLineParser can stay independent of the SourceManager.

llvm-svn: 171640

show more ...


# ef2cfb11 05-Jan-2013 Manuel Klimek <klimek@google.com>

Fixes PR14801 - preprocessor directives shouldn't be indented

Uses indent 0 for macros for now and resets the indent state to the
level prior to the preprocessor directive.

llvm-svn: 171639


# 09e07979 05-Jan-2013 Manuel Klimek <klimek@google.com>

Fixes PR14811: Crash when formatting some macros

A preprocessor directive cannot be started while we're parsing one.

llvm-svn: 171635


# 1abf789c 04-Jan-2013 Manuel Klimek <klimek@google.com>

Various fixes to clang-format's macro handling.

Some of this is still pretty rough (note the load of FIXMEs), but it is
strictly an improvement and fixes various bugs that were related to
macro proc

Various fixes to clang-format's macro handling.

Some of this is still pretty rough (note the load of FIXMEs), but it is
strictly an improvement and fixes various bugs that were related to
macro processing but are also imporant in non-macro use cases.

Specific fixes:
- correctly puts espaced newlines at the end of the line
- fixes counting of white space before a token when escaped newlines are
present
- fixes parsing of "trailing" tokens when eof() is hit
- puts macro parsing orthogonal to parsing other structure
- general support for parsing of macro definitions

Due to the fix to format trailing tokens, this change also includes a
bunch of fixes to the c-index tests.

llvm-svn: 171556

show more ...


# 3c2557d0 04-Jan-2013 Daniel Jasper <djasper@google.com>

Correctly format dereference and address of in array parameters.

Before: InvalidRegions[ &R] = 0;
After: InvalidRegions[&R] = 0;

This fixes llvm.org/PR14793

llvm-svn: 171522


# c0880a90 04-Jan-2013 Daniel Jasper <djasper@google.com>

Let the formatter ignore UnwrappedLines containing errors.

This prevents code like:

namespace {
class Foo {
Foo(
};
} // comment

from causing segfaults (see llvm.org/PR14774).

llvm-svn: 1714

Let the formatter ignore UnwrappedLines containing errors.

This prevents code like:

namespace {
class Foo {
Foo(
};
} // comment

from causing segfaults (see llvm.org/PR14774).

llvm-svn: 171495

show more ...


# b69e3c62 02-Jan-2013 Manuel Klimek <klimek@google.com>

Fixes multiple formatting bugs.

Fixes:
- incorrect handling of multiple consecutive preprocessor directives
- crash when trying to right align the escpaed newline for a line that
is longer than th

Fixes multiple formatting bugs.

Fixes:
- incorrect handling of multiple consecutive preprocessor directives
- crash when trying to right align the escpaed newline for a line that
is longer than the column limit
- using only ColumnLimit-1 columns when layouting with escaped newlines
inside preprocessor directives

llvm-svn: 171401

show more ...


# 90e51fdb 02-Jan-2013 Daniel Jasper <djasper@google.com>

Don't allow line breaks after template parameters.

This fixes llvm.org/PR14786.

We will need to split there as a last resort, but that should be done
consistently independent of whether the type is

Don't allow line breaks after template parameters.

This fixes llvm.org/PR14786.

We will need to split there as a last resort, but that should be done
consistently independent of whether the type is a template type or not.

Before:
template <typename T>
aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa<T>
::aaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
template <typename T>
aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 171400

show more ...


# 3c0431c8 02-Jan-2013 Daniel Jasper <djasper@google.com>

Format */& as binary operator if followed by a unary operator.

This fixes llvm.org/PR14687.
Also fixes segfault for lines starting with * or &.

Before:
a *~b;
*a = 1; // <- this segfaulted

After:

Format */& as binary operator if followed by a unary operator.

This fixes llvm.org/PR14687.
Also fixes segfault for lines starting with * or &.

Before:
a *~b;
*a = 1; // <- this segfaulted

After:
a * ~b;
*a = 1; // no segfault :-)

llvm-svn: 171396

show more ...


# a71e5d81 02-Jan-2013 Manuel Klimek <klimek@google.com>

Fixes use of unescaped newlines when formatting preprocessor directives.

This is the first step towards handling preprocessor directives. This
patch only fixes the most pressing issue, namely correc

Fixes use of unescaped newlines when formatting preprocessor directives.

This is the first step towards handling preprocessor directives. This
patch only fixes the most pressing issue, namely correctly escaping
newlines for tokens within a sequence of a preprocessor directive.

The next step will be to fix incorrect format decisions on #define
directives.

llvm-svn: 171393

show more ...


# 542de16e 02-Jan-2013 Daniel Jasper <djasper@google.com>

Correctly format pointers and references in casts.

This fixes llvm.org/PR14747.

Before: Type *A = (Type * ) P;
After: Type *A = (Type *) P;
llvm-svn: 171390


# da1c68ab 02-Jan-2013 Daniel Jasper <djasper@google.com>

Understand unary operators after "return" and "case".

This fixes llvm.org/PR14746.

Before: return - 1;
After: return -1;
llvm-svn: 171389


# ac5c1c28 02-Jan-2013 Daniel Jasper <djasper@google.com>

Prefer splitting after "template <...>" and fix indentation.

This addresses llvm.org/PR14699

Before:
template <typename T>
void looooooooooooooooooooooongFunction(int Param1, int Param2);
templ

Prefer splitting after "template <...>" and fix indentation.

This addresses llvm.org/PR14699

Before:
template <typename T>
void looooooooooooooooooooooongFunction(int Param1, int Param2);
template <typename T> void looooooooooooooooooooongFunction(
int Paaaaaaaaaaaaaaaaaaaaram1, int Paaaaaaaaaaaaaaaaaaaaram2);

After:
template <typename T>
void looooooooooooooooooooooongFunction(int Param1, int Param2);
template <typename T>
void looooooooooooooooooooongFunction(int Paaaaaaaaaaaaaaaaaaaaram1,
int Paaaaaaaaaaaaaaaaaaaaram2);

llvm-svn: 171388

show more ...


# 3d0c75cc 02-Jan-2013 Daniel Jasper <djasper@google.com>

Prefer to break after operators over breaking after "(".

Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
aaaaaaaaaaaa

Prefer to break after operators over breaking after "(".

Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 171386

show more ...


# 22bcf8a8 02-Jan-2013 Daniel Jasper <djasper@google.com>

Understand * and & in ternary expressions.

Before: "int a = b ? *c : * d;"
After: "int a = b ? *c : *d;
llvm-svn: 171358


1...<<71727374757677787980>>...82