summaryrefslogtreecommitdiffstats
path: root/clang/test/Format
Commit message (Collapse)AuthorAgeFilesLines
* clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, ↵Nico Weber2017-02-271-0/+263
| | | | | | | | | | | | | | | | | | reloaded Second attempt after http://llvm.org/viewvc/llvm-project?rev=296166&view=rev In the first attempt, Code (the memory buffer backing the input file) was reset before overwriteChangedFiles() was called, but overwriteChangedFiles() still reads from it. This time, load the whole input file into memory instead of using mmap when formatting in-place. (Since the test is identical to what was in the repo before chapuni's revert, svn diff doesn't show it – see the above link for the test.) https://reviews.llvm.org/D30385 llvm-svn: 296408
* Revert r296166, "clang-format: Don't leave behind temp files in -i mode on ↵NAKAMURA Takumi2017-02-251-263/+0
| | | | | | | | | | | | | | | | | | | | | Windows, PR26125", and r296171. (MemoryBuffer)Code.reset() was too early. ==26912== Invalid read of size 1 ==26912== at 0x437E1D: llvm::MemoryBuffer::init(char const*, char const*, bool) (MemoryBuffer.cpp:47) ==26912== by 0x438013: (anonymous namespace)::MemoryBufferMem::MemoryBufferMem(llvm::StringRef, bool) (MemoryBuffer.cpp:86) ==26912== by 0x438128: llvm::MemoryBuffer::getMemBuffer(llvm::StringRef, llvm::StringRef, bool) (MemoryBuffer.cpp:112) ==26912== by 0x4E189D: clang::vfs::detail::(anonymous namespace)::InMemoryFileAdaptor::getBuffer(llvm::Twine const&, long, bool, bool) (VirtualFileSystem.cpp:443) ==26912== by 0x4DF5BA: clang::vfs::FileSystem::getBufferForFile(llvm::Twine const&, long, bool, bool) (VirtualFileSystem.cpp:94) ==26912== by 0x4B72EC: clang::FileManager::getBufferForFile(clang::FileEntry const*, bool, bool) (FileManager.cpp:443) ==26912== by 0x4C1F81: clang::SrcMgr::ContentCache::getBuffer(clang::DiagnosticsEngine&, clang::SourceManager const&, clang::SourceLocation, bool*) const (SourceManager.cpp:98) ==26912== by 0x4C50E5: clang::SourceManager::getBufferData(clang::FileID, bool*) const (SourceManager.cpp:689) ==26912== by 0x58E794: clang::Rewriter::getEditBuffer(clang::FileID) (Rewriter.cpp:230) ==26912== by 0x407297: clang::format::format(llvm::StringRef) (ClangFormat.cpp:311) ==26912== by 0x4078D7: main (ClangFormat.cpp:363) llvm-svn: 296237
* Try to unbreak tests after r296166Nico Weber2017-02-241-1/+1
| | | | | | | | Looks like %T isn't per-test but per-test-directory, and the rm was deleting temp files written by other tests in test/Format. Limit the rm's scope a bit. llvm-svn: 296171
* clang-format: Don't leave behind temp files in -i mode on Windows, PR26125Nico Weber2017-02-241-0/+263
| | | | | | Fix and analysis by Wei Mao <weimao1@gmail.com> (see bug), test by me. llvm-svn: 296166
* clang-format: remove tests that assume no config file will be found as this ↵Antonio Maiorano2017-01-231-11/+4
| | | | | | | | | | | | | is not always the case These tests fail for developers who place their build directories under the llvm root directory because llvm's own .clang-format file will be found. Anyway these cases are covered by FormatStyle.GetStyleOfFile tests (FormatTest.cpp). Differential Revision: https://reviews.llvm.org/D28983 llvm-svn: 292787
* [clang-format] Remove redundant test in style-on-command-line.cppKrasimir Georgiev2017-01-201-9/+6
| | | | | | | | | | | | | | | | | | | | | Summary: rL292562 added a fix to always format if the fallback style is set to "none". In test/Format/style-on-command-line.cpp:19 is redundant, since -fallback-style has a default value of LLVM set in ClangFormat.cpp:72. @amaiorano: I believe that the rest of the test cases still cover your change in case the fallback style is explicitly set to "none". Please, if this is not the case, initiate a discussion. Reviewers: ioeric, bkramer Reviewed By: ioeric Subscribers: cfe-commits, klimek, amaiorano Differential Revision: https://reviews.llvm.org/D28943 llvm-svn: 292604
* clang-format: fix fallback style set to "none" not always formattingAntonio Maiorano2017-01-201-0/+20
| | | | | | | | | | | This fixes clang-format not formatting if fallback-style is explicitly set to "none", and either a config file is found or YAML is passed in without a "BasedOnStyle". With this change, passing "none" in these cases will have no affect, and LLVM style will be used as the base style. Differential Revision: https://reviews.llvm.org/D28844 llvm-svn: 292562
* clang-format: Make GetStyle return Expected<FormatStyle> instead of FormatStyleAntonio Maiorano2017-01-171-8/+5
| | | | | | | | | | Change the contract of GetStyle so that it returns an error when an error occurs (i.e. when it writes to stderr), and only returns the fallback style when it can't find a configuration file. Differential Revision: https://reviews.llvm.org/D28081 llvm-svn: 292174
* Make clang-format remove duplicate headers when sorting #includes.Eric Liu2016-08-101-0/+14
| | | | | | | | | | | | Summary: When sorting #includes, #include directives that have the same text will be deduplicated when sorting #includes, and only the first #include in the duplicate #includes remains. If the `Cursor` is provided and put on a deleted #include, it will be put on the remaining #include in the duplicate #includes. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D23274 llvm-svn: 278206
* Fix clang-format test. I believe that the new behavior is better.Daniel Jasper2015-11-231-1/+1
| | | | llvm-svn: 253861
* clang-format: Enable #include sorting by default.Daniel Jasper2015-11-161-0/+10
| | | | | | | | | This has seen quite some usage and I am not aware of any issues. Also add a style option to enable/disable include sorting. The existing command line flag can from now on be used to override whatever is set in the style. llvm-svn: 253202
* clang-format: When a line is formatted, also format subsequence lines if ↵Daniel Jasper2015-10-283-9/+19
| | | | | | | | | | | | | | their indent is off. Summary: This is especially important so that if a change is solely inserting a block around a few statements, clang-format-diff.py will still clean up and add indentation to the inner parts. Reviewers: klimek Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D14105 llvm-svn: 251474
* clang-format: Use pipes instead of temporary files for most lit tests.Nico Weber2015-10-199-34/+31
| | | | | | | | | | | | | | | This makes the format tests look more like most other FileCheck tests in clang. The multiple-inputs tests still use temp files, to make sure that the file input code in clang-format stays tested. Stop stripping out the comment lines in style-on-command-line.cpp as they don't get in the way and it makes the test simpler. Also remove 2>&1s on the tests in that file that don't need it. http://reviews.llvm.org/D13852 llvm-svn: 250706
* clang-format: Add test for (properly escaped) XML output.Daniel Jasper2015-10-171-0/+12
| | | | llvm-svn: 250629
* Disable style-on-command-line test on WindowsReid Kleckner2015-06-091-0/+4
| | | | llvm-svn: 239416
* Remove rm invocations where the file is immediately rewritten later.Benjamin Kramer2015-06-091-3/+1
| | | | | | | This may or may not help making this test less flaky on windows. There's a race condition in lit somewhere. llvm-svn: 239402
* Remove error message when using the fallback style.Manuel Klimek2015-06-021-1/+0
| | | | llvm-svn: 238822
* Reapply r236854 and fixed r236867.Daniel Jasper2015-05-102-1/+9
| | | | | | | Makes emacs show a different message when clang-format encountered a syntax error. llvm-svn: 236943
* Revert "Make emacs show when clang-format encountered a syntax error."Tobias Grosser2015-05-082-9/+1
| | | | | | | | | | | This reverts commit 236854, which caused clang-format to always print '{ "IncompleteFormat": false }' at the top of an incompletely formatted file. This output causes problems e.g. in Polly's automatic formatting checks. Daniel tried to fix this in 236867, but this fix had to be reverted due to buildbot failures. I revert this change as well for now as it is Friday night and unlikely to be fixed immediately. llvm-svn: 236908
* Revert "clang-format: Only output IncompleteFormat if -cursor is given."Renato Golin2015-05-081-2/+2
| | | | | | | This reverts commit r236867, as it was breaking multiple buildbots. Daniel will look into it later. llvm-svn: 236882
* clang-format: Only output IncompleteFormat if -cursor is given.Daniel Jasper2015-05-081-2/+2
| | | | | | This is only for editor integrations. llvm-svn: 236867
* Make emacs show when clang-format encountered a syntax error.Manuel Klimek2015-05-082-1/+9
| | | | | | | Propagate the 'incomplete-format' state back through clang-format's command line interace and adapt the emacs integration to show a better result. llvm-svn: 236854
* Revert "clang/test/Driver/crash-report.c: This requires rewriter for ↵Alp Toker2014-07-161-2/+0
| | | | | | | | | | | | | | | | | | | | | -frewrite-includes. [PR20321]" We've decided to make the core rewriter class and PP rewriters mandatory. They're only a few hundred lines of code in total and not worth supporting as a distinct build configuration, especially since doing so disables key compiler features. This reverts commit r213150. Revert "clang/test: Introduce the feature "rewriter" for --enable-clang-rewriter." This reverts commit r213148. Revert "Move clang/test/Frontend/rewrite-*.c to clang/test/Frontend/Rewriter/" This reverts commit r213146. llvm-svn: 213159
* clang/test: Introduce the feature "rewriter" for --enable-clang-rewriter.NAKAMURA Takumi2014-07-161-0/+2
| | | | llvm-svn: 213148
* clang-format: Introduce style with spaces on both sides of */&.Daniel Jasper2014-06-171-0/+4
| | | | | | | Patch by Janusz Sobczak (slightly extended). This fixes llvm.org/19929. llvm-svn: 211098
* Allow lowercase messages in this test again.Rafael Espindola2014-06-121-3/+3
| | | | | | I misunderstood where the message was being converted. llvm-svn: 210774
* Give clang-format its own error category.Rafael Espindola2014-06-121-3/+3
| | | | | | | | | The posix errno values are probably to the best thing to use for describing parse errors. This should also fix the mingw build. llvm-svn: 210739
* Accomodate for message differences on windows.Rafael Espindola2014-06-111-3/+3
| | | | llvm-svn: 210722
* clang-format: Add basic test for -style=none.Daniel Jasper2014-05-221-0/+6
| | | | llvm-svn: 209447
* clang-format: Explicitly set fallback style that is tested.Daniel Jasper2013-12-031-2/+2
| | | | llvm-svn: 196213
* Added an option to specify fallback style.Alexander Kornienko2013-12-021-2/+3
| | | | | | | | | | | | | | | | 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
* Added LanguageStandard::LS_JavaScript to gate all JS-specific parsing.Alexander Kornienko2013-11-291-0/+7
| | | | | | | | | | | | | | | | Summary: Use LS_JavaScript for files ending with ".js". Added support for ">>>=" operator. Reviewers: djasper, klimek Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2242 llvm-svn: 195961
* Disable this check temporarily.Bill Wendling2013-11-191-1/+1
| | | | | | | | | | | | | | | This is failing for me. When I run the command on my own, I get this: Error reading /usr/local/google/home/morbo/llvm/llvm.obj/tools/clang/test/Format/Output/.clang-format: Invalid argument void f() { int* i; int j; } The formatting is like this because I have the Google format version in my ~/.clang-format file. This test should be made independent of that. llvm-svn: 195080
* Allow _clang-format as alternative to .clang-format config filenameHans Wennborg2013-09-101-0/+5
| | | | | | | | | | | 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
* Trying to fix tests with in-tree builds, that contain a .clang-format files inAlexander Kornienko2013-09-021-2/+2
| | | | | | both tools/clang and llvm directories. llvm-svn: 189761
* Test for empty .clang-format file.Alexander Kornienko2013-09-021-0/+4
| | | | | | | | | | | | | | Summary: Test clang-format's handling of empty .clang-format files. Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D1562 llvm-svn: 189757
* Switch the default mode for clang-format to '-file'. Make 'LLVM' theChandler Carruth2013-09-021-5/+2
| | | | | | | | | | | | | | | | | | | 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
* [tests] Use 'printf' instead of 'echo -e', which is not part of BSD echo.Daniel Dunbar2013-08-291-1/+1
| | | | llvm-svn: 189562
* Added -lines X:Y option to specify line range to process. This is a more ↵Alexander Kornienko2013-07-182-1/+14
| | | | | | | | human-friendly alternative to -offset and -length. Differential Revision: http://llvm-reviews.chandlerc.com/D1160 llvm-svn: 186625
* Add 'not' to commands that are expected to fail.Rafael Espindola2013-07-041-1/+1
| | | | | | | This is at least good documentation, but also opens the possibility of using pipefail. llvm-svn: 185652
* Let clang-format move the cursor appropriately.Daniel Jasper2013-05-211-0/+6
| | | | | | | | | 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-0/+23
| | | | | | | | | | | | | | 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
* Remove diagnostics from clang-format.Daniel Jasper2013-05-151-4/+0
| | | | | | | We only ever implemented one and that one is not actually all that helpful (e.g. gets incorrectly triggered by macros). llvm-svn: 181871
* clang-format support for multiple input files.Alexander Kornienko2013-04-243-0/+21
| | | | | | | | | | | | | | | | | | | 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
* Provide better emacs integration.Daniel Jasper2013-04-122-2/+2
| | | | | | | | | | | 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
* Re-add clang-format tests to clang/test.Daniel Jasper2013-03-253-0/+21
Also now use -strict-whitespace as the tests are confusing otherwise. llvm-svn: 177853
OpenPOWER on IntegriCloud