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
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
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
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
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
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
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
RefactoringTool::run() no longer writes changes to disk automatically. Updating users of RefactoringTool to explicitly perform the write.
Reviewers: klimek
llvm-svn: 172218
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
- 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
- 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
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
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
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
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
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
- 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
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