Summary:
The clang-apply-replacements process is now invoked to apply
replacements between applying transforms. This resulted in a massive
simplification of the tool:
- FileOverrides class no longer needed.
- Change tracking and code formatting no longer needed.
- No more dependency on libclangApplyReplacements.
- Final syntax check is easier to do directly now than with a separate
header/source pair.
Replacement handling stuff abstracted into a new header/source pair to
de-clutter ClangModernize.cpp somewhat.
Tests updated.
Differential Revision: http://llvm-reviews.chandlerc.com/D1836
llvm-svn: 192032
The tool now supports a collection of arguments to turn on and provide settings
for the formatting of code affected by applying replacements:
* --format turns on formatting (default style is LLVM)
* --style controls code style settings
* --style-config allows one to explicitly indicate where a style config file
lives.
The libclangApplyReplacements interface has a new function to turn Replacements
into Ranges to be used with tooling::reformat().
llvm-svn: 191667
This patch also fixes the case where a compilation database is autodetected from
source but the file itself cannot be found in the compilation database, it then
ignores the compilation database and transforms the file with c++11 support.
llvm-svn: 191213
- Limit the transform to const-ref and non-const value parameters only.
- Do not generate a replacement when the type is already a value.
See CM-139 for the bugs corresponding to this issue.
llvm-svn: 190212
clang-modernize can now transform headers properly and the experimental
-headers option is no longer necessary.
Remember, at least -include is necessary for indicating which headers
are allowed to be changed.
Differential Revision: http://llvm-reviews.chandlerc.com/D1610
llvm-svn: 190158
If transformations lead to changes that do not need reformatting, the
current strategy will not write those files. With this patch, we just
update the overall state with the changes due to reformatting, and then
write out everything.
llvm-svn: 190050
There is no reason to expect this tool to be limited to C++11, it seems
very likely to be of on-going interest. It seems likely to be useful for
modernizing even as new libraries come out in TSes and other formats
than a complete standard. Fundamentally, we need something a bit more
general. After some discussion on the list, going with
'clang-modernize'.
I've tried to do a reasonably comprehensive job of fixing up the names,
but I may still have missed some. Feel free to poke me if you spot any
fallout here. Things I've tried reasonably hard to find and fix:
- cpp11-migrate -> clang-modernize
- Migrator -> Modernizer
- Clean up the introductory documentation that was C++11 specific.
I'll also point out that this tool continues to delight me. =] Also,
a huge thanks to those who have so carefully, thoroughly documented the
tool. The docs here are simply phenomenal. Every tool should be this
well documented. I hope I have updated the documentation reasonably
well, but I'm not very good at documentation, so review much
appreciated.
llvm-svn: 189960
The NoProblemsDependencies.modularize test is failing on many buildbots.
I have also reverted the change in 189904 to disable that test for MSVC.
llvm-svn: 189957
Made changes throughout clang-tools-extra for the renaming of
clang-replace to clang-apply-replacements as per feedback from
community.
llvm-svn: 189832
Re-commit of r189691 and r189689 now with a proper autoconf fix.
Massive simplification of how replacements and file overrides are
handled by the migrator:
* Sources and headers are all treated the same.
* All replacements for a given translation unit are stored in the same
TranslationUnitReplacements structure.
* Change tracking is updated only from main file; no need for
propagating "is tracking" flag around.
* Transform base class no longer responsible for applying replacements.
They are simply stored and main() looks after deduplication and
application.
* Renamed -yaml-only to -serialize-replacements. Same restrictions apply:
Can only request one transform. New restriction: formatting cannot also
be turned on since it's basically a transform.
* If -serialize-replacements is requested, changes to files will not be
applied on disk.
* Changed behaviour of function generating names for serialized
replacements: Only the main source file goes into the name of the file
since a file may contain changes for multiple different files.
* Updated HeaderReplacements LIT test for new serialization behaviour.
* Replaced old test that ensures replacements are not serialized if
-serialize-replacements is not provided. New version ensures changes
are made directly to all files in the translation unit.
* Updated unit tests.
* Due to major simplification of structures in FileOverrides.h, the
FileOverridesTest is quite a bit simpler now.
llvm-svn: 189798
Revert "cpp11-migrate: Refactor for driver model of operation"
This reverts commit r189691.
This reverts commit r189689.
This was breaking the phase 1 OS X build for ~2 hours.
https://smooshbase.apple.com/buildbot-internal/builders/phase1%20-%20sanity/builds/9559
I reverted the latter commit since I think the latter depended on the former.
llvm-svn: 189700
Massive simplification of how replacements and file overrides are handled by
the migrator:
* Sources and headers are all treated the same.
* All replacements for a given translation unit are stored in the same
TranslationUnitReplacements structure.
* Change tracking is updated only from main file; no need for
propagating "is tracking" flag around.
* Transform base class no longer responsible for applying replacements.
They are simply stored and main() looks after deduplication and
application.
* Renamed -yaml-only to -serialize-replacements. Same restrictions apply:
Can only request one transform. New restriction: formatting cannot also
be turned on since it's basically a transform.
* If -serialize-replacements is requested, changes to files will not be
applied on disk.
* Changed behaviour of function generating names for serialized
replacements: Only the main source file goes into the name of the file
since a file may contain changes for multiple different files.
* Updated HeaderReplacements LIT test for new serialization behaviour.
* Replaced old test that ensures replacements are not serialized if
-serialize-replacements is not provided. New version ensures changes
are made directly to all files in the translation unit.
* Updated unit tests.
* Due to major simplification of structures in FileOverrides.h, the
FileOverridesTest is quite a bit simpler now.
Differential Revision: http://llvm-reviews.chandlerc.com/D1545
llvm-svn: 189689
Currently only constructor parameters stored in class-local storage are modified
to make use of the pass-by-value idiom but this is a base that can be be further
improved to handle more situations.
This commit is the same as r189363 with additionnal fixes for the build issues.
llvm-svn: 189584
Currently only constructor parameters stored in class-local storage are modified
to make use of the pass-by-value idiom but this is a base that can be be further
improved to handle more situations.
llvm-svn: 189363
Added a command line option "-remove-change-desc-files" that triggers
the deletion of the change description files after merging and applying
regardless of success.
Differential Revision: http://llvm-reviews.chandlerc.com/D1492
llvm-svn: 189268
Test-time dependencies now live within test/clang-replace/Inputs which is more
in line with llvm and clang test suites.
Added 'Inputs' to the lit config's 'exclude' list as with llvm's lit.cfg since
test-time dependencies should not have any lit scripts within.
llvm-svn: 189047
Subdirectories of test/clang-replace contain test-time dependencies and not
more LIT tests. Tell LIT to ignore these directories from the test suite.
llvm-svn: 189019
Functionality for clang-replace completed with the addition of the ability to
write merged replacements to disk.
Test added.
Differential Revision: http://llvm-reviews.chandlerc.com/D1460
llvm-svn: 189014
Introducing new tool 'clang-replace' that finds files containing
serialized Replacements and applies those changes after deduplication
and detecting conflicts.
Currently the tool does not apply changes. It stops just after the
deduplication and conflict report phase. Forthcoming patches will
complete functionality.
Both build systems updated for new tool.
Includes a conflict test case.
clang-replace added to Doxygen build.
Differential Revision: http://llvm-reviews.chandlerc.com/D1424
llvm-svn: 189008
For use with -headers, -yaml-only will cause cpp11-migrate to not write header
changes to disk and instead write them as header change description files. This
option facilitiates upcoming functionality to properly support changing headers
as part of migration.
Differential Revision: http://llvm-reviews.chandlerc.com/D1385
llvm-svn: 188371
Reworked how the tests dealt with paths. Instead of removing the full path name,
put a marker in the expected file and replace the marker with the full path
before running diff.
Differential Revision: http://llvm-reviews.chandlerc.com/D1381
llvm-svn: 188299
Another attempt to commit r187204 after windows related problems has
been fixed. Note that changes to this patch reflect the current behavior
of cpp11-migrate.
Header replacements are now written to disk in YAML format for an external tool
to merge. A unique file will be created in the same directory as the header
with all replacements that came from a source file that included the header
file. The YAML file will have:
- Name of the header file
- Name of the source file that included the header file
- Transform ID that generated the replacement
- Offset
- Length
- Replacement text
Any tool reading these replacements should read them using the
HeaderChangeDocument struct.
Differential Revision: http://llvm-reviews.chandlerc.com/D1369
llvm-svn: 188274