Commit Graph

81 Commits

Author SHA1 Message Date
Manuel Klimek f92b666da9 Adapt test to new clang-format behavior.
llvm-svn: 174738
2013-02-08 20:04:33 +00:00
Edwin Vane 37fea69391 Fix for combined loop and nullptr convert tests
The rewriter was previously reading the content buffer from the file itself.
Since we are now keeping the content in memory and writing to the file only
once, the rewriter's buffer (from the file) was not in sync with the
RefactoringTool's buffer. Adding an overrideFileContents call (similar to how
Clang-format handles for this) will resolve this issue.

Author: Jack Yang <jack.yang@intel.com>
Reviewers: gribozavr, klimek
llvm-svn: 174643
2013-02-07 18:49:23 +00:00
Daniel Jasper d1a6659263 Remove superseeded option.
The -invert-pointer-binding option will be superseeded by my next
cfe-commit. Instead of explicitly overwriting this flag, clang-format
can then be configured to auto-detect certain style-options based on the
input file.

llvm-svn: 174503
2013-02-06 14:22:17 +00:00
Manuel Klimek 5e5e1c3b80 Add xml:space='preserve' in order to correctly preserve whitespace.
llvm-svn: 174502
2013-02-06 12:40:01 +00:00
Manuel Klimek 1882ad9905 Kick JSON output for XML output.
Apparently the owners of the tools we want to integrate with (eclipse in
this case) don't have JSON parsers.

The output now is:
<replacements>
<replacement offset='2' length='3'>  </replacement>
...
</replacements>

Kicking JSON for now - it's easy enough to get back in when we need it.

FIXME: once we find this useful enough, we might want to add it as
free-standing functions to tooling.

llvm-svn: 174497
2013-02-06 09:42:05 +00:00
Manuel Klimek 65bdeae121 Adds JSON output for replacements, to simplify tools integration.
Using -output-replacements will now output the replacements instead
of the changed code. This allows easier integration with tools that
need full control over what changed.

The format is an array of objects with the members "offset" (number),
"length" (number) and "replacement_text" (string), for example:

[
  {
    "offset": 42,
    "length": 5,
    "replacement_text": "  "
  },
  {
    "offset": 105,
    "length": 4,
    "replacement_text": ""
  }
]

llvm-svn: 174382
2013-02-05 15:52:21 +00:00
Manuel Klimek 8c651f0974 Implements support for specifying multiple ranges.
This is backwards compatible with earlier integrations.
Also adds a basic test and a test for the ranges integration.

You can now run:
clang-format -offset=42 -length=15 -offset=150 -length=22
To re-format the ranges (42, +15) and (150, +22).

llvm-svn: 174378
2013-02-05 15:25:34 +00:00
Daniel Jasper 21cdc848f4 Don't touch unchanged file for in-place edit.
This fixes llvm.org/PR15087.

llvm-svn: 173919
2013-01-30 09:52:38 +00:00
NAKAMURA Takumi 6fb75e08e5 test/remove-cstr-calls/basic.cpp: Disable again on mingw. It behaves unstable.
llvm-svn: 173562
2013-01-26 06:39:48 +00:00
NAKAMURA Takumi fc37344916 Drop "REQUIRES:shell" in tests. They can run on win32.
llvm-svn: 173415
2013-01-25 04:33:40 +00:00
Edwin Vane 44c3145938 Add use-nullptr transform to cpp11-migrate
This transform converts the usage of null pointer constants (e.g. NULL, 0,
etc.) in legacy C++ code and converts them to use the new C++11 nullptr
keyword.
- Added use-nullptr transform.
- Added C++11 support to the final syntax check. Used ArgumentAdjuster class to
  add -std=c++11 option to the command line options.
- Added tests for use-nullptr transform.
- Added tests that exercises both loop-convert and use-nullptr in the source
  file.

TODO: There's a known bug when using both -loop-convert and -use-nullptr at the
      same time.

Author: Tareq A Siraj <tareq.a.siraj@intel.com>
Reviewers: klimek, gribozavr
llvm-svn: 173178
2013-01-22 18:31:49 +00:00
Chris Lattner 28b00bffd2 these need the bitcode reader as well.
llvm-svn: 172908
2013-01-19 18:45:35 +00:00
Chandler Carruth 06e24e34a9 Re-sort the #include lines which have gotten out of order.
llvm-svn: 172895
2013-01-19 09:10:38 +00:00
NAKAMURA Takumi 40ac112c91 Introduce llvm::sys::PrintStackTraceOnErrorSignal()
llvm-svn: 172821
2013-01-18 14:31:00 +00:00
Dmitri Gribenko 3de75d7c7c Fix a -Wdocumentation warning (empty paragraph passed to '\brief' command)
llvm-svn: 172661
2013-01-16 22:10:09 +00:00
Edwin Vane 862fec8835 Write transform results to disk only once
Instead of writing the result of each transform to disk for every
transform, write the results to buffers in memory and pass those buffers
to the next transform as input. Only write the buffers to disk if the
final syntax check passes.

Reviewers: klimek
llvm-svn: 172657
2013-01-16 21:11:50 +00:00
Daniel Jasper 9f4a1c6184 Add temporary option to invert the */& binding in a specific style.
This is temporarily necessary until styles are configurable through files
as it seems to be a contentious issue.

llvm-svn: 172546
2013-01-15 18:56:19 +00:00
Alexander Kornienko 02fd3ad24b Test source file name in diagnostics
llvm-svn: 172434
2013-01-14 17:01:57 +00:00
Daniel Jasper 51ce63cd98 Add support for Chromium style.
llvm-svn: 172432
2013-01-14 16:26:38 +00:00
Edwin Vane d44cbf7d09 Adding a .gitignore to tools-extra
Reviewers: klimek

llvm-svn: 172414
2013-01-14 14:20:19 +00:00
Alexander Kornienko 92bb086fba Added a test for clang-format diagnostics.
llvm-svn: 172407
2013-01-14 13:57:05 +00:00
Alexander Kornienko 79f49456fa Fix: correct file name in diagnostics.
llvm-svn: 172405
2013-01-14 13:40:44 +00:00
Edwin Vane bfbd10b329 Update users of RefactoringTool
RefactoringTool::run() no longer writes changes to disk automatically. Updating users of RefactoringTool to explicitly perform the write.
    
Reviewers: klimek

llvm-svn: 172218
2013-01-11 17:04:09 +00:00
Nico Weber e5d643d21c Remove FIXME fixed by djasper in r172066.
llvm-svn: 172097
2013-01-10 19:48:53 +00:00
Alexander Kornienko 92465285ab Format what you can when errors are found
llvm-svn: 172075
2013-01-10 15:19:44 +00:00
Edwin Vane 86c63d94bb Removing loop-convert tool
cpp11-migrate now contains the loop convert transform code and tests.
Cleaning up the old code/tests and updating build system files as
necessary.

Reviewers: klimek
llvm-svn: 172074
2013-01-10 15:19:11 +00:00
Alexander Kornienko 5b64279192 Improved clang-format integration support for diagnostic messages output
llvm-svn: 172072
2013-01-10 15:06:57 +00:00
Daniel Jasper 494394d817 Let clang-format binary use same LangOpts as test.
llvm-svn: 172066
2013-01-10 13:09:09 +00:00
Alex Rosenberg eb8360003b Add .arcconfig for Arcanist support for Phabricator
llvm-svn: 172043
2013-01-10 04:12:08 +00:00
Alex Rosenberg 0b18a095cf Fix comment
llvm-svn: 172042
2013-01-10 04:12:06 +00:00
Daniel Jasper abf4cce40f Simplify reversed for-loop.
llvm-svn: 171998
2013-01-09 20:46:42 +00:00
Daniel Jasper 46e432fb8a Initial version of diff/patch-reformat tool.
Use at your own risk :-).

llvm-svn: 171994
2013-01-09 20:20:11 +00:00
Manuel Klimek 3a449891ba Implements the features requested in PR14679.
- adds '-h' as an alias for '-help'.
- adds an optional <file> argument
- adds an option -i to in-place edit the given file
- adds a help text to explain what the tool does

llvm-svn: 171858
2013-01-08 15:19:57 +00:00
Edwin Vane 31896624da Transferred loop-convert tests to cpp11-migrate
- Turned off -count-only tests as they aren't supported in cpp11-migrate
  yet.
- Updated tests to use new binary name and options to access
  loop-convert transform.
- Fixed header guards to not use restricted names.

Reviewers: klimek, gribozavr
llvm-svn: 171852
2013-01-08 14:36:29 +00:00
Nico Weber 48e75f7e48 Enabled ObjC2 in clang-format for @package. Matches r171766.
llvm-svn: 171767
2013-01-07 19:08:19 +00:00
Nico Weber d9a440d21f Set LangOpts.ObjC1 to 1 in clang-format.
This matches the test change done in clang at r171742. Without this,
clang-format would strip '@' characters and format e.g. '@interface' as
'interface'.

llvm-svn: 171743
2013-01-07 15:21:13 +00:00
Daniel Jasper f7b48b6342 Make clang-format binary understand C++11.
llvm-svn: 171736
2013-01-07 14:52:14 +00:00
Chandler Carruth 08116a7df3 Add a namespace qualifier to the befriending statement for
RecusiveASTVisitor. With Clang and modern GCCs this was found through
the injected class name of the base class but older GCCs don't properly
implement the injected class name rules.

llvm-svn: 171593
2013-01-05 02:57:54 +00:00
Edwin Vane dde168b8b5 Port loop-convert into cpp11-migrate
Took existing code from loop-convert tool and made it into a cpp11-migrate
transform. Pattern now set for having transform code in subdirectories. Related
changes:
- Makefile and CMakeLists.txt updated to support source files in
  subdirectories.
- At least one transform must be specified. syntax-only tests removed to
  reflect this.
- TODO: port over loop-convert tests.

Reviewers: klimek, silvas
llvm-svn: 171481
2013-01-04 18:25:18 +00:00
Daniel Jasper f0273f8e15 Handle segfaults in clang-format vim-integration.
A segfault used to clear the entire buffer. With this change, a message
to report a bug is displayed instead.

This should solve most cases similar to llvm.org/PR14774.

llvm-svn: 171480
2013-01-04 18:24:12 +00:00
Chandler Carruth 54e147a933 Fix the sorting of the #include lines in these tools.
This is done with the script in llvm/utils/sort_includes.py

llvm-svn: 171365
2013-01-02 10:29:31 +00:00
NAKAMURA Takumi 43632a26a5 Update the copyright coredits -- Happy new year 2013!
llvm-svn: 171342
2013-01-01 10:00:19 +00:00
Chandler Carruth 5826f96e51 Teach the extras repository to actually install the clang-format tool.
We should also install the clang-format.py script somewhere that makes
since for a Vim integration script. I don't know where that is though,
so just installing the binary for now. This is enough to let me use the
script from a checkout combined with the installed (and thus less likely
to crash or be slow) clang-format binary.

llvm-svn: 171164
2012-12-27 17:48:37 +00:00
Edwin Vane 9e3c9de527 Use renamed CommonOptionsParser member functions
GetCompilations() and GetSourcePathLists() were renamed to match LLVM style.

Reviewed By: Alexander Kornienko

llvm-svn: 170230
2012-12-14 18:59:24 +00:00
Edwin Vane 3d97cc4c57 Add cpp11-migrate to autoconf build
llvm-svn: 169986
2012-12-12 16:08:10 +00:00
Edwin Vane 9bd2e1bacc Initial commit for cpp11-migrate tool
- Added directory structures and build system files for the new tool.
- Extremely basic implementation of tool performs only an initial syntax check.
- Basic tests ensure syntax test works as expected.

llvm-svn: 169983
2012-12-12 14:30:57 +00:00
Daniel Jasper 79e68bcf0e Basic clang-format vim-integration.
File contains installation and usage instructions.

llvm-svn: 169421
2012-12-05 21:06:08 +00:00
Daniel Jasper 95b089e287 Fix make build (hopefully).
llvm-svn: 169371
2012-12-05 10:22:07 +00:00
Daniel Jasper ff1491322e First version of a command line clang-format tool.
Reads a single source range (offset, length) as well as the style guide
as parameters and then reformats everything it receives from stdin.

llvm-svn: 169364
2012-12-05 09:01:09 +00:00
Chandler Carruth 9b1773b517 Update the #include lines of the extra tools.
llvm-svn: 169239
2012-12-04 09:21:50 +00:00