summaryrefslogtreecommitdiff
path: root/test/Format
AgeCommit message (Collapse)Author
2017-08-15[clang] Get rid of "%T" expansionsKuba Mracek
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310950 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-12clang-format: add an option -verbose to list the files being processedSylvestre Ledru
Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D34824 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310778 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-21[clang-format] Replace IncompleteFormat by a struct with LineKrasimir Georgiev
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300985 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-28clang/test/Format/inplace.cpp: Avoid using wildcard.NAKAMURA Takumi
MSYS' tools don't do globbing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296460 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-28[clang-format] Fix test failure caused by "rm" on some buildbots.Haojian Wu
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296453 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-27clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, ↵Nico Weber
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296408 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-25Revert r296166, "clang-format: Don't leave behind temp files in -i mode on ↵NAKAMURA Takumi
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) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296237 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-24Try to unbreak tests after r296166Nico Weber
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296171 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-24clang-format: Don't leave behind temp files in -i mode on Windows, PR26125Nico Weber
Fix and analysis by Wei Mao <weimao1@gmail.com> (see bug), test by me. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296166 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-23clang-format: remove tests that assume no config file will be found as this ↵Antonio Maiorano
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@292787 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20[clang-format] Remove redundant test in style-on-command-line.cppKrasimir Georgiev
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@292604 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20clang-format: fix fallback style set to "none" not always formattingAntonio Maiorano
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@292562 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17clang-format: Make GetStyle return Expected<FormatStyle> instead of FormatStyleAntonio Maiorano
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@292174 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-10Make clang-format remove duplicate headers when sorting #includes.Eric Liu
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@278206 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-23Fix clang-format test. I believe that the new behavior is better.Daniel Jasper
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253861 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-16clang-format: Enable #include sorting by default.Daniel Jasper
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253202 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-28clang-format: When a line is formatted, also format subsequence lines if ↵Daniel Jasper
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251474 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-19clang-format: Use pipes instead of temporary files for most lit tests.Nico Weber
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250706 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-17clang-format: Add test for (properly escaped) XML output.Daniel Jasper
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250629 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-09Disable style-on-command-line test on WindowsReid Kleckner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239416 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-09Remove rm invocations where the file is immediately rewritten later.Benjamin Kramer
This may or may not help making this test less flaky on windows. There's a race condition in lit somewhere. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239402 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-02Remove error message when using the fallback style.Manuel Klimek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238822 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-10Reapply r236854 and fixed r236867.Daniel Jasper
Makes emacs show a different message when clang-format encountered a syntax error. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236943 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-08Revert "Make emacs show when clang-format encountered a syntax error."Tobias Grosser
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236908 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-08Revert "clang-format: Only output IncompleteFormat if -cursor is given."Renato Golin
This reverts commit r236867, as it was breaking multiple buildbots. Daniel will look into it later. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236882 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-08clang-format: Only output IncompleteFormat if -cursor is given.Daniel Jasper
This is only for editor integrations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236867 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-08Make emacs show when clang-format encountered a syntax error.Manuel Klimek
Propagate the 'incomplete-format' state back through clang-format's command line interace and adapt the emacs integration to show a better result. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236854 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-16Revert "clang/test/Driver/crash-report.c: This requires rewriter for ↵Alp Toker
-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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213159 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-16clang/test: Introduce the feature "rewriter" for --enable-clang-rewriter.NAKAMURA Takumi
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213148 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-17clang-format: Introduce style with spaces on both sides of */&.Daniel Jasper
Patch by Janusz Sobczak (slightly extended). This fixes llvm.org/19929. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211098 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-12Allow lowercase messages in this test again.Rafael Espindola
I misunderstood where the message was being converted. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210774 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-12Give clang-format its own error category.Rafael Espindola
The posix errno values are probably to the best thing to use for describing parse errors. This should also fix the mingw build. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210739 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-11Accomodate for message differences on windows.Rafael Espindola
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210722 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-22clang-format: Add basic test for -style=none.Daniel Jasper
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209447 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-03clang-format: Explicitly set fallback style that is tested.Daniel Jasper
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196213 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-02Added an option to specify fallback style.Alexander Kornienko
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196108 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-29Added LanguageStandard::LS_JavaScript to gate all JS-specific parsing.Alexander Kornienko
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195961 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19Disable this check temporarily.Bill Wendling
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195080 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10Allow _clang-format as alternative to .clang-format config filenameHans Wennborg
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
2013-09-02Trying to fix tests with in-tree builds, that contain a .clang-format files inAlexander Kornienko
both tools/clang and llvm directories. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189761 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-02Test for empty .clang-format file.Alexander Kornienko
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189757 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-02Switch the default mode for clang-format to '-file'. Make 'LLVM' theChandler Carruth
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
2013-08-29[tests] Use 'printf' instead of 'echo -e', which is not part of BSD echo.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189562 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-18Added -lines X:Y option to specify line range to process. This is a more ↵Alexander Kornienko
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
2013-07-04Add 'not' to commands that are expected to fail.Rafael Espindola
This is at least good documentation, but also opens the possibility of using pipefail. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185652 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-21Let clang-format move the cursor appropriately.Daniel Jasper
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
2013-05-19Clang-format: allow -style="{yaml/json}" on command lineAlexander Kornienko
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
2013-05-15Remove diagnostics from clang-format.Daniel Jasper
We only ever implemented one and that one is not actually all that helpful (e.g. gets incorrectly triggered by macros). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181871 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-24clang-format support for multiple input files.Alexander Kornienko
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
2013-04-12Provide better emacs integration.Daniel Jasper
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179372 91177308-0d34-0410-b5e6-96231b3b80d8