Commit Graph

332 Commits

Author SHA1 Message Date
Guillaume Papin 65ec930557 clang-modernize: Fix bugs in Pass-By-Value transform
- 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
2013-09-06 22:28:53 +00:00
Edwin Vane 5a816f044c clang-modernize: Tweak docs after rename
* Removing sphinx warnings about docs not in a toctree.
* Adding more links to cpp11-migrate redirect docs.

llvm-svn: 190195
2013-09-06 19:27:19 +00:00
Edwin Vane 684daa90f2 clang-modernize: Update docs with -include/-exclude
-include/-exclude and friends have been marked as hidden options until this
point. This is no longer necessary. Update the docs to describe their effect.

Differential Revision: http://llvm-reviews.chandlerc.com/D1621

llvm-svn: 190194
2013-09-06 19:26:25 +00:00
Edwin Vane 5f002639e4 clang-modernize: Remove -headers option
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
2013-09-06 14:23:56 +00:00
Manuel Klimek bfbc8c8412 Fix writing of reformatted files.
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
2013-09-05 13:55:39 +00:00
John Thompson 7d0213c581 modularize - Fix of header dependencies - this time with the source.
llvm-svn: 189984
2013-09-04 20:46:24 +00:00
John Thompson 99e12d41d8 modularize - Fix of header dependencies.
llvm-svn: 189983
2013-09-04 20:45:43 +00:00
Chandler Carruth 8e8db654be Update the header guards for clang-modernize's unittests.
llvm-svn: 189974
2013-09-04 19:15:54 +00:00
Chandler Carruth 35c0361783 Update the header guards for clang-modernize.
llvm-svn: 189973
2013-09-04 19:13:50 +00:00
John Thompson 53a9d2da49 modularize - Update main comment.
llvm-svn: 189968
2013-09-04 18:29:36 +00:00
Chandler Carruth e160627d7b Fix up a few straggling bits of the build system. This should fix the
build of the clang-modernize unittest which is for some reason not being
built by default on my system (sorry about that).

llvm-svn: 189966
2013-09-04 18:03:44 +00:00
Chandler Carruth b0b51b36d5 This is apparantely the one makefile that actually has file names in it.
;] Update them. Sorry for the breakage.

llvm-svn: 189963
2013-09-04 17:47:21 +00:00
Chandler Carruth d9063c46f5 Rename cpp11-migrate to clang-modernize.
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
2013-09-04 17:35:07 +00:00
Bob Wilson f5999bda8c Revert svn 189837 "Added header dependencies support."
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
2013-09-04 16:48:28 +00:00
NAKAMURA Takumi 3b6ef78954 Suppress test/modularize/NoProblemsDependencies.modularize on msvc, for now. Investigating.
llvm-svn: 189904
2013-09-04 02:03:03 +00:00
John Thompson 7475180f9b Added header dependencies support.
llvm-svn: 189837
2013-09-03 18:48:43 +00:00
John Thompson cc2e291dac Ran clang-format for a base-line.
llvm-svn: 189836
2013-09-03 18:44:11 +00:00
John Thompson 0b7fc15e70 Undo r189834 - broke test.
llvm-svn: 189835
2013-09-03 18:38:32 +00:00
John Thompson a486a6f211 Ran clang-format.
llvm-svn: 189834
2013-09-03 18:21:22 +00:00
Edwin Vane b225be2729 Rename clang-replace -> clang-apply-replacements
Made changes throughout clang-tools-extra for the renaming of
clang-replace to clang-apply-replacements as per feedback from
community.

llvm-svn: 189832
2013-09-03 17:58:19 +00:00
Edwin Vane 147984a8ad cpp11-migrate: Refactor for driver model of operation
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
2013-09-03 13:16:02 +00:00
Chandler Carruth 9051d41a74 Update tests to reflect clang r189769 which changes the printing of
'auto const' to 'const auto'.

llvm-svn: 189770
2013-09-02 19:21:12 +00:00
Michael Gottesman 92d9cb4dd1 Revert "cpp11-migrate: Fixing autoconf build after adding libclangReplace dependency"
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
2013-08-30 22:09:03 +00:00
Edwin Vane 848c5dc7aa cpp11-migrate: Fixing autoconf build after adding libclangReplace dependency
llvm-svn: 189691
2013-08-30 19:45:49 +00:00
Edwin Vane 0acd502afe cpp11-migrate: Refactor for driver model of operation
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
2013-08-30 19:28:59 +00:00
Edwin Vane f5b5f1f7f6 clang-replace: Fix autoconf build failures
Updating autoconf files to reflect changes to directory structure

llvm-svn: 189681
2013-08-30 15:40:26 +00:00
Edwin Vane 1790ea000b clang-replace: Re-org of file structure
clang-replace is likely to move to clang proper one day soon. To facilitate
that move, renaming files and directory structure layout to ease transition for
users of clang-replace and libclangReplace.

For now, functionality still exists in clang::replace namespace. Header guards
and file comments updated.

Differential Revision: http://llvm-reviews.chandlerc.com/D1548

llvm-svn: 189671
2013-08-30 14:33:56 +00:00
Guillaume Papin 81332632b1 cpp11-migrate: Add Pass-By-Value Transform
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
2013-08-29 13:42:13 +00:00
Edwin Vane f18633c3d5 clang-replace: Afford applying replacements in memory
For users of libclangReplace, this patch affords the ability to apply
replacements in memory instead of writing to disk.

Differential Revision: http://llvm-reviews.chandlerc.com/D1519

llvm-svn: 189493
2013-08-28 17:19:10 +00:00
Eric Christopher 35c6b614ea Temporarily revert r189363 as it seems to be failing to build.
llvm-svn: 189387
2013-08-27 17:26:07 +00:00
Guillaume Papin dcdae946f3 cpp11-migrate: Add Pass-By-Value Transform
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
2013-08-27 16:11:26 +00:00
Guillaume Papin 64feb39b1b cpp11-migrate: Add a class to support include directives modifications
The IncludeDirectives class helps with detecting and modifying #include
directives. For now it allows the users to add angled-includes in a source file.
This is a start for this class that will evolve in the future to add more
functionality.

This should fix the reverted commit r189037 (buildbot failures on Windows).

llvm-svn: 189354
2013-08-27 14:50:26 +00:00
Tareq A. Siraj 1175552853 clang-replace: Delete change description files
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
2013-08-26 19:58:59 +00:00
John Thompson 9e8d672206 Updated the main comment with respect to problems and future directions.
llvm-svn: 189229
2013-08-26 15:55:47 +00:00
John Thompson 8e01c069c9 Fixed some issues that resulted in erroneous duplicate symbol error messages.
llvm-svn: 189228
2013-08-26 15:17:23 +00:00
Edwin Vane 9f7a1c10ea clang-replace: Layout of test directory now more standard
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
2013-08-22 19:44:07 +00:00
Guillaume Papin 883a2b2427 Revert "cpp11-migrate: Add a class to support include directives modifications"
This reverts commit r189017.

It broke the windows bots:
- http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/4176
- http://bb.pgr.jp/builders/cmake-clang-i686-mingw32/builds/3837

llvm-svn: 189037
2013-08-22 18:20:03 +00:00
Edwin Vane 69948e4155 clang-replace: Exclude test-time deps from LIT test suite
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
2013-08-22 15:04:34 +00:00
Guillaume Papin effabf9691 cpp11-migrate: Add a class to support include directives modifications
The IncludeDirectives class helps with detecting and modifying #include
directives. For now it allows the users to add angled-includes in a source file.
This is a start for this class that will evolve in the future to add more
functionality.

This should fix the reverted commit r188791 (buildbot failures on Windows).

llvm-svn: 189017
2013-08-22 14:49:07 +00:00
Edwin Vane 1106ef2a69 clang-replace: Write merged changes to disk
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
2013-08-22 13:40:32 +00:00
Edwin Vane 3bf14cebee Introducing new tool clang-replace
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
2013-08-22 13:07:14 +00:00
Eli Friedman a4ff59a7f8 Adjust for r188968.
llvm-svn: 188970
2013-08-22 00:48:18 +00:00
Edwin Vane d2cd2a4e1e cpp11-migrate: Use Replacement serialization from clang::tooling
Serialization of replacements has been moved to clang::tooling.

Differential Revision: http://llvm-reviews.chandlerc.com/D1423

llvm-svn: 188820
2013-08-20 19:20:52 +00:00
NAKAMURA Takumi 166b874696 UniqueHeaderNameTest.cpp: Appease valgrind.
llvm::sys::path::native(dst, dst) might be overridden-safe in most cases, though.

llvm-svn: 188800
2013-08-20 14:02:38 +00:00
Guillaume Papin 1593c7b20a Revert "cpp11-migrate: Add a class to support include directives modifications"
This reverts commit r188791.

The Windows bots are still broken.

llvm-svn: 188795
2013-08-20 13:05:57 +00:00
Guillaume Papin f240481b99 cpp11-migrate: Add a class to support include directives modifications
The IncludeDirectives class helps with detecting and modifying #include
directives. For now it allows the users to add angled-includes in a source file.
This is a start for this class that will evolve in the future to add more
functionality.

This should fix the reverted commit r188610 (buildbot failures on Windows).

llvm-svn: 188791
2013-08-20 12:30:26 +00:00
Alexey Samsonov f656e1783b Add dependencies on TransformUtils library in preparation for re-applying r188666
llvm-svn: 188674
2013-08-19 13:58:56 +00:00
Guillaume Papin 8d951fbc18 Revert "cpp11-migrate: Add a class to support include directives modifications"
This reverts commit r188610.

Issue with the absolute include paths not found in the unit tests on the Windows
bots. Needs investigation.

llvm-svn: 188611
2013-08-17 19:04:56 +00:00
Guillaume Papin 114d035521 cpp11-migrate: Add a class to support include directives modifications
The IncludeDirectives class helps with detecting and modifying #include
directives. For now it allows the users to add angled-includes in a source file.
This is a start for this class that will evolve in the future to add more
functionality.

llvm-svn: 188610
2013-08-17 18:48:31 +00:00
Ariel J. Bernal 2203559c3e Use -std=c++11 when no compilation database is provided
Allow the migrator to be used without specifing --. If neither -- nor -p is
provided and no compilation database can be detecteded from the first source
file path then -std=c++11 is added as the only compiler argument.

llvm-svn: 188533
2013-08-16 04:40:44 +00:00