Commit Graph

138 Commits

Author SHA1 Message Date
Daniel Jasper 06dbac4be9 clang-format: Cut more clangAST dependencies.
Hopefully fixing windows builds.

llvm-svn: 220878
2014-10-29 22:42:53 +00:00
Daniel Jasper cb3e6188bc Refactor libTooling to reduce required dependencies.
This moves classes for storing and applying replacements to separate
files. These classes specifically are used by clang-format which doesn't
have any other dependencies on clangAST. Thereby, the size of
clang-format's binary can be cut roughly in half and its build time sped
up.

llvm-svn: 220867
2014-10-29 18:55:09 +00:00
Saleem Abdulrasool 1f060a8552 clang-format: improve vim integration docs
Improve the documentation for vim integration of clang-format.  Prefer the use
of <c-o> to do the normal mode command execution to avoid side-effects of the
escape and re-insertion (cursor movement).  Tweak the macros to use a double
return to avoid having to manually return control to the editor from the
subprocess.

llvm-svn: 220685
2014-10-27 17:13:33 +00:00
Daniel Jasper 23376259c0 clang-format: [JS] Support regex literals with trailing escaped slash.
Before:
  var regex = / a\//; int i;

After:
  var regex = /a\//;
  int i;

This required pushing the Lexer into its wrapper class and generating a
new one in this specific case. Otherwise, the sequence get lexed as a
//-comment. This is hacky, but I don't know a better way (short of
supporting regex literals in the Lexer).

Pushing the Lexer down seems to make all the call sites simpler.

llvm-svn: 217444
2014-09-09 14:37:39 +00:00
Daniel Jasper 4db69bd542 clang-format: [JS] Support alternative operator names as identifiers.
Before:
  not. and . or . not_eq = 1;

After:
  not.and.or.not_eq = 1;

llvm-svn: 217179
2014-09-04 18:23:42 +00:00
Ed Schouten bf041d975e Use /usr/bin/env python instead of /usr/bin/python.
On operating systems like the BSDs, it is typically the case that
/usr/bin/python does not exist. We should therefore use /usr/bin/env
instead. This is also done in various other scripts in tools/.

llvm-svn: 216945
2014-09-02 20:59:13 +00:00
Alp Toker 0621cb2e7d Make clang's rewrite engine a core feature
The rewrite facility's footprint is small so it's not worth going to these
lengths to support disabling at configure time, particularly since key compiler
features now depend on it.

Meanwhile the Objective-C rewriters have been moved under the
ENABLE_CLANG_ARCMT umbrella for now as they're comparatively heavy and still
potentially worth excluding from lightweight builds.

Tests are now passing with any combination of feature flags. The flags
historically haven't been tested by LLVM's build servers so caveat emptor.

llvm-svn: 213171
2014-07-16 16:48:33 +00:00
Rafael Espindola 2d2b420ab9 Update for llvm api change.
llvm-svn: 212408
2014-07-06 17:43:24 +00:00
David Blaikie 66cc07b4f7 Remove 'const' from MemoryBuffers used through the SourceManager
This removes a const_cast added in r211884 that occurred due to an
inconsistency in how MemoryBuffers are handled between some parts of
clang and LLVM.

MemoryBuffers are immutable and the general convention in the LLVM
project is to omit const from immutable types as it's simply
redundant/verbose (see llvm::Type, for example). While this change
doesn't remove "const" from /every/ MemoryBuffer, it at least makes this
chain of ownership/usage consistent.

llvm-svn: 211915
2014-06-27 17:40:03 +00:00
Rafael Espindola 8e650d7bf0 Refer to error_code with the std prefix.
llvm-svn: 210817
2014-06-12 20:37:59 +00:00
Daniel Jasper c64b09acc3 clang-format: Introduce DisableFormat that prevents formatting.
And "none" pseudo-style indicating that formatting should be not
applied.

(1) Using .clang-format with "DisableFormat: true" effectively prevents
formatting for all files within the folder containing such .clang-format
file.

(2) Using -fallback-style=none together with -style=file prevents
formatting when .clang-format is not found, which can be used in on-save
callback.

Patch by Adam Strzelecki. Thank you!

llvm-svn: 209446
2014-05-22 15:12:22 +00:00
Daniel Jasper 62f73ec1ef clang-format: Fix vim-integration for empty files.
Discovered by Ahmed Charles in http://reviews.llvm.org/D3018.

llvm-svn: 209417
2014-05-22 11:37:05 +00:00
Daniel Jasper 2e8600c02b clang-format: Add clang-format-diff usage examples for SVN.
llvm-svn: 208766
2014-05-14 09:36:11 +00:00
Nikola Smiljanic e08a91ecd2 Enable alternative tokens by default for clang-format.
Patch by Bobby Moretti.

llvm-svn: 208269
2014-05-08 00:05:13 +00:00
Nico Weber ffaf29a07b clang-format.py: Don't omit the first two words from error messages.
This reverts r172072.  clang-format used to use DiagnosticEngine to output
errors: http://llvm.org/viewvc/llvm-project?view=revision&revision=172071. Now
it doesn't, so this code is obsolete.

llvm-svn: 206479
2014-04-17 17:51:57 +00:00
Daniel Jasper dfacecbd31 clang-format: Add proto files and JavaScript to git-clang-format.
llvm-svn: 205842
2014-04-09 09:22:35 +00:00
Ahmed Charles f9e1e5f8de Add a main function to the clang-format.py vim integration.
This will allow using an early return statement in a subsequent change.

llvm-svn: 203501
2014-03-10 22:12:14 +00:00
Ahmed Charles b89843299a Replace OwningPtr with std::unique_ptr.
This compiles cleanly with lldb/lld/clang-tools-extra/llvm.

llvm-svn: 203279
2014-03-07 20:03:18 +00:00
Alexander Kornienko 1eda305a52 Add newlines to fallback-style description. Patch by Kamal Essoufi\!
llvm-svn: 202269
2014-02-26 15:03:57 +00:00
Alexander Kornienko 3bb8fbfa3e Make the OptionCategory variable static.
llvm-svn: 200839
2014-02-05 13:42:43 +00:00
Daniel Jasper 2158912a4e clang-format: Enable formatting for .proto and .protodevel files.
Support for protocol buffer files seems complete enough.

llvm-svn: 199750
2014-01-21 15:40:01 +00:00
Nico Weber b00d66e6ac Shorten the output of `clang-format --version`, include revision number.
Before:
  $ clang-format  --version
  LLVM (http://llvm.org/):
    LLVM version 3.5svn
    Optimized build with assertions.
    Built Jan  3 2014 (14:28:46).
    Default target: x86_64-apple-darwin13.0.0
    Host CPU: core-avx-i

Now:
  $ bin/clang-format --version
  clang-format version 3.5 (198452)

llvm-svn: 198694
2014-01-07 16:27:35 +00:00
Chandler Carruth 5553d0d4ca Sort all the #include lines with LLVM's utils/sort_includes.py which
encodes the canonical rules for LLVM's style. I noticed this had drifted
quite a bit when cleaning up LLVM, so wanted to clean up Clang as well.

llvm-svn: 198686
2014-01-07 11:51:46 +00:00
Daniel Jasper db7933ab99 Fix usage description of clang-format-diff.py.
llvm-svn: 197668
2013-12-19 10:21:37 +00:00
Alp Toker 679bf0141b clang-format-diff.py: fix -regex/-iregex matching
While debating the finer points of file extension matching, we somehow missed
the bigger problem that the current code will match anything starting with the
default or user-specified pattern (e.g. lit.site.cfg.in).

Fix this by doing what find(1) does, implicitly wrapping the pattern with ^$.

llvm-svn: 197608
2013-12-18 21:34:07 +00:00
Alp Toker c49406d18c clang-format-diff.py: add the OpenCL file extension
It's handled correctly as a C-family language.

llvm-svn: 197542
2013-12-18 00:58:58 +00:00
Alexander Kornienko 25c683891c Added -iregex for case-insensitive regex to filter file names.
Summary:
-regex and -iregex both mimic options of the find utility.
Made the default list of extensions case-insensitive, so that it's not only C
and CPP extensions are accepted in upper case.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2415

llvm-svn: 197378
2013-12-16 10:57:30 +00:00
Alp Toker 8c7cbdf53a clang-format-diff.py: Support -regex filter and more filename extensions
Add support for more filename extensions based on the list in the clang
plus JavaScript.

Also adds a -regex option so users can override defaults if they have unusual
file extensions or want to format everything in the diff.

Keeping with tradition the flag is modelled on Unix conventions, this time
matching the semantics of find(1).

llvm-svn: 196917
2013-12-10 13:51:53 +00:00
NAKAMURA Takumi ac85179219 [CMake] Update target_link_libraries() and LLVM_LINK_COMPONENTS for each CMakeLists.txt.
llvm-svn: 196916
2013-12-10 12:40:37 +00:00
Alp Toker fcf30326fd clang-format-diff.py: pass through errors to stderr, not stdout
Also use write() for unified diff output to avoid further processing by the
print function (e.g. trailing newline).

llvm-svn: 196484
2013-12-05 08:14:54 +00:00
Alp Toker 0e7f6da674 clang-format-diff.py: Fix 'beintroduced' in help output
Also update docs to reflect recently changed -i inplace edit behaviour.

llvm-svn: 196336
2013-12-04 00:48:22 +00:00
Manuel Klimek f54dcbc4e6 Preserve carriage return when using clang-format's XML interface.
Patch by James Park.

llvm-svn: 196265
2013-12-03 09:46:06 +00:00
Alexander Kornienko bc4ae44928 Added an option to specify fallback style.
Summary:
Added -fallback-style option. Changed clang-format to stop searching
for .clang-format when an invalid file is found.

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D2292

llvm-svn: 196108
2013-12-02 15:21:38 +00:00
Hans Wennborg ae78e23e5f Install clang-format's editor integrations in $PREFIX/share/clang/
They were previously not part of the install target.

Differential Revision: http://llvm-reviews.chandlerc.com/D2154

llvm-svn: 194741
2013-11-14 22:48:06 +00:00
Bill Wendling e94f74f69f Use a StringRef. Saves 0.00000000000001s on execution time.
llvm-svn: 194301
2013-11-09 00:23:58 +00:00
Sean Silva 60dccf2d06 Py3k compat for clang-format Sublime Text extension.
Sublime Text 2 uses Python 2.6
Sublime Text 3 uses Python 3.3

The `print` function has been available as a __future__ import since
2.6, so use it.

Patch by Johan Engelen!

llvm-svn: 194287
2013-11-08 22:46:56 +00:00
Alp Toker 07ce1d0282 clang-format: Write files atomically
Switch clang-format over to Rewriter::overwriteChangedFiles().

The previous implementation was attempting to stream back directly to the
original file and failing if it was already memory mapped by MemoryBuffer,
an operation unsupported by Windows.

MemoryBuffer generally mmaps files larger than the physical page size so
this will have been difficult to reproduce consistently.

This change also reduces flicker in code editors and IDEs on all platforms
when reformatting in-place.

Note that other incorrect uses of MemoryBuffer exist in LLVM/clang and
will need a similar fix.

A test should be added for Windows when libFormat performance issues are
fixed (it takes longer than a day to format a 1MB file at present!)

llvm-svn: 194250
2013-11-08 08:07:19 +00:00
Nico Weber 8bdd1ee021 clang-format.py: Make formatting unnamed buffers work again (broke in r190691).
llvm-svn: 193433
2013-10-25 20:06:20 +00:00
Alexander Kornienko 95c009afd9 Changed clang-format-diff.py to output diff by default. Added -i option to apply changes to files instead.
Summary:
"svn diff|clang-format-diff.py" will just output the diff.
Now it's possible to use:
  svn diff|clang-format-diff.py|patch -p0
as an equivalent to:
  svn diff|clang-format-diff.py -i
;)

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1840

llvm-svn: 192505
2013-10-11 21:32:01 +00:00
Daniel Jasper e8845ad4c5 clang-format: Don't exit with failure on empty files.
Also let clang-format-diff.py detect errors based on clang-format's
return code. Otherwise messages like "Can't find usable .clang-format,
falling back to LLVM style" can make it fail, which might be undesired.

Patch by Alp Toker. Thank you!

llvm-svn: 192184
2013-10-08 15:54:36 +00:00
Daniel Jasper 164c8e1810 clang-format: Fix clang-format-diff.py according to diff specification.
Patch by Alp Toker. Many thanks!

Original descriptions:
clang-format-diff incorrectly modifies unchanged lines due to an error
in diff parsing.

The unified diff format has a default line change count of 1, and 0 may
be specified to indicate that no lines have been added. This patch
updates the parser to accurately reflect the diff specification.

This also has the benefit of stabilising the operation so it will
produce the same output when run multiple times on the same changeset,
which was previously not the case.

No tests added because this script is not currently tested (though we
should look into that!)

llvm-svn: 191820
2013-10-02 13:59:03 +00:00
David Blaikie 8b03ef8388 Remove unused variable introduced in 191666
llvm-svn: 191682
2013-09-30 17:30:41 +00:00
Edwin Vane d544aa79c9 Moving style option formatting to libFormat
The help text for clang-format's -style option and the function that processes
its value is moved to libFormat in this patch. The goal is to enable other
tools that use libFormat and also have a -style option to behave consistently
with clang-format.

llvm-svn: 191666
2013-09-30 13:31:48 +00:00
Daniel Jasper cf627f0f7b Fix clang-format-diff.py to accept -style again.
Copy and paste error in r190935..

llvm-svn: 191137
2013-09-21 10:05:02 +00:00
Daniel Jasper dcab7fbb83 Simplify clang-format-diff.py using new clang-format options.
clang-format's -lines parameter makes this significantly easier.

llvm-svn: 190935
2013-09-18 12:14:09 +00:00
Daniel Jasper e488f5dd1e clang-format: Add -assume-filename option for editor integrations.
With -style=file, clang-format now starts to search for a .clang-format
file starting at the file given with -assume-filename if it reads from
stdin. Otherwise, it would start searching from the current directory,
which is not helpful for editor integrations.

Also changed vim, emacs and sublime integrations to actually make use of
this flag.

This fixes llvm.org/PR17072.

llvm-svn: 190691
2013-09-13 13:40:24 +00:00
Hans Wennborg 9f6581bb88 Allow _clang-format as alternative to .clang-format config filename
Dotfiles are impractical on Windows. This makes clang-format search
for the style configuration file as '_clang-format' in addition to
the usual '.clang-format'. This is similar to how VIM searches for
'_vimrc' on Windows.

Differential Revision: http://llvm-reviews.chandlerc.com/D1629

llvm-svn: 190413
2013-09-10 15:41:12 +00:00
Alexander Kornienko e3648fbe1a Added WebKit style to the BasedOnStyle handling and to the relevant help messages.
llvm-svn: 189765
2013-09-02 16:39:23 +00:00
Alexander Kornienko d83adf30c6 Whitespace changes in help messages + updated help output in .rst file.
llvm-svn: 189762
2013-09-02 15:30:26 +00:00
Chandler Carruth bc36e6e099 Switch the default mode for clang-format to '-file'. Make 'LLVM' the
fallback syntax used when we fail to find a '.clang-format' file. Adjust
variable names appropriately.

Update the editor integration pieces that specify a '-style' option to
specify it as '-style=file'. I left the functionality in place because
even if the preferred method is to use '.clang-format' files, this way
if someone needs to clobber the style in their editor we show how to do
so in these examples.

Also check in a '.clang-format' file for Clang to ensure that separate
checkouts and builds of Clang from LLVM can still get the nice
formatting. =] This unfortunately required nuking the test for the
absence of a '.clang-format' file as now the directory happening to be
under your clang source tree will cause there to always be a file. ;]

llvm-svn: 189741
2013-09-02 07:42:02 +00:00
Daniel Jasper 695bad54a8 Simplify git-clang-format by using new -lines option.
Patch by Mark Lodato. Thank you!

llvm-svn: 187592
2013-08-01 18:17:13 +00:00
Daniel Jasper 8e2c20a77d Fix bug in clang-format's vim integration cause by r186789.
After the first operation, the buffer contents has changed and thus all
other operations would be invalid. Executing the operations in reversed
order should fix this.

llvm-svn: 186840
2013-07-22 16:22:13 +00:00
Daniel Jasper 5f08421e2d Install git-clang-format along with clang-format by default.
llvm-svn: 186825
2013-07-22 12:51:47 +00:00
Daniel Jasper 68c03c82df clang-format: Smarter replacement in the vim integration.
With this fix, only changed regions will be replaced in vim's buffer.
Thereby, marks should mostly be left intact. Furthermore, this is a
better fix for the performance problem in conjunction with
'foldmethod=syntax' (see r186660).

llvm-svn: 186789
2013-07-21 10:45:33 +00:00
Alexander Kornienko 5884aa9617 Use -lines option instead of -offset/-length. This fixes problems with files using dos newlines (<CR><LF>).
llvm-svn: 186740
2013-07-20 01:01:25 +00:00
Daniel Jasper b11c2c2838 Improve clang-format vim integration.
The previous line-by-line replacement causes vim to take a long time if
the foldmethod is set to 'syntax'. This should significantly improve
performance in that case.

llvm-svn: 186660
2013-07-19 09:30:44 +00:00
Alexander Kornienko a49732ff28 Added -lines X:Y option to specify line range to process. This is a more human-friendly alternative to -offset and -length.
Differential Revision: http://llvm-reviews.chandlerc.com/D1160

llvm-svn: 186625
2013-07-18 22:54:56 +00:00
Rafael Espindola 16125fb652 Update for llvm API change.
llvm-svn: 186448
2013-07-16 19:44:23 +00:00
Daniel Jasper 095737413f Prevent error message when formatting an empty file.
This fixes llvm.org/PR16514.

llvm-svn: 185531
2013-07-03 12:22:18 +00:00
Daniel Jasper a3fc21a0f1 Fix ranges computed by git clang-format.
Before, the computed byte range would include the trailing newline.
clang-format on the other hand counts whitespace as belonging to the
following token, so that git-clang-format inadvertendly reformats the
first unmodified line as well.

It is not entirely clear whether clang-format's behavior itself should
be modified, but for now this seems to be a safe change.

llvm-svn: 185423
2013-07-02 13:20:35 +00:00
Alexander Kornienko 1e80887d63 Use lexing mode based on FormatStyle.Standard.
Summary:
Some valid pre-C++11 constructs change meaning when lexed in C++11
mode, e.g.
#define x(_a) printf("foo"_a);
(example from http://llvm.org/bugs/show_bug.cgi?id=16342). "foo"_a is treated as
a user-defined string literal when parsed in C++11 mode.
In order to deal with this correctly, we need to set lexing mode according to
which standard the code conforms to. We already have a configuration value for
this (FormatStyle.Standard), which seems to be appropriate to use in this case
as well.

Reviewers: klimek

CC: cfe-commits, gribozavr

Differential Revision: http://llvm-reviews.chandlerc.com/D1028

llvm-svn: 185149
2013-06-28 12:51:24 +00:00
Reid Kleckner 898229ab4b [Driver] Refactor clang driver to use LLVM's Option library
The big changes are:
- Deleting Driver/(Arg|Opt)*
- Rewriting includes to llvm/Option/ and re-sorting
- 'using namespace llvm::opt' in clang::driver
- Fixing the autoconf build by adding option everywhere

As discussed in the review, this change includes using directives in
header files.  I'll make follow up changes to remove those in favor of
name specifiers.

Reviewers: espindola

Differential Revision: http://llvm-reviews.chandlerc.com/D975

llvm-svn: 183989
2013-06-14 17:17:23 +00:00
Manuel Klimek c00dd83583 Make it possible to assign clang-format-buffer to a keybinding.
Patch by Chris Gray.

llvm-svn: 183739
2013-06-11 12:00:24 +00:00
Reid Kleckner 99dfe95bdd [clang-format] Don't flash an ugly cmd prompt in Vim on Windows
Reviewers: klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D941

llvm-svn: 183654
2013-06-10 14:16:26 +00:00
Daniel Jasper 2714ba03f6 Fix default value of clang-format-diff's -p option.
This way, it has the same default as 'patch' and also the example in the
code makes more sense as it is explicitly setting -p 1.

llvm-svn: 182923
2013-05-30 11:50:20 +00:00
Daniel Jasper e7a500160e clang-format integration for git.
Put this somewhere on your path and use:

git clang-format

Awesome work by Mark Lodato. Many thanks!

llvm-svn: 182596
2013-05-23 17:53:42 +00:00
Daniel Jasper a3c14575ef Fix off-by-one error in clang-format's emacs integration.
llvm-svn: 182395
2013-05-21 17:05:40 +00:00
Daniel Jasper a8048b8216 Fix behavior of clang-format's -cursor flag.
llvm-svn: 182386
2013-05-21 14:21:46 +00:00
Daniel Jasper 2a250b8b49 Let clang-format move the cursor appropriately.
With this patch, clang-format will try to keep the cursor at the
original code position in editor integrations (implemented for emacs and
vim). This means, after formatting, clang-format will try to keep the
cursor on the same character of the same token.

llvm-svn: 182373
2013-05-21 12:21:39 +00:00
Alexander Kornienko 006b5c89ce Clang-format: allow -style="{yaml/json}" on command line
Summary: + improved handling of default style and predefined styles.

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D813

llvm-svn: 182205
2013-05-19 00:53:30 +00:00
Daniel Jasper 5b38f744e8 Add basic clang-format integration for sublime text.
llvm-svn: 182015
2013-05-16 15:08:25 +00:00
Daniel Jasper 6e3506f212 Update clang-format emacs integration.
- Remove free variables
- Add function clang-format-buffer, e.g. for before-save-hooks
- Wrap restoring windows in an unwind-protect

Patch by Stephen Gildea!

llvm-svn: 181766
2013-05-14 08:48:24 +00:00
Alexander Kornienko 88a0d939de Reformat clang-format help strings, filter out irrelevant options.
Summary: +updated ClangFormat.rst

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D780

llvm-svn: 181617
2013-05-10 18:12:00 +00:00
Alexander Kornienko 70f6b3b631 Updated clang-format help messages for -offset and -length
llvm-svn: 181593
2013-05-10 13:18:17 +00:00
Alexander Kornienko fa94cbb70f Minor clarifications in help messages and a comment.
llvm-svn: 181591
2013-05-10 13:04:20 +00:00
Alexander Kornienko 49149677d9 Config file support for clang-format, part 2.
Summary:
Adds actual config file reading to the clang-format utility.
Configuration file name is .clang-format. It is looked up for each input file
in its parent directories starting from immediate one. First found .clang-format
file is used. When using standard input, .clang-format is searched starting from
the current directory.
Added -dump-config option to easily create configuration files.

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits, jordan_rose, kimgr

Differential Revision: http://llvm-reviews.chandlerc.com/D758

llvm-svn: 181589
2013-05-10 11:56:10 +00:00
Daniel Jasper ee48c856e2 Further fix to clang-format emacs integration.
This is just a slight improvement for the fix in r181299, which fixes
formatting the very last line of a file.

llvm-svn: 181303
2013-05-07 10:04:47 +00:00
Daniel Jasper f7bec9b4ed Fix clang-format emacs integration in last line.
Emacs seems to have a line that is just past the last character of the
buffers content. This needs to be handled specially so that clang-format
is not called with an invalid -offset.

llvm-svn: 181299
2013-05-07 09:25:29 +00:00
Alexander Kornienko c860266e0f Added Mozilla style, cleaned get*Style methods.
Summary: Patch based on a patch by Ehsan Akhgari.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D750

llvm-svn: 181196
2013-05-06 14:11:27 +00:00
Daniel Jasper 5f99742632 Basic clang-format integration for BBEdit.
Thanks to Avi Drissman!

llvm-svn: 180933
2013-05-02 17:37:36 +00:00
Daniel Jasper a04337e22b Fix scrolling bug in clang-format's emacs integration.
This patch ensure that nothing scrolls even if the same buffer is opened
in multiple windows.

llvm-svn: 180252
2013-04-25 07:06:48 +00:00
Alexander Kornienko 3fbee010c6 clang-format support for multiple input files.
Summary:
Added support for multiple input files, that can be used both with and
without in-place edit (-i) option. Added checks for -offset and -length options:
don't allow them on multiple files, check that they don't fall outside input
file, made both options unsigned, so that there's no need to check for negative
values. Removed "-1 can be used for end-of-file" from -length description.

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D719

llvm-svn: 180185
2013-04-24 12:46:44 +00:00
Daniel Jasper dd77743af8 Small improvements to clang-format documentation and integration
scripts.

llvm-svn: 179676
2013-04-17 07:55:02 +00:00
Daniel Jasper 31f916ac51 Fix clang-format-diff.py script.
llvm-svn: 179377
2013-04-12 13:42:36 +00:00
Daniel Jasper 92a3130509 Provide better emacs integration.
The new emacs integration is simpler, does not save the current file
before reformatting and ensures that emacs does not scroll as a result
of formatting.

Also explicitly set the style in clang-format tests to make them more
robust.

llvm-svn: 179372
2013-04-12 10:12:01 +00:00
Daniel Jasper e4549a2391 Improvements to clang-format integrations.
This adds an emacs editor integration (thanks to Ami Fischman). Also
pulls out the style into a variable for the vi integration and just
uses clang-formats defaults style in clang-format-diff.py.

llvm-svn: 179098
2013-04-09 15:23:04 +00:00
Daniel Jasper 4b14f4f9e6 Remove outdated part of help message.
The styles are now documented with the -style option. This fixes
llvm.org/PR15689.

llvm-svn: 179017
2013-04-08 10:50:02 +00:00
Daniel Jasper 9be2c5cf17 Add clang-format binary to cfe.
llvm-svn: 177506
2013-03-20 09:53:23 +00:00