summaryrefslogtreecommitdiffstats
path: root/clang/test/Format
Commit message (Collapse)AuthorAgeFilesLines
* [clang-format] Proposal for clang-format to give compiler style warningsPaul Hoad2019-10-132-0/+8
| | | | | | relanding {D68554} with fixed lit tests, checked on Windows and MacOS llvm-svn: 374720
* Revert r374663 "[clang-format] Proposal for clang-format to give compiler ↵Nico Weber2019-10-122-8/+0
| | | | | | | | | | style warnings" The test fails on macOS and looks a bit wrong, see comments on the review. Also revert follow-up r374686. llvm-svn: 374688
* [clang-format] Proposal for clang-format to give compiler style warningsPaul Hoad2019-10-122-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Related somewhat to {D29039} On seeing a quote on twitter by @invalidop > If it's not formatted with clang-format it's a build error. This made me want to change the way I use clang-format into a tool that could optionally show me where my source code violates clang-format syle. When I'm making a change to clang-format itself, one thing I like to do to test the change is to ensure I didn't cause a huge wave of changes, what I want to do is simply run this on a known formatted directory and see if any new differences arrive in a manner I'm used to. This started me thinking that we should allow build systems to run clang-format on a whole tree and emit compiler style warnings about files that fail clang-format in a form that would make them as a warning in most build systems and because those build systems range in their construction I don't think its unreasonable to NOT expect them to have to do the directory searching or parsing the output replacements themselves, but simply transform that into an error code when there are changes required. I am starting this by suggesing adding a -n or -dry-run command line argument which would emit a warning/error of the form Support for various common compiler command line argumuments like '-Werror' and '-ferror-limit' could make this very flexible to be integrated into build systems and CI systems. ``` > $ /usr/bin/clang-format --dry-run ClangFormat.cpp -ferror-limit=3 -fcolor-diagnostics > ClangFormat.cpp:54:29: warning: code should be clang-formatted [-Wclang-format-violations] > static cl::list<std::string> > ^ > ClangFormat.cpp:55:20: warning: code should be clang-formatted [-Wclang-format-violations] > LineRanges("lines", cl::desc("<start line>:<end line> - format a range of\n" > ^ > ClangFormat.cpp:55:77: warning: code should be clang-formatted [-Wclang-format-violations] > LineRanges("lines", cl::desc("<start line>:<end line> - format a range of\n" > ^ ``` Reviewers: mitchell-stellar, klimek, owenpan Reviewed By: klimek Subscribers: mgorny, cfe-commits Tags: #clang-format, #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D68554 llvm-svn: 374663
* Re-land Remove REQUIRES:shell from tests that pass for me on WindowsReid Kleckner2019-09-101-1/+1
| | | | | | | | | | | | This reverts r371497 (git commit 3d7e9ab7b9f8c53aa41420c54970f0fb421004a2) Reorder `not` with `env` in these two tests so they pass: Driver/rewrite-map-in-diagnostics.c Index/crash-recovery-modules.m. This will not be necessary after D66531 lands. llvm-svn: 371552
* Revert Remove REQUIRES:shell from tests that pass for me on WindowsJames Henderson2019-09-101-1/+1
| | | | | | This reverts r371478 (git commit a9980f60ce083fa6d5fd03c12c58ca0b293e3d60) llvm-svn: 371497
* Remove REQUIRES:shell from tests that pass for me on WindowsReid Kleckner2019-09-101-1/+1
| | | | | | | | | | | | | I see in the history for some of these tests REQUIRES:shell was used as a way to disable tests on Windows because they are flaky there. I tried not to re-enable such tests, but it's possible that I missed some and this will re-enable flaky tests on Windows. If so, we should disable them with UNSUPPORTED:system-windows and add a comment that they are flaky there. So far as I can tell, the lit internal shell is capable of running all of these tests, and we shouldn't use REQUIRES:shell as a proxy for Windows. llvm-svn: 371478
* [clang-format][tests] Explicitly specify style in some testsRafael Stahl2019-07-124-5/+5
| | | | | | | | | | | | | | | | Summary: This fixes broken tests when doing an out-of-source build that picks up a random .clang-format on the file system due to the default "file" style. Reviewers: djasper, klimek, MyDeveloperDay, krasimir Reviewed By: MyDeveloperDay Subscribers: lebedev.ri, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61001 llvm-svn: 365909
* [clang-format] Fix bug where -dump-config failed on ObjC headerBen Hamilton2018-01-293-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: `clang-format -dump-config path/to/file.h` never passed anything for the Code parameter to clang::format::getStyle(). This meant the logic to guess Objective-C from the contents of a .h file never worked, because LibFormat didn't have the code to work with. With this fix, we now correctly read in the contents of the file if possible with -dump-config. I had to update the lit config for test/Format/ because the default config ignores .h files. Test Plan: make -j12 check-clang Reviewers: jolesiak, krasimir Reviewed By: jolesiak, krasimir Subscribers: Wizard, klimek, cfe-commits, djasper Differential Revision: https://reviews.llvm.org/D42395 llvm-svn: 323668
* [clang] Get rid of "%T" expansionsKuba Mracek2017-08-151-9/+10
| | | | | | | | | | The %T lit expansion expands to a common directory shared between all the tests in the same directory, which is unexpected and unintuitive, and more importantly, it's been a source of subtle race conditions and flaky tests. In https://reviews.llvm.org/D35396, it was agreed that it would be best to simply ban %T and only keep %t, which is unique to each test. When a test needs a temporary directory, it can just create one using mkdir %t. This patch removes %T in clang. Differential Revision: https://reviews.llvm.org/D36437 llvm-svn: 310950
* clang-format: add an option -verbose to list the files being processedSylvestre Ledru2017-08-121-0/+16
| | | | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D34824 llvm-svn: 310778
* [clang-format] Replace IncompleteFormat by a struct with LineKrasimir Georgiev2017-04-211-1/+1
| | | | | | | | | | | | | | Summary: This patch replaces the boolean IncompleteFormat that is used to notify the client if an unrecoverable syntax error occurred by a struct that also contains a line number. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32298 llvm-svn: 300985
* clang/test/Format/inplace.cpp: Avoid using wildcard.NAKAMURA Takumi2017-02-281-4/+6
| | | | | | MSYS' tools don't do globbing. llvm-svn: 296460
* [clang-format] Fix test failure caused by "rm" on some buildbots.Haojian Wu2017-02-281-1/+0
| | | | | | | | | The begining command "rm" will return 1 when there is not such file to delete. This patch is to remove it, as it's not needed for the test. llvm-svn: 296453
* 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
OpenPOWER on IntegriCloud