summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/cpp11-migrate/UseNullptr/NullptrActions.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Rename cpp11-migrate to clang-modernize.Chandler Carruth2013-09-041-450/+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-031-17/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-301-16/+17
| | | | | | | | | | | | | | | | | 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-301-17/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Adjust for r188968.Eli Friedman2013-08-221-1/+1
| | | | llvm-svn: 188970
* cpp11-migrate: Tidying upEdwin Vane2013-07-081-5/+5
| | | | | | | | | | | | * 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: Minor command-line fixes and improvementsEdwin Vane2013-07-041-4/+6
| | | | | | | | | | | * all transforms are in the same category * all transforms' options are in the same category * display the CommonOptionParser extra-help (which describe in more details the compilation database stuff) * add EXAMPLES section Author: Guillaume Papin <guillaume.papin@epitech.eu> llvm-svn: 185660
* cpp11-migrate: Transforms honour header modification flagEdwin Vane2013-06-181-9/+12
| | | | | | | | | | 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: Check for valid NULL macros from macro arg expansionsEdwin Vane2013-05-161-2/+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: Refactor NullptrActionsEdwin Vane2013-05-161-181/+179
| | | | | | | Several free functions related to macro arg testing are being moved into CastSequenceVisitor to facilitate upcoming fix. llvm-svn: 182013
* Added comprehensive macro arg usage logic to Use-Nullptr TransformEdwin Vane2013-05-061-44/+304
| | | | | | | | | | 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
* Fix UseNullptr fails to replace c-style explicit cast in a return statementAriel J. Bernal2013-04-091-10/+10
| | | | | | | | | | | | 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
* Refactor Usenullptr matcher to avoid duplicationAriel J. Bernal2013-04-011-55/+53
| | | | | | | | | | | 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
* Allow users to specify NULL like macros to be replacedTareq A. Siraj2013-03-281-11/+46
| | | | | | | | | | | | | | | | -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
* Don't replace macro usage if macro body has NULLEdwin Vane2013-03-191-5/+26
| | | | | | | | | | | | | | | | | | | 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
* Don't include outer-most explicit cast in nullptr replacementEdwin Vane2013-03-151-10/+13
| | | | | | | | | | The outer-most explicit cast is now left alone by the Use-Nullptr transform to maintain the type of the expression and avoid introducing ambiguities. Fixes PR15395. Author: Ariel J Bernal <ariel.j.bernal@intel.com> llvm-svn: 177179
* Fixed Use-Nullptr when replacing return(0)Edwin Vane2013-03-061-2/+4
| | | | | | | | | | | | Before fix, the paren expression was being replaced resulting in returnnullptr. ParenExpr and implicit casts now ignored so we get return(nullptr) instead. Added new test cases. Fixes PR15398 Author: Ariel Bernal <ariel.j.bernal@intel.com> llvm-svn: 176551
* cpp11-migrate: Factor out duplicate code in UseNullPtrStefanus Du Toit2013-03-011-20/+25
| | | | | | | | | | | | This moves the actual replacement code into a separate function. There is still a bit of code duplication to go from macros to expansion areas, but that code will need to be fixed anyways to resolve bugs around macro replacement. Reviewed by: Tareq Siraj, Edwin Vane llvm-svn: 176372
* Fix -use-nullptr problems with assert()Edwin Vane2013-02-171-4/+7
| | | | | | | | | | | | | If a cast expression (NullToPointer) is detected in a function-like macro parameter, we should use the spelling location instead of the expansion location. Using SourceManager::getFileLoc() fixes this problem. Also added testcases for this bug. Fixes: PR15279 Author: Tareq A Siraj <tareq.a.siraj@intel.com> Reviewer: klimek llvm-svn: 175399
* Add use-nullptr transform to cpp11-migrateEdwin Vane2013-01-221-0/+115
This transform converts the usage of null pointer constants (e.g. NULL, 0, etc.) in legacy C++ code and converts them to use the new C++11 nullptr keyword. - Added use-nullptr transform. - Added C++11 support to the final syntax check. Used ArgumentAdjuster class to add -std=c++11 option to the command line options. - Added tests for use-nullptr transform. - Added tests that exercises both loop-convert and use-nullptr in the source file. TODO: There's a known bug when using both -loop-convert and -use-nullptr at the same time. Author: Tareq A Siraj <tareq.a.siraj@intel.com> Reviewers: klimek, gribozavr llvm-svn: 173178
OpenPOWER on IntegriCloud