Commit Graph

10 Commits

Author SHA1 Message Date
Daniel Jasper e6fcf7d372 clang-format: clang-format (NFC)
llvm-svn: 239903
2015-06-17 13:08:06 +00:00
Manuel Klimek 3d3ea84a4f Refactor clang-format's formatter.
Summary:
a) Pull out a class LevelIndentTracker whose responsibility is to keep track
   of the indent of levels across multiple annotated lines.
b) Put all responsibility for merging lines into the LineJoiner; make the
   LineJoiner iterate over the lines so we never operate on a line that might
   be merged later; this makes the interface safer to use.
c) Move formatting of the end-of-file whitespace into formatFirstToken.

Fix bugs that became obvious after the refactoring:
1. We would not format lines with offsets correctly inside nested blocks if
   only the outer expression was affected:
   int x = s({ // clang-format only this line
     class X {
       public:
    // ^ this starts at the non-modified indnent level; previously we would
    //   not fix this, now we correctly outdent it.
       void f();
     };
   });
2. We would incorrectly align comments across lines that do not have comments
   for lines with nested blocks:
   int expression; // with comment
   int x = s({
     int y; // comment
     int z; // we would incorrectly align this comment with the comment on
            // 'expression'
   });

llvm-svn: 237104
2015-05-12 09:23:57 +00:00
Manuel Klimek d3585dbd1a Refactor the formatter of clang-format.
Pull various parts of the UnwrappedLineFormatter into their own
abstractions. NFC.

There are two things left for subsequent changes (to keep this
reasonably small)
- the UnwrappedLineFormatter now has a bad name
- the UnwrappedLineFormatter::format function is still too large

llvm-svn: 236974
2015-05-11 08:21:35 +00:00
Manuel Klimek ec5c3db7ac Implements a way to retrieve information about whether some lines were not formatted due to syntax errors.
llvm-svn: 236722
2015-05-07 12:26:30 +00:00
Daniel Jasper 036181471c clang-format: Don't indent 'signals' as access specifier if it isn't one
Before:
  {
  signals.set(0);
  }

After:
  {
    signals.set(0);
  }

llvm-svn: 236630
2015-05-06 19:21:23 +00:00
Daniel Jasper 289afc071e clang-format: Support nested block formatting with ColumnLimit=0.
llvm-svn: 235580
2015-04-23 09:23:17 +00:00
Daniel Jasper 53395406da clang-format: Fix regression formatting QT's "signals:" from r234318.
llvm-svn: 234320
2015-04-07 15:04:40 +00:00
Daniel Jasper 8370908667 clang-format: [JS] Support classes.
This adds support for JavaScript class definitions (again following
TypeScript & AtScript style). This only required support for
visibility modifiers in JS, everything else was already working.

Patch by Martin Probst, thank you.

llvm-svn: 229701
2015-02-18 17:14:05 +00:00
Nico Weber fac2371be3 clang-format: Add support for SEH __try / __except / __finally blocks.
This lets clang-format format

    __try {
    } __except(0) {
    }

and

    __try {
    } __finally {
    }

correctly. __try and __finally are keywords if `LangOpts.MicrosoftExt` is set,
so this turns this on.  This also enables a few other keywords, but it
shouldn't overly perturb regular clang-format operation.  __except is a
context-sensitive keyword, so `AdditionalKeywords` needs to be passed around to
a few more places.

Fixes PR22321.

llvm-svn: 228148
2015-02-04 15:26:27 +00:00
Daniel Jasper 0df50938be clang-format: Factor out UnwrappedLineFormatter into a separate file.
No functional changes intended.

llvm-svn: 223936
2014-12-10 19:00:42 +00:00