summaryrefslogtreecommitdiffstats
path: root/tools/clang-format/ClangFormat.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Don't exit with failure on empty files.Daniel Jasper2013-10-081-1/+1
| | | | | | | | | | 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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192184 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unused variable introduced in 191666David Blaikie2013-09-301-3/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191682 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191666 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format: Add -assume-filename option for editor integrations.Daniel Jasper2013-09-131-1/+13
| | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190691 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow _clang-format as alternative to .clang-format config filenameHans Wennborg2013-09-101-0/+10
| | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190413 91177308-0d34-0410-b5e6-96231b3b80d8
* Added WebKit style to the BasedOnStyle handling and to the relevant help ↵Alexander Kornienko2013-09-021-1/+1
| | | | | | messages. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189765 91177308-0d34-0410-b5e6-96231b3b80d8
* Whitespace changes in help messages + updated help output in .rst file.Alexander Kornienko2013-09-021-4/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189762 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch the default mode for clang-format to '-file'. Make 'LLVM' theChandler Carruth2013-09-021-7/+7
| | | | | | | | | | | | | | | | | | | 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. ;] git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189741 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186625 91177308-0d34-0410-b5e6-96231b3b80d8
* Update for llvm API change.Rafael Espindola2013-07-161-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186448 91177308-0d34-0410-b5e6-96231b3b80d8
* Prevent error message when formatting an empty file.Daniel Jasper2013-07-031-0/+2
| | | | | | This fixes llvm.org/PR16514. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185531 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185149 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix behavior of clang-format's -cursor flag.Daniel Jasper2013-05-211-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182386 91177308-0d34-0410-b5e6-96231b3b80d8
* Let clang-format move the cursor appropriately.Daniel Jasper2013-05-211-0/+8
| | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182373 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182205 91177308-0d34-0410-b5e6-96231b3b80d8
* Reformat clang-format help strings, filter out irrelevant options.Alexander Kornienko2013-05-101-27/+52
| | | | | | | | | | | | | | Summary: +updated ClangFormat.rst Reviewers: djasper, klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D780 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181617 91177308-0d34-0410-b5e6-96231b3b80d8
* Updated clang-format help messages for -offset and -lengthAlexander Kornienko2013-05-101-7/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181593 91177308-0d34-0410-b5e6-96231b3b80d8
* Minor clarifications in help messages and a comment.Alexander Kornienko2013-05-101-2/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181591 91177308-0d34-0410-b5e6-96231b3b80d8
* Config file support for clang-format, part 2.Alexander Kornienko2013-05-101-14/+50
| | | | | | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181589 91177308-0d34-0410-b5e6-96231b3b80d8
* Added Mozilla style, cleaned get*Style methods.Alexander Kornienko2013-05-061-2/+7
| | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181196 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format support for multiple input files.Alexander Kornienko2013-04-241-20/+57
| | | | | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180185 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove outdated part of help message.Daniel Jasper2013-04-081-1/+0
| | | | | | | The styles are now documented with the -style option. This fixes llvm.org/PR15689. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179017 91177308-0d34-0410-b5e6-96231b3b80d8
* Add clang-format binary to cfe.Daniel Jasper2013-03-201-0/+152
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177506 91177308-0d34-0410-b5e6-96231b3b80d8