summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/cpp11-migrate/LoopConvert
Commit message (Collapse)AuthorAgeFilesLines
* Rename cpp11-migrate to clang-modernize.Chandler Carruth2013-09-0410-2248/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* cpp11-migrate: Refactor for driver model of operationEdwin Vane2013-09-034-27/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Fixing autoconf build after adding libclangReplace ↵Michael Gottesman2013-08-304-24/+27
| | | | | | | | | | | | | | | | | 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
* cpp11-migrate: Refactor for driver model of operationEdwin Vane2013-08-304-27/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* cpp11-migrate: Add -for-compilers command line switch.Guillaume Papin2013-07-291-0/+7
| | | | | | | | | This change add a new option command line option -for-compilers that allows the user to enable multiple transforms automatically. Another difference is that now all transforms are enabled by default. llvm-svn: 187360
* cpp11-migrate: Register the transforms automatically using llvm::RegistryGuillaume Papin2013-07-241-0/+14
| | | | | | | With this change each transform now register a factory. The factories are registered using an llvm::Registry which makes them available globally. llvm-svn: 187041
* cpp11-migrate: Tidying upEdwin Vane2013-07-0810-23/+31
| | | | | | | | | | | | * Some file headers were missing for files in Core/ * Some headers were included but not necessary * CMakeLists.txt was linking in LLVMSupport even though CMakeLists in subdirs were linking it in too. * StringRefisation of constructors of types in FileOverrides.h * Other misc cleanups Author: Guillaume Papin <guillaume.papin@epitech.eu> llvm-svn: 185811
* cpp11-migrate: Transforms honour header modification flagEdwin Vane2013-06-183-21/+23
| | | | | | | | | | Transforms will now make changes to headers if header modifications have been enabled. FIXME: Only UseNullptr contains a cursory header modification test. Other transforms should have them too. llvm-svn: 184197
* cpp11-migrate: Transform now responsible for applying replacementsEdwin Vane2013-06-182-27/+15
| | | | | | | | | | | | | | | | | | | | | | | | To make it possible for replacements made to headers as part of transforming one translation unit to not be visible to the transform of other translation units, Transform now handles replacement application as part of its end-of-source handling. Several things were simplified as a result: - The duplicated code in every transform for applying replacements is now gone and replaced with one location in Transform. - RefactoringTool is no longer used since Transform houses the Replacements structure. - RewriterContainer is now a private implementation detail of Transform (also renamed to RewriterManager since its behaviour is slightly different now with respect to lifetime of objects). - There's now no distinction between input and output file state. Misc notes: - Interface changes reflected in unit tests. - Replacements for files other than the main file are assumed to be for headers and stored as such. llvm-svn: 184194
* cpp11-migrate: Transform now responsible for file content overridingEdwin Vane2013-06-171-1/+3
| | | | | | | | | | | To better support per-translation unit replacements, any real work is being moved out of ActionFactory and into Transform. In this revision, that means file override application. For simplification, Transform no longer inherits from SourceFileCallbacks. TransformTest required updating as a result. llvm-svn: 184098
* cpp11-migrate: Replace file override containerEdwin Vane2013-06-132-4/+4
| | | | | | | | | | | | A more flexible container for storing overrides is required for headers. Before a source goes through the transform pipeline, any headers it references will be in their original state and unaffected by transforms applied to other sources. Therefore overrides for headers need to be kept separate for each source file. This patch doesn't introduce support for storing header overrides yet. It only replaces the existing structure and makes any necessary changes to support it. llvm-svn: 183910
* cpp11-migrate: New mechanism for overriding file contentsEdwin Vane2013-06-121-8/+1
| | | | | | | | | | | Next step toward supporting migrating headers. Instead of using ClangTool's ability to override all files at once, use a custom FrontendAction and override only the source (and eventually headers) the action is about to parse. Use of newFrontendActionFactory() is replaced with a new factory maker provided by Transform. llvm-svn: 183855
* cpp11-migrate: Refactor how global options are passed to TransformsEdwin Vane2013-06-062-7/+5
| | | | | | | | | Refactored how global options are passed to Transforms to avoid widespread changes every time a new global option is added. Tests updated to reflect new interface. llvm-svn: 183443
* cpp11-migrate: Transforms collect timing data.Edwin Vane2013-05-302-2/+4
| | | | | | | | | | Using updated form of newFrontendActionFactory(), Transforms now automatically measure, if requested, how long it takes to apply a MatchFinder to a source file. Other per-transform overhead, e.g. applying replacements, is not currently measured. This behaviour is disabled for now and soon will be connected to a new command line arg. llvm-svn: 182942
* Transform for loops over pseudo-arrays only if begin/end members existEdwin Vane2013-05-091-1/+48
| | | | | | | | | | | | For loops using pseudo-arrays, classes that can be used like arrays from the Loop Convert Transform's point of view, should only get transformed if the pseudo-array class has begin()/end() members for the range-based for-loop to call. Free versions of begin()/end() should also be allowed but this is an enhancement for another revision. llvm-svn: 181539
* Use 'auto const&' for iterators whose deref operator return a const varAriel J. Bernal2013-05-094-13/+93
| | | | | | | | | This patch fixes PR15601. - Added check for whether the loop variable and the initializer have the same type. - Added tests. llvm-svn: 181528
* Stop LoopConvert removing DeclStmts from selection/iteration condition clausesEdwin Vane2013-05-062-10/+78
| | | | | | | | | | | If the LoopConvert Transform detects an alias for the loop variable, it attempts to use that name in the resulting range-based for loop while removing the original DeclStmt for the variable. That removal produced bad code when the declaration was in the condition of an if, switch, while, or for stmt. This revision fixes the problem by simply replacing the declaration with a use of the alias variable. llvm-svn: 181242
* lib-ified core cpp11-migrate functionality to support unit testsEdwin Vane2013-04-042-2/+2
| | | | | | | | | | | | | | | | | | Summary: Transform.* and Transforms.* moved to form a new library: libmigrateCore. #includes updated to point to new header locations. To support autoconf build, Cpp11Migrate.cpp moved to new subdirectory 'tool' which also contains build files for creating final binary. CMake and autoconf updated to build the new library and link it with cpp11-migrate and with cpp11-migrate unit tests. Dummy unit tests replaced with simple, but real, tests for Transform's public interface. TODO: Lib-ifying the transforms to further simplify build of cpp11-migrate. llvm-svn: 178785
* Improve loop convert's variable aliasingEdwin Vane2013-04-011-8/+17
| | | | | | | | | | | | | | | Loop convert's variable name aliasing may cause issues if the variable is declared as a value (copy). The converted loop will declare the variable as a reference which may inadvertently cause modifications to the container if it were used and modified as a temporary copy. This is fixed by preserving the reference or value qualifiers of the aliased variable. That is, if the variable was declared as a value the loop variable will also be declared as a value and similarly for references. Fixes: PR15600 Author: Jack Yang <jack.yang@intel.com> llvm-svn: 178485
* Test commit: Remove whitespace.Tareq A. Siraj2013-03-281-1/+1
| | | | llvm-svn: 178241
* Extend loop variable naming checksEdwin Vane2013-03-085-11/+48
| | | | | | | | | | | | The loop convert tests for conflicting names have been extended to check for macro names, types, and language keywords including language extensions. Tests have also been added. Fixes PR15322 Author: Jack Yang <jack.yang@intel.com> Reviewer: gribozavr, klimek, revane llvm-svn: 176690
* Have LoopConvert use 'auto &&' where necessaryEdwin Vane2013-03-074-27/+89
| | | | | | | | | | | | | | | | For iterators where the dereference operator returns by value, LoopConvert should use 'auto &&' in the range-based for loop expression. If the dereference operator returns an rvalue reference, this is deemed too strange and the for loop is not converted. Moved test case from iterator_failing.cpp to iterator.cpp and added extra tests. Fixes PR15437. Reviewer: gribozavr llvm-svn: 176631
* Added summary option to cpp11-migrate toolDmitri Gribenko2013-03-052-7/+4
| | | | | | | | | Added a summary option that enables output to stdout counting the number of changes each transform has accepted, rejected or deferred. Patch by Ariel Bernal. llvm-svn: 176465
* Properly identify 'this' as range-based for containerEdwin Vane2013-03-041-3/+9
| | | | | | | | | The Loop-Convert transform was mistransforming loops using 'this' implicitly. Fixed and added tests. Fixes PR15411. llvm-svn: 176436
* Fix documentation comment in LoopConvertDmitri Gribenko2013-02-271-1/+1
| | | | | | Patch by Ariel Bernal llvm-svn: 176191
* Propagate changes through no-op transformsEdwin Vane2013-02-151-1/+1
| | | | | | | | | | | Currently, changes made by previous transforms are not kept if a transform doesn't make any changes itself to a given file. Now file states are propagated properly through transforms that don't make changes. Fixes: PR15281 Author: Jack Yang <jack.yang@intel.com> Reviewer: klimek llvm-svn: 175288
* Fix for combined loop and nullptr convert testsEdwin Vane2013-02-071-1/+1
| | | | | | | | | | | | 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
* Re-sort the #include lines which have gotten out of order.Chandler Carruth2013-01-191-1/+1
| | | | llvm-svn: 172895
* Fix a -Wdocumentation warning (empty paragraph passed to '\brief' command)Dmitri Gribenko2013-01-161-1/+1
| | | | llvm-svn: 172661
* Write transform results to disk only onceEdwin Vane2013-01-162-5/+29
| | | | | | | | | | 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
* Update users of RefactoringToolEdwin Vane2013-01-111-1/+1
| | | | | | | | RefactoringTool::run() no longer writes changes to disk automatically. Updating users of RefactoringTool to explicitly perform the write. Reviewers: klimek llvm-svn: 172218
* Add a namespace qualifier to the befriending statement forChandler Carruth2013-01-051-1/+1
| | | | | | | | 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
* Port loop-convert into cpp11-migrateEdwin Vane2013-01-0410-0/+1907
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
OpenPOWER on IntegriCloud