summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/cpp11-migrate
Commit message (Collapse)AuthorAgeFilesLines
* Rename cpp11-migrate to clang-modernize.Chandler Carruth2013-09-0449-3897/+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-035-39/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Update tests to reflect clang r189769 which changes the printing ofChandler Carruth2013-09-024-6/+6
| | | | | | 'auto const' to 'const auto'. llvm-svn: 189770
* Revert "cpp11-migrate: Fixing autoconf build after adding libclangReplace ↵Michael Gottesman2013-08-305-77/+39
| | | | | | | | | | | | | | | | | 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-305-39/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Pass-By-Value TransformGuillaume Papin2013-08-292-0/+191
| | | | | | | | | | 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
* Temporarily revert r189363 as it seems to be failing to build.Eric Christopher2013-08-272-187/+0
| | | | llvm-svn: 189387
* cpp11-migrate: Add Pass-By-Value TransformGuillaume Papin2013-08-272-0/+187
| | | | | | | | 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
* cpp11-migrate: Use Replacement serialization from clang::toolingEdwin Vane2013-08-201-4/+5
| | | | | | | | Serialization of replacements has been moved to clang::tooling. Differential Revision: http://llvm-reviews.chandlerc.com/D1423 llvm-svn: 188820
* cpp11-migrate: Remove mention of 'headers' from serialization codeEdwin Vane2013-08-141-3/+2
| | | | | | | | | | | | | * HeaderChangeDocument -> MigratorDocument * HeaderFileName -> TargetFile * SourceFileName -> MainSourceFile * Removed TransformID * Comments updated, at least with respect to serialization * Unit tests updated. Differential Revision: http://llvm-reviews.chandlerc.com/D1403 llvm-svn: 188404
* cpp11-migrate: Adding -yaml-only optionEdwin Vane2013-08-141-2/+2
| | | | | | | | | | | 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
* clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main.cpp: Use "%/t" ↵NAKAMURA Takumi2013-08-141-6/+3
| | | | | | | | instead of "%t" on sed(1) to avoid \'s expanded to control chars. The feature, "%/t", has been introduced in llvm/lit since r188348. llvm-svn: 188349
* clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main.cpp: Use ↵NAKAMURA Takumi2013-08-141-4/+12
| | | | | | FileCheck instead of grep(1). llvm-svn: 188347
* clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main.cpp: Suppress ↵NAKAMURA Takumi2013-08-141-0/+3
| | | | | | this on win32, for now. Investigating. llvm-svn: 188345
* Fixes test failure on darwin introduced by r188274Tareq A. Siraj2013-08-132-10/+11
| | | | | | | | | | 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
* cpp11-migrate: Write header replacements to diskTareq A. Siraj2013-08-134-0/+94
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert "cpp11-migrate: Write header replacements to disk"Rafael Espindola2013-07-304-94/+0
| | | | | | | This reverts commit 187428. It broke the windows bots. http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/3450 llvm-svn: 187447
* cpp11-migrate: Write header replacements to diskTareq A. Siraj2013-07-304-0/+94
| | | | | | | | | | | | | | | | | | | | Committing r187204 with fixes for darwin. Note that one of the lit tests are disabled on windows due to a bug in writing header replacements to file. 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 file - Transform ID that generated the replacement - Offset - Length - Replacement text Any tool reading these replacements should read them using the TransformDocument struct. llvm-svn: 187428
* cpp11-migrate: Add -for-compilers command line switch.Guillaume Papin2013-07-292-6/+63
| | | | | | | | | 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
* Revert "cpp11-migrate: Write header replacements to disk"Rafael Espindola2013-07-264-91/+0
| | | | | | | | This reverts commit 187204. It broke the freebsd bots: http://lab.llvm.org:8011/builders/clang-X86_64-freebsd/builds/9561 llvm-svn: 187227
* cpp11-migrate: Write header replacements to diskTareq A. Siraj2013-07-264-0/+91
| | | | | | | | | | | | | | | | | | | 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 file - Transform ID that generated the replacement - Offset - Length - Replacement text Any tool reading these replacements should read them using the TransformDocument struct. Differential Revision: http://llvm-reviews.chandlerc.com/D1142 llvm-svn: 187204
* cpp11-migrate: Tweak lit tests to avoid false negativesEdwin Vane2013-07-251-2/+3
| | | | | | | | Recent failures on a freebsd buildbot indicated a weakness in the Reformatting.cpp lit test. Tweaking the test to avoid false negatives and hopefully make the buildbot happy. llvm-svn: 187153
* cpp11-migrate: Fix build break on Windows introduced in r187041.Guillaume Papin2013-07-241-2/+2
| | | | | | | | | | | r187041 changed the way the transform are created and the order the transformed are applied "may" have changed as well (no specific constraints exist on the order). This produced a test failure on the Windows buildbot. Now the test use -std=c++11, so 'nullptr' is defined and the test is not anymore dependent on the order the transforms are applied. llvm-svn: 187048
* cp11-migrate: Integration with LibFormatEdwin Vane2013-07-231-0/+15
| | | | | | | | | | | Adding a feature to optionally reformat code changed by the migrator. Like LibFormat, can choose between built-in styles (LLVM, Mozilla, Google, Chromium) or use a YAML-format config file. Now with no dependency on iostream by the Reformatting.cpp LIT test. Author: Guillaume Papin <guillaume.papin@epitech.eu> llvm-svn: 186938
* Revert "cp11-migrate: Integration with LibFormat"Michael Gottesman2013-07-221-42/+0
| | | | | | | | | | This reverts commit r186866. This breaks the build and the original author Guillaume Papin <guillaume.papin@epitech.eu> asked me to revert so he could look at it more with revane. llvm-svn: 186873
* cp11-migrate: Integration with LibFormatEdwin Vane2013-07-221-0/+42
| | | | | | | | | Adding a feature to optionally reformat code changed by the migrator. Like LibFormat, can choose between built-in styles (LLVM, Mozilla, Google, Chromium) or use a YAML-format config file. Author: Guillaume Papin <guillaume.papin@epitech.eu> llvm-svn: 186866
* Fix UseAuto not transforming iterator when non-fully qualifiers are used andAriel J. Bernal2013-07-153-5/+10
| | | | | | | | | | | | 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: Add Replace-AutoPtr TransformEdwin Vane2013-07-035-0/+365
| | | | | | | | | | | | Add a new transform to replace uses of 'std::auto_ptr' by 'std::unique_ptr'. Copy-ctor and assign-operator are wrapped with a call to 'std::move()'. Note that until header modification is ready it is not that useful, that's why it's marked as (EXPERIMENTAL) in the command line description and a "Known Limitations" section is present in the transform documentation. Author: Guillaume Papin <guillaume.papin@epitech.eu> llvm-svn: 185535
* cpp11-migrate: Transforms honour header modification flagEdwin Vane2013-06-182-3/+9
| | | | | | | | | | 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
* Force c++98 so this works on windows where c++11 is the default.Rafael Espindola2013-06-141-1/+1
| | | | llvm-svn: 183983
* cpp11-migrate: Add option to detect and use macros that expand to 'override'Edwin Vane2013-05-311-57/+66
| | | | | | | | Added a new option -override-macros which causes the, the add-override transform to detect macros that expand to 'override' (like LLVM_OVERRIDE) and use these macros instead of the override keyword directly. llvm-svn: 183001
* Fix UseAuto replacing declaration lists with new expressionsAriel J. Bernal2013-05-271-0/+45
| | | | | | | | | | | 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
* Fix UseAuto replacing variable declaration lists containing non-initializedAriel J. Bernal2013-05-171-0/+12
| | | | | | | | | | | 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
* cpp11-migrate: Check for valid NULL macros from macro arg expansionsEdwin Vane2013-05-161-0/+8
| | | | | | | | | | The recent improvement to the Use Nullptr Transform for macro arg expansions wasn't testing that only allowed NULL macros used in macro args can be transformed. This revision replaces a TODO to that effect. Fixes PR15955. llvm-svn: 182014
* cpp11-migrate: Add override specifier before comments on inline methodsEdwin Vane2013-05-142-25/+4
| | | | | | | | | | | | This commit fixes a "FIXME" in the add-override transform. ' override' was misplaced when a comment was between the function body and the end of the 'prototype'. It also remove duplicated check for the main file from the last commit (and fixes the typo in the comment above). Author: Guillaume Papin <guillaume.papin@epitech.eu> llvm-svn: 181806
* cpp11-migrate: Fix crash in AddOverride due to template instantiationsEdwin Vane2013-05-102-0/+58
| | | | | | | | | | | | | | | This patch fixes different issues: - override is not added in template 'contexts' (this will be further improved to handle safe situations, a test for this has been written already) - the main file is now checked before the modifications are applied - override is not applied now when dealing with pure methods since it was misplaced (ignoring it isn't the perfect solution but it seems difficult to find the location just before the pure-specifier) Fixes PR15827 Author: Guillaume Papin <guillaume.papin@epitech.eu> llvm-svn: 181596
* Transform for loops over pseudo-arrays only if begin/end members existEdwin Vane2013-05-092-1/+72
| | | | | | | | | | | | 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-095-15/+115
| | | | | | | | | 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-061-0/+43
| | | | | | | | | | | 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
* Added comprehensive macro arg usage logic to Use-Nullptr TransformEdwin Vane2013-05-061-25/+74
| | | | | | | | | | If a NullTo(Member)Pointer cast results from a macro arg expansion, all uses of the arg must result in such casts or else the macro arg cannot be replaced with 'nullptr' safely. This revision adds logic and tests to ensure the safety of replacing macro args in the Use-Nullptr Transform. Fixes: PR15816 llvm-svn: 181221
* Adding the AddOverride transform for cpp11-migrateEdwin Vane2013-04-092-0/+135
| | | | | | | | This transform adds the override specifier to methods that overrides virtual methods from a base class that don't already have this specifier. Author: Philip Dunstan <phil@phildunstan.com> llvm-svn: 179127
* Fix UseNullptr fails to replace c-style explicit cast in a return statementAriel J. Bernal2013-04-091-0/+12
| | | | | | | | | | | | This happens whenever there is a c-style explicit cast to nullptr not surrounded by parentheses following a return statement. - Added a white space before nullptr if the character before is alphanumeric when replacing the null pointer expression. - Simplified visitor - Addes tests llvm-svn: 179103
* Fix UseNullptr fails to replace explict casts surrounded by another implicitAriel J. Bernal2013-04-051-0/+25
| | | | | | | | | | | | cast UseNullptr previously matched the implicit cast to const pointer as well as the explicit cast within that has an implicit cast to nullptr as a descendant. -Refactored UseNullptr to avoid special-casing certain kinds of cast sequences -Added test cases. llvm-svn: 178907
* Use 'auto' with 'new' expressionsEdwin Vane2013-04-022-0/+88
| | | | | | | | | | | | | | | | | | | | | 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
* Refactor Usenullptr matcher to avoid duplicationAriel J. Bernal2013-04-011-3/+15
| | | | | | | | | | | Previously UseNullptr matched separately implicit and explicit casts to nullptr, now it matches casts that either are implict casts to nullptr or have an implicit cast to nullptr within. Also fixes PR15572 since the same macro replacement logic is applied to implicit and explicit casts. llvm-svn: 178494
* Improve loop convert's variable aliasingEdwin Vane2013-04-011-0/+37
| | | | | | | | | | | | | | | 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
* Allow users to specify NULL like macros to be replacedTareq A. Siraj2013-03-281-2/+4
| | | | | | | | | | | | | | | | -use-nullptr only replaced macro named NULL and ignored any user defined macros that behaved like NULL. This patch introduces -user-null-macros command line option to let users specify their custom NULL like macros. - Added a -user-null-macros command line option that takes a comma-separated list of user-defined macros to be replaced when using the -use-nullptr transform. - Added documentation. - Updated testcase to reflect current behavior. - Whitespace fixes. Reviewers: revane, klimek, gribozavr llvm-svn: 178243
* cpp11-migrate segfaults transforming map<string,int>::iterator Ariel J. Bernal2013-03-272-0/+11
| | | | | | | | | | | | 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
* Adding a failing test case for cpp11-migrate's Loop Convert TransformEdwin Vane2013-03-252-0/+29
| | | | | | Related to PR15589. llvm-svn: 177891
* Don't replace macro usage if macro body has NULLEdwin Vane2013-03-192-26/+94
| | | | | | | | | | | | | | | | | | | In case of macro body expansion, check to see if the macro is named NULL and don't replace inside the macro body. This fixes the case when NULL appears inside the macro body and the transform replaces the usage of the macro with nullptr. This is an easy fix for the problem for now and we should analyze the macro body to see if it expands to only NullToPointer in the future for a more robust solution that takes care of user defined macros that behaves like NULL. Other changes: - Moved complex macro tests to macros.cpp - Added new test cases. - Added checks to make sure that the macro bodies are not modified by the tool. Fixes: PR15396 Author: Tareq A Siraj <tareq.a.siraj@intel.com> llvm-svn: 177422
OpenPOWER on IntegriCloud