summaryrefslogtreecommitdiffstats
path: root/clang/tools/clang-format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Enable formatting for .proto and .protodevel files.Daniel Jasper2014-01-211-1/+2
| | | | | | Support for protocol buffer files seems complete enough. llvm-svn: 199750
* Shorten the output of `clang-format --version`, include revision number.Nico Weber2014-01-071-0/+7
| | | | | | | | | | | | | | | | | 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
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-071-1/+1
| | | | | | | 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
* Fix usage description of clang-format-diff.py.Daniel Jasper2013-12-191-2/+2
| | | | llvm-svn: 197668
* clang-format-diff.py: fix -regex/-iregex matchingAlp Toker2013-12-181-4/+4
| | | | | | | | | | 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
* clang-format-diff.py: add the OpenCL file extensionAlp Toker2013-12-181-1/+1
| | | | | | It's handled correctly as a C-family language. llvm-svn: 197542
* Added -iregex for case-insensitive regex to filter file names.Alexander Kornienko2013-12-161-5/+13
| | | | | | | | | | | | | | | | | 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
* clang-format-diff.py: Support -regex filter and more filename extensionsAlp Toker2013-12-101-4/+5
| | | | | | | | | | | | | 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
* [CMake] Update target_link_libraries() and LLVM_LINK_COMPONENTS for each ↵NAKAMURA Takumi2013-12-101-3/+3
| | | | | | CMakeLists.txt. llvm-svn: 196916
* clang-format-diff.py: pass through errors to stderr, not stdoutAlp Toker2013-12-051-5/+2
| | | | | | | Also use write() for unified diff output to avoid further processing by the print function (e.g. trailing newline). llvm-svn: 196484
* clang-format-diff.py: Fix 'beintroduced' in help outputAlp Toker2013-12-041-1/+1
| | | | | | Also update docs to reflect recently changed -i inplace edit behaviour. llvm-svn: 196336
* Preserve carriage return when using clang-format's XML interface.Manuel Klimek2013-12-031-2/+23
| | | | | | Patch by James Park. llvm-svn: 196265
* Added an option to specify fallback style.Alexander Kornienko2013-12-021-3/+10
| | | | | | | | | | | | | | | | 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
* Install clang-format's editor integrations in $PREFIX/share/clang/Hans Wennborg2013-11-141-0/+5
| | | | | | | | They were previously not part of the install target. Differential Revision: http://llvm-reviews.chandlerc.com/D2154 llvm-svn: 194741
* Use a StringRef. Saves 0.00000000000001s on execution time.Bill Wendling2013-11-091-1/+1
| | | | llvm-svn: 194301
* Py3k compat for clang-format Sublime Text extension.Sean Silva2013-11-081-1/+2
| | | | | | | | | | | | 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
* clang-format: Write files atomicallyAlp Toker2013-11-081-11/+1
| | | | | | | | | | | | | | | | | | | | | | 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
* clang-format.py: Make formatting unnamed buffers work again (broke in r190691).Nico Weber2013-10-251-3/+4
| | | | llvm-svn: 193433
* Changed clang-format-diff.py to output diff by default. Added -i option to ↵Alexander Kornienko2013-10-111-3/+22
| | | | | | | | | | | | | | | | | | | | | | 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
* clang-format: Don't exit with failure on empty files.Daniel Jasper2013-10-082-2/+3
| | | | | | | | | | 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
* clang-format: Fix clang-format-diff.py according to diff specification.Daniel Jasper2013-10-021-2/+5
| | | | | | | | | | | | | | | | | | | | | 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
* Remove unused variable introduced in 191666David Blaikie2013-09-301-3/+0
| | | | llvm-svn: 191682
* Moving style option formatting to libFormatEdwin Vane2013-09-301-78/+6
| | | | | | | | | 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
* Fix clang-format-diff.py to accept -style again.Daniel Jasper2013-09-211-1/+1
| | | | | | Copy and paste error in r190935.. llvm-svn: 191137
* Simplify clang-format-diff.py using new clang-format options.Daniel Jasper2013-09-181-59/+26
| | | | | | clang-format's -lines parameter makes this significantly easier. llvm-svn: 190935
* clang-format: Add -assume-filename option for editor integrations.Daniel Jasper2013-09-134-15/+30
| | | | | | | | | | | | | | 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
* Allow _clang-format as alternative to .clang-format config filenameHans Wennborg2013-09-103-2/+14
| | | | | | | | | | | 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
* Added WebKit style to the BasedOnStyle handling and to the relevant help ↵Alexander Kornienko2013-09-022-4/+6
| | | | | | messages. llvm-svn: 189765
* Whitespace changes in help messages + updated help output in .rst file.Alexander Kornienko2013-09-021-4/+4
| | | | llvm-svn: 189762
* Switch the default mode for clang-format to '-file'. Make 'LLVM' theChandler Carruth2013-09-024-14/+16
| | | | | | | | | | | | | | | | | | | 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
* Simplify git-clang-format by using new -lines option.Daniel Jasper2013-08-011-44/+12
| | | | | | Patch by Mark Lodato. Thank you! llvm-svn: 187592
* Fix bug in clang-format's vim integration cause by r186789.Daniel Jasper2013-07-221-1/+1
| | | | | | | | 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
* Install git-clang-format along with clang-format by default.Daniel Jasper2013-07-221-3/+2
| | | | llvm-svn: 186825
* clang-format: Smarter replacement in the vim integration.Daniel Jasper2013-07-211-7/+6
| | | | | | | | | 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
* Use -lines option instead of -offset/-length. This fixes problems with files ↵Alexander Kornienko2013-07-201-6/+3
| | | | | | using dos newlines (<CR><LF>). llvm-svn: 186740
* Improve clang-format vim integration.Daniel Jasper2013-07-191-2/+2
| | | | | | | | 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
* Added -lines X:Y option to specify line range to process. This is a more ↵Alexander Kornienko2013-07-181-16/+67
| | | | | | | | human-friendly alternative to -offset and -length. Differential Revision: http://llvm-reviews.chandlerc.com/D1160 llvm-svn: 186625
* Update for llvm API change.Rafael Espindola2013-07-161-1/+1
| | | | llvm-svn: 186448
* Prevent error message when formatting an empty file.Daniel Jasper2013-07-031-0/+2
| | | | | | This fixes llvm.org/PR16514. llvm-svn: 185531
* Fix ranges computed by git clang-format.Daniel Jasper2013-07-021-2/+2
| | | | | | | | | | | | 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
* Use lexing mode based on FormatStyle.Standard.Alexander Kornienko2013-06-281-3/+4
| | | | | | | | | | | | | | | | | | | | | 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
* [Driver] Refactor clang driver to use LLVM's Option libraryReid Kleckner2013-06-141-1/+1
| | | | | | | | | | | | | | | | | | 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
* Make it possible to assign clang-format-buffer to a keybinding.Manuel Klimek2013-06-111-0/+1
| | | | | | Patch by Chris Gray. llvm-svn: 183739
* [clang-format] Don't flash an ugly cmd prompt in Vim on WindowsReid Kleckner2013-06-101-1/+9
| | | | | | | | Reviewers: klimek Differential Revision: http://llvm-reviews.chandlerc.com/D941 llvm-svn: 183654
* Fix default value of clang-format-diff's -p option.Daniel Jasper2013-05-301-1/+1
| | | | | | | 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
* clang-format integration for git.Daniel Jasper2013-05-231-0/+513
| | | | | | | | | | Put this somewhere on your path and use: git clang-format Awesome work by Mark Lodato. Many thanks! llvm-svn: 182596
* Fix off-by-one error in clang-format's emacs integration.Daniel Jasper2013-05-211-2/+2
| | | | llvm-svn: 182395
* Fix behavior of clang-format's -cursor flag.Daniel Jasper2013-05-211-1/+1
| | | | llvm-svn: 182386
* Let clang-format move the cursor appropriately.Daniel Jasper2013-05-213-13/+35
| | | | | | | | | 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
* Clang-format: allow -style="{yaml/json}" on command lineAlexander Kornienko2013-05-191-8/+30
| | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud