summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/cpp11-migrate/UseAuto
Commit message (Collapse)AuthorAgeFilesLines
* Rename cpp11-migrate to clang-modernize.Chandler Carruth2013-09-046-630/+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-19/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-17/+19
| | | | | | | | | | | | | | | | | 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-19/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix UseAuto not transforming iterator when non-fully qualifiers are used andAriel J. Bernal2013-07-151-16/+9
| | | | | | | | | | | | using inline namespaces is specified. UseAuto used to fail to transform iterators when using inline namespaces and non-fully qualified types, relying on a using directive previously declared. - This fix uses the already define isFromStdNamespace matcher. - Fixed tests and added a new test using inline namespaces. - Added CustomMatchers to reuse common matchers among transforms. llvm-svn: 186327
* cpp11-migrate: Tidying upEdwin Vane2013-07-085-17/+22
| | | | | | | | | | | | * 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-10/+10
| | | | | | | | | | 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-18/+10
| | | | | | | | | | | | | | | | | | | | | | | | 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-7/+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-5/+3
| | | | | | | | | 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/+3
| | | | | | | | | | 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
* Fix UseAuto replacing declaration lists with new expressionsAriel J. Bernal2013-05-273-59/+81
| | | | | | | | | | | UseAuto used to replace declarion lists with new expressons where some variable were not initialized with new. This fix checks that every DeclStmt has a VarDecl with an initializer and it also ensures that all declarations have the same type. Added tests for multiple declarations and for typedefs. llvm-svn: 182736
* Unbreak the build.Benjamin Kramer2013-05-171-3/+4
| | | | | | UseAutoActions.cpp:48:17: error: redefinition of 'E' with a different type. llvm-svn: 182119
* Fix UseAuto replacing variable declaration lists containing non-initializedAriel J. Bernal2013-05-173-53/+69
| | | | | | | | | | | variables. UseAuto used to match initialized variable declarations independently of whether they were defined in a declaration list or as a single declaration. Now it matches declaration statements where every variable declaration is initialized. llvm-svn: 182114
* 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
* Use 'auto' with 'new' expressionsEdwin Vane2013-04-025-17/+123
| | | | | | | | | | | | | | | | | | | | | For variable declarations initialized with new expressions, use 'auto' for the type specifier. The 'auto' replacement happens only when the type of the VarDecl exactly matches the type of the initializer and the VarDecl is *not* CV-qualified. The only case that is currently handled is if the pointer type of the VarDecl is itself CV qualified. Some improvements need to be made to Clang's TypeLoc information in order for other CV qualifier cases to be successfully handled. See the new test suite new_cv_failing.cpp for examples of usages that could be handled with such an improvement. Function pointers are, for now, not transformed until the identifier info can be extracted. Reviewer: klimek llvm-svn: 178575
* cpp11-migrate segfaults transforming map<string,int>::iterator Ariel J. Bernal2013-03-271-1/+8
| | | | | | | | | | | | cpp11-migrate segfaults when -use-auto tries to resolve initializing expression resulting in an expression with cleanups. - Skip expressions with cleanups from the initializer - Added test case Fixes PR15550 llvm-svn: 178167
* Fixing Doxygen warnings in cpp11-migrateEdwin Vane2013-03-081-3/+3
| | | | | | Turned on doxygen warnings and fixed the resulting problems. llvm-svn: 176712
* Added summary option to cpp11-migrate toolDmitri Gribenko2013-03-052-2/+3
| | | | | | | | | 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
* Introducing Use-Auto transform for cpp11-migrateEdwin Vane2013-02-286-0/+473
The new Use-Auto transform replaces the type specifier for variable declarations with the special C++11 'auto' type specifier. For now, the replacement is done only for variables that are iterators of any of the std containers and only if the type used is one of those explicitly allowed by the standard (i.e. not an implementation-specific type). Reviewers: gribozavr, silvas, klimek llvm-svn: 176266
OpenPOWER on IntegriCloud