Commit Graph

2607 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith 030d7d6daa Reapply "Modules: Cache PCMs in memory and avoid a use-after-free"
This reverts commit r298185, effectively reapplying r298165, after fixing the
new unit tests (PR32338).  The memory buffer generator doesn't null-terminate
the MemoryBuffer it creates; this version of the commit informs getMemBuffer
about that to avoid the assert.

Original commit message follows:

----

Clang's internal build system for implicit modules uses lock files to
ensure that after a process writes a PCM it will read the same one back
in (without contention from other -cc1 commands).  Since PCMs are read
from disk repeatedly while invalidating, building, and importing, the
lock is not released quickly.  Furthermore, the LockFileManager is not
robust in every environment.  Other -cc1 commands can stall until
timeout (after about eight minutes).

This commit changes the lock file from being necessary for correctness
to a (possibly dubious) performance hack.  The remaining benefit is to
reduce duplicate work in competing -cc1 commands which depend on the
same module.  Follow-up commits will change the internal build system to
continue after a timeout, and reduce the timeout.  Perhaps we should
reconsider blocking at all.

This also fixes a use-after-free, when one part of a compilation
validates a PCM and starts using it, and another tries to swap out the
PCM for something new.

The PCMCache is a new type called MemoryBufferCache, which saves memory
buffers based on their filename.  Its ownership is shared by the
CompilerInstance and ModuleManager.

- The ModuleManager stores PCMs there that it loads from disk, never
touching the disk if the cache is hot.

- When modules fail to validate, they're removed from the cache.

- When a CompilerInstance is spawned to build a new module, each
already-loaded PCM is assumed to be valid, and is frozen to avoid
the use-after-free.

- Any newly-built module is written directly to the cache to avoid the
round-trip to the filesystem, making lock files unnecessary for
correctness.

Original patch by Manman Ren; most testcases by Adrian Prantl!

llvm-svn: 298278
2017-03-20 17:58:26 +00:00
Renato Golin f1966cf646 Revert "Modules: Cache PCMs in memory and avoid a use-after-free"
This reverts commit r298165, as it broke the ARM builds.

llvm-svn: 298185
2017-03-18 12:31:32 +00:00
Duncan P. N. Exon Smith 079c40e886 Modules: Cache PCMs in memory and avoid a use-after-free
Clang's internal build system for implicit modules uses lock files to
ensure that after a process writes a PCM it will read the same one back
in (without contention from other -cc1 commands).  Since PCMs are read
from disk repeatedly while invalidating, building, and importing, the
lock is not released quickly.  Furthermore, the LockFileManager is not
robust in every environment.  Other -cc1 commands can stall until
timeout (after about eight minutes).

This commit changes the lock file from being necessary for correctness
to a (possibly dubious) performance hack.  The remaining benefit is to
reduce duplicate work in competing -cc1 commands which depend on the
same module.  Follow-up commits will change the internal build system to
continue after a timeout, and reduce the timeout.  Perhaps we should
reconsider blocking at all.

This also fixes a use-after-free, when one part of a compilation
validates a PCM and starts using it, and another tries to swap out the
PCM for something new.

The PCMCache is a new type called MemoryBufferCache, which saves memory
buffers based on their filename.  Its ownership is shared by the
CompilerInstance and ModuleManager.

  - The ModuleManager stores PCMs there that it loads from disk, never
    touching the disk if the cache is hot.

  - When modules fail to validate, they're removed from the cache.

  - When a CompilerInstance is spawned to build a new module, each
    already-loaded PCM is assumed to be valid, and is frozen to avoid
    the use-after-free.

  - Any newly-built module is written directly to the cache to avoid the
    round-trip to the filesystem, making lock files unnecessary for
    correctness.

Original patch by Manman Ren; most testcases by Adrian Prantl!

llvm-svn: 298165
2017-03-17 22:55:13 +00:00
Martin Probst c9c51c4e41 [clang-format] disable adding extra space after MSVC '__super' keyword
clang-format treats MSVC `__super` keyword like all other keywords adding
a single space after. This change disables this behavior for `__super`.

Patch originally by jutocz (thanks!).

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

llvm-svn: 297936
2017-03-16 10:21:35 +00:00
Daniel Jasper 04bbda9923 clang-format: Fix bug in wrapping behavior of operators.
Before (even violating the column limit):
  auto Diag =
      diag()
      << aaaaaaaaaaaaaaaa(aaaaaaaaaaaa, aaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
  auto Diag = diag() << aaaaaaaaaaaaaaaa(aaaaaaaaaaaa, aaaaaaaaaaaaa,
                                         aaaaaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 297931
2017-03-16 07:54:11 +00:00
Aaron Ballman 9fd6ee6a78 Add AST matchers for ObjCProtocolDecl, ObjCCategoryDecl, ObjCMethodDecl, ObjCIvarDecl, and ObjCPropertyDecl.
Patch by Dave Lee.

llvm-svn: 297882
2017-03-15 20:14:25 +00:00
Juergen Ributzka 53fda3996c Add more debugging code for the SystemZ bot.
llvm-svn: 297759
2017-03-14 17:46:26 +00:00
Daniel Jasper c79e4d2d25 clang-format: Make it very slighly more expensive to wrap between "= {".
This prevents unwanted fallout from r296664. Specifically in proto formatting,
this changed:
  optional Aaaaaaaa aaaaaaaa = 12 [
    (aaa) = aaaa,
    (bbbbbbbbbbbbbbbbbbbbbbbbbb) = {
      aaaaaaaaaaaaaaaaa: true,
      aaaaaaaaaaaaaaaa: true
    }
  ];

Into:
  optional Aaaaaaaa aaaaaaaa = 12 [
    (aaa) = aaaa,
    (bbbbbbbbbbbbbbbbbbbbbbbbbb) =
        {aaaaaaaaaaaaaaaaa: true, aaaaaaaaaaaaaaaa: true}
  ];

Which is considered less readable. Generally, it seems preferable to
format such dict literals as blocks rather than contract them to one
line.

llvm-svn: 297696
2017-03-14 00:40:32 +00:00
Juergen Ributzka f978743907 Reapply [VFS] Ignore broken symlinks in the directory iterator.
Modified the tests to accept any iteration order, to run only on Unix, and added
additional error reporting to investigate SystemZ bot issue.

The VFS directory iterator and recursive directory iterator behave differently
from the LLVM counterparts. Once the VFS iterators hit a broken symlink they
immediately abort. The LLVM counterparts don't stat entries unless they have to
descend into the next directory, which allows to recover from this issue by
clearing the error code and skipping to the next entry.

This change adds similar behavior to the VFS iterators. There should be no
change in current behavior in the current CLANG source base, because all
clients have loop exit conditions that also check the error code.

This fixes rdar://problem/30934619.

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

llvm-svn: 297693
2017-03-14 00:14:40 +00:00
Martin Probst b4cdb65e5f clang-format: [JS] do not wrap @see tags.
Summary:
@see is special among JSDoc tags in that it is commonly followed by URLs. The JSDoc spec suggests that users should wrap URLs in an additional {@link url...} tag (@see http://usejsdoc.org/tags-see.html), but this is very commonly violated, with @see being followed by a "naked" URL.

This change special cases all JSDoc lines that contain an @see not to be wrapped to account for that.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 297607
2017-03-13 09:39:23 +00:00
Martin Probst 22b8d26924 clang-format: [JS] allow breaking after non-null assertions.
Summary:
Previously clang-format would not break after any !. However in TypeScript, ! can be used as a post fix operator for non-nullability:
    x.foo()!.bar()!;

With this change, clang-format will wrap after the ! if it is likely a post-fix non null operator.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 297606
2017-03-13 09:14:23 +00:00
Martin Probst b98ab89ebb clang-format: [JS] do not wrap after interface and type.
Summary:
`interface` and `type` are pseudo keywords and cause automatic semicolon
insertion when followed by a line break:

    interface  // gets parsed as a long variable access to "interface"
        VeryLongInterfaceName {

    }

With this change, clang-format not longer wraps after `interface` or `type`.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 297605
2017-03-13 07:10:18 +00:00
Juergen Ributzka 31d01baa9f Revert "Reapply [VFS] Ignore broken symlinks in the directory iterator."
Still broken on Windows and SystemZ bot ... sorry for the noise.

llvm-svn: 297533
2017-03-11 00:14:50 +00:00
Juergen Ributzka c28c7e5bd3 Adding debug output to investigate systemz bot issue.
llvm-svn: 297531
2017-03-11 00:01:24 +00:00
Juergen Ributzka 46541f1b0b Reapply [VFS] Ignore broken symlinks in the directory iterator.
Modified the tests to accept any iteration order.

The VFS directory iterator and recursive directory iterator behave differently
from the LLVM counterparts. Once the VFS iterators hit a broken symlink they
immediately abort. The LLVM counterparts allow to recover from this issue by
clearing the error code and skipping to the next entry.

This change adds the same functionality to the VFS iterators. There should be
no change in current behavior in the current CLANG source base, because all
clients have loop exit conditions that also check the error code.

This fixes rdar://problem/30934619.

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

llvm-svn: 297528
2017-03-10 22:49:04 +00:00
Juergen Ributzka bc1c5b1d04 Revert r297510 "[VFS] Ignore broken symlinks in the directory iterator."
The tests are failing on one of the bots.

llvm-svn: 297517
2017-03-10 21:46:51 +00:00
Juergen Ributzka fd958fca0b [VFS] Ignore broken symlinks in the directory iterator.
The VFS directory iterator and recursive directory iterator behave differently
from the LLVM counterparts. Once the VFS iterators hit a broken symlink they
immediately abort. The LLVM counterparts allow to recover from this issue by
clearing the error code and skipping to the next entry.

This change adds the same functionality to the VFS iterators. There should be
no change in current behavior in the current CLANG source base, because all
clients have loop exit conditions that also check the error code.

This fixes rdar://problem/30934619.

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

llvm-svn: 297510
2017-03-10 21:23:27 +00:00
Andi-Bogdan Postelnicu 0ef8ee19f8 [clang-format] Add option to break before inheritance separation operator in class declaration.
Differential Revision: https://reviews.llvm.org/D30487

llvm-svn: 297467
2017-03-10 15:10:37 +00:00
Eric Liu 373c182a07 Add missing implementation for AtomicChange::replace(...)
Summary: Just realized the implementation is missing...

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 297289
2017-03-08 15:53:10 +00:00
Krasimir Georgiev bc05ebaa5a [clang-format] Look at NoLineBreak and NoLineBreakInOperand before breakProtrudingToken
Summary:
This patch makes ContinuationIndenter call breakProtrudingToken only if
NoLineBreak and NoLineBreakInOperand is false.

Previously, clang-format required two runs to converge on the following example with 24 columns:
Note that the second operand shouldn't be splitted according to NoLineBreakInOperand, but the
token breaker doesn't take that into account:
```
func(a, "long long long long", c);
```
After first run:
```
func(a, "long long "
        "long long",
         c);
```
After second run, where NoLineBreakInOperand is taken into account:
```
func(a,
     "long long "
     "long long",
     c);
```

With the patch, clang-format now obtains in one run:
```
func(a,
     "long long long"
     "long",
     c);
```
which is a better token split overall.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 297274
2017-03-08 12:54:50 +00:00
Daniel Jasper 628dd85b32 clang-format: Get slightly better at understanding */&.
Before:
  void f() { MACRO(A * const a); }

After:
  void f() { MACRO(A *const a); }

llvm-svn: 297268
2017-03-08 09:49:12 +00:00
Krasimir Georgiev 17725d8391 [clang-format] Enable comment reflowing in multiline comments containing pragmas
Summary:
This patch enables comment reflowing of lines not matching the comment pragma regex
in multiline comments containing comment pragma lines. Previously, these comments
were dumped without being reindented to the result.

Reviewers: djasper, mprobst

Reviewed By: mprobst

Subscribers: klimek, mprobst, cfe-commits

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

llvm-svn: 297261
2017-03-08 08:55:12 +00:00
Andi-Bogdan Postelnicu 4743e2d9b9 [clang-format] Followup of D30646 - unbreak the build
llvm-svn: 297148
2017-03-07 15:20:31 +00:00
Andi-Bogdan Postelnicu 6732989637 [clang-format] Fixed indent issue when adding a comment at the end of a return type in named function declaration.
Differential Revision: https://reviews.llvm.org/D30646

llvm-svn: 297143
2017-03-07 14:48:02 +00:00
Krasimir Georgiev eb62118e6d [clang-format] Support namespaces ending in semicolon
Summary:
This patch adds support for namespaces ending in semicolon to the namespace comment fixer.
source:
```
namespace A {
  int i;
  int j;
};
```
clang-format before:
```
namespace A {
  int i;
  int j;
} // namespace A;
```
clang-format after:
```
namespace A {
  int i;
  int j;
}; // namespace A
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 297140
2017-03-07 14:07:43 +00:00
Martin Bohme 0c11c29121 [analyzer] Fix crash when building CFG with variable of incomplete type
Summary:
I've included a unit test with a function template containing a variable
of incomplete type. Clang compiles this without errors (the standard
does not require a diagnostic in this case). Without the fix, this case
triggers the crash.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 297129
2017-03-07 08:42:37 +00:00
Krasimir Georgiev 615353cf38 [clang-format] Add tests for ambiguous namespaces to the comment fixer
llvm-svn: 297034
2017-03-06 17:29:25 +00:00
Krasimir Georgiev bda77397db [clang-format] Make NamespaceEndCommentFixer add at most one comment
Summary:
Until now, NamespaceEndCommentFixer was adding missing comments for every run,
which results in multiple end comments for:
```
namespace {
  int i;
  int j;
}
#if A
  int a = 1;
#else
  int a = 2;
#endif
```
result before:

```
namespace {
  int i;
  int j;
}// namespace // namespace
#if A
  int a = 1;
#else
  int a = 2;
#endif
```
result after:
```
namespace {
  int i;
  int j;
}// namespace
#if A
  int a = 1;
#else
  int a = 2;
#endif
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 297028
2017-03-06 16:44:45 +00:00
Krasimir Georgiev 9163fe2aba [clang-format] Use number of unwrapped lines for short namespace
Summary:
This patch makes the namespace comment fixer use the number of unwrapped lines
that a namespace spans to detect it that namespace is short, thus not needing
end comments to be added.
This is needed to ensure clang-format is idempotent. Previously, a short namespace
was detected by the original source code lines. This has the effect of requiring two
runs for this example:
```
namespace { class A; }
```
after first run:
```
namespace {
class A;
}
```
after second run:
```
namespace {
class A;
} // namespace
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 296736
2017-03-02 09:54:44 +00:00
Daniel Jasper 893b8adca2 clang-format: [JS] Properly format object literals with shorthands.
Before:
  return {
    a,
    b: 'b', c,
  };

After:
  return {
    a,
    b: 'b',
    c,
  };

llvm-svn: 296664
2017-03-01 19:47:28 +00:00
Daniel Jasper 01b8783a05 clang-format: [JS/TS] Properly understand cast expressions.
Many things were wrong:
- We didn't always allow wrapping after "as", which can be necessary.
- We used to Undestand the identifier after "as" as a start of a name.
- We didn't properly parse the structure of the expression with "as"
  having the precedence of relational operators

llvm-svn: 296659
2017-03-01 19:26:12 +00:00
Krasimir Georgiev 85c3704c0d [clang-format] Don't add namespace end comments for unbalanced right braces after namespace end
llvm-svn: 296638
2017-03-01 16:38:08 +00:00
Krasimir Georgiev 32eaa864e3 [clang-format] Add a new flag FixNamespaceComments to FormatStyle
Summary:
This patch enables namespace end comments under a new flag FixNamespaceComments,
which is enabled for the LLVM and Google styles.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 296632
2017-03-01 15:35:39 +00:00
Eric Liu 9e745b7292 Introducing clang::tooling::AtomicChange for refactoring tools.
Summary:
An AtomicChange is used to create and group a set of source edits, e.g.
replacements or header insertions. Edits in an AtomicChange should be related,
e.g. replacements for the same type reference and the corresponding header
insertion/deletion.

An AtomicChange is uniquely identified by a key position and will either be
fully applied or not applied at all. The key position should be the location
of the key syntactical element that is being changed, e.g. the call to a
refactored method.

Next step: add a tool that applies AtomicChange.

Reviewers: klimek, djasper

Reviewed By: klimek

Subscribers: alexshap, cfe-commits, djasper, mgorny

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

llvm-svn: 296616
2017-03-01 13:14:01 +00:00
Daniel Jasper 62703eb8a7 Fix r296605 so that stuff in #ifndef SWIG blocks is still formatted.
llvm-svn: 296608
2017-03-01 11:10:11 +00:00
Daniel Jasper eab6cd474c clang-format: Ignore contents of #ifdef SWIG .. #endif blocks.
Those blocks are used if C++ code is SWIG-wrapped (see swig.org) and
usually do not contain C++ code. Also cleanup the implementation of for #if 0
and #if false a bit.

llvm-svn: 296605
2017-03-01 10:47:52 +00:00
Daniel Jasper e154020dc5 clang-format: [Java] Fix bug in enum formatting.
Before:
  public enum VeryLongEnum {
    ENUM_WITH_MANY_PARAMETERS("aaaaaaaaaaaaaaaaaaaaaa",
                              "bbbbbbbbbbbbbbbbbbbbbbbbbbb",
                              "ccccccccccccccccccc")
    ,
    SECOND_ENUM("a", "b", "c");

    private VeryLongEnum(String a, String b, String c) {}
  }

After:
  public enum VeryLongEnum {
    ENUM_WITH_MANY_PARAMETERS("aaaaaaaaaaaaaaaaaaaaaa",
                              "bbbbbbbbbbbbbbbbbbbbbbbbbbb",
                              "ccccccccccccccccccc") ,
    SECOND_ENUM("a", "b", "c");

    private VeryLongEnum(String a, String b, String c) {}
  }

llvm-svn: 296499
2017-02-28 18:28:15 +00:00
Martin Probst bb46a7dd2a Blacklist arbitrary @\\w+ JSDoc tags from wrapping.
Summary:
Also limits the blacklisting to only apply when the tag is actually
followed by a parameter in curly braces.

    /** @mods {long.type.must.not.wrap} */

vs

    /** @const this is a long description that may wrap. */

Reviewers: djasper

Subscribers: klimek, krasimir, cfe-commits

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

llvm-svn: 296467
2017-02-28 11:08:24 +00:00
Krasimir Georgiev 7cb267af75 [clang-format] Add a NamespaceEndCommentsFixer
Summary:
This patch adds a NamespaceEndCommentsFixer TokenAnalyzer for clang-format,
which fixes end namespace comments.
It currently supports inserting and updating existing wrong comments.

Example source:
```
namespace A {
int i;
}

namespace B {
int j;
} // namespace A
```

after formatting:
```
namespace A {
int i;
} // namespace A

namespace B {
int j;
} // namespace B
```

Reviewers: klimek, djasper

Reviewed By: djasper

Subscribers: klimek, mgorny

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

llvm-svn: 296341
2017-02-27 13:28:36 +00:00
Martin Probst 20371c30ef clang-format: [JS] whitespace after async in arrow functions.
Summary:
Async arrow functions should be marked with a whitespace after the async keyword, before the parameter list:
    x = async () => foo();

Before:
    x = async() => foo();

This makes it easier to tell apart an async arrow function from a call to a function called async.

Reviewers: bkramer

Subscribers: cfe-commits, klimek

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

llvm-svn: 296330
2017-02-27 11:15:53 +00:00
Nico Weber d96ae86735 clang-format: Fix many Objective-C formatting regressions from r289428
r289428 added a separate language kind for Objective-C, but kept many
"Language == LK_Cpp" checks untouched.  This introduced a "IsCpp()"
method that returns true for both C++ and Objective-C++, and replaces
all comparisons of Language with LK_Cpp with calls to this new method.

Also add a lot more test coverge for formatting things in LK_ObjC mode,
by having FormatTest's verifyFormat() test for LK_ObjC everything that's
being tested for LK_Cpp at the moment.

Fixes PR32060 and many other things.

llvm-svn: 296160
2017-02-24 19:10:12 +00:00
Daniel Jasper 98e0b12d13 clang-format: [JS] Improve line-wrapping behavior of template strings.
Specifically, similar to other blocks, clang-format now wraps both
after "${" and before the corresponding "}", if the contained
expression spans multiple lines.

llvm-svn: 295663
2017-02-20 14:51:16 +00:00
Daniel Jasper d9b319e3e3 clang-format: Prevent weird line-wraps in complex lambda introducers
Before:
  aaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
      [aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]() -> ::std::
	  unordered_set<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> {
	    //
	  });

After:
  aaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
      [aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]()
	  -> ::std::unordered_set<
	      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> {
	//
      });

llvm-svn: 295659
2017-02-20 12:43:48 +00:00
Daniel Jasper 3d934d366e clang-format: [JS/TS] Improve detection for array subscripts in types.
Before:
  var someValue = (v as aaaaaaaaaaaaaaaaaaaa<T>[
                  ]).someFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
  var someValue = (v as aaaaaaaaaaaaaaaaaaaa<T>[])
                      .someFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 295658
2017-02-20 12:43:41 +00:00
Daniel Jasper 23c2b5ae7e clang-format: Don't remove existing spaces between identifier and ::.
This can lead to bad behavior with macros that are used to annotate
functions (e.g. ALWAYS_INLINE).

Before, this:
  ALWAYS_INLINE ::std::string getName() ...

was turned into:
  ALWAYS_INLINE::std::string getName() ...

If it turns out that clang-format is failing to clean up a lot of the
existing spaces now, we can add more analyses of the identifier. It
should not currently. Cases where clang-format breaks nested name
specifiers should be fine as clang-format wraps after the "::". Thus, a
line getting longer and then shorter again should lead to the same
original code.

llvm-svn: 295437
2017-02-17 10:44:07 +00:00
Krasimir Georgiev bb99a36dc0 [clang-format] Align block comment decorations
Summary:
This patch implements block comment decoration alignment.

source:
```
/* line 1
* line 2
*/
```

result before:
```
/* line 1
* line 2
*/
```

result after:
```
/* line 1
 * line 2
 */
```

Reviewers: djasper, bkramer, klimek

Reviewed By: klimek

Subscribers: mprobst, cfe-commits, klimek

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

llvm-svn: 295312
2017-02-16 12:39:31 +00:00
Krasimir Georgiev 93a8e9df44 [clang-format] Remove dead code in FormatTestComments, NFC
llvm-svn: 295044
2017-02-14 10:35:42 +00:00
Nico Weber 2108880660 clang-format: don't break code using __has_include, PR31908
llvm-svn: 294772
2017-02-10 19:36:52 +00:00
Krasimir Georgiev fd0dda765e [clang-format] Move comment tests to their own file.
Summary: With a growing suite of comment-related tests, it makes sense to take them out of the main test file. No functional changes.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek, mgorny

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

llvm-svn: 294439
2017-02-08 12:53:18 +00:00
Krasimir Georgiev f62f958a58 [clang-format] Break before a sequence of line comments aligned with the next line.
Summary:
Make the comment alignment respect sections of line comments originally alinged
with the next token. Until now the decision how to break a continuous sequence
of line comments into sections was taken without reference to the next token.

source:
```
class A {
public: // comment about public
  // comment about a
  int a;
}
```

format before:
```
class A {
public: // comment about public
        // comment about a
  int a;
}
```

format after:
```
class A {
public: // comment about public
  // comment about a
  int a;
}
```

Reviewers: djasper, klimek

Reviewed By: klimek

Subscribers: cfe-commits, klimek

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

llvm-svn: 294435
2017-02-08 10:30:44 +00:00