summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/cpp11-migrate/UseNullptr
Commit message (Collapse)AuthorAgeFilesLines
* Rename cpp11-migrate to clang-modernize.Chandler Carruth2013-09-045-518/+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: 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: 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
* 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
* 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
* 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
* 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
* 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
* Don't include outer-most explicit cast in nullptr replacementEdwin Vane2013-03-151-7/+48
| | | | | | | | | | 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
* Prevent nullptr_t-typed exprs from being replacedEdwin Vane2013-03-151-7/+19
| | | | | | | | | | The Use-Nullptr transform was replacing nullptr_t-typed expressions because in the AST such expressions have an implicit NullToPointer cast around them. Now the transform ignores these expressions. Fixes PR15414. llvm-svn: 177168
* Test case for PR-15414 - nullptr_t functionsStefanus Du Toit2013-03-061-0/+17
| | | | | | | | | | | | | The use-null-ptr transform will transform calls to functions that return a nullptr_t. Even if the function were to only return a null pointer and do nothing else, this replacement would still be undesired as the behavior and signature of the function could change in the future. This adds an XFAILed test case to demonstrate the issue. Reviewed by: Edwin Vane, Tareq Siraj llvm-svn: 176553
* Fixed Use-Nullptr when replacing return(0)Edwin Vane2013-03-061-0/+31
| | | | | | | | | | | | 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
* Fix -use-nullptr problems with assert()Edwin Vane2013-02-171-0/+26
| | | | | | | | | | | | | 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
* Drop "REQUIRES:shell" in tests. They can run on win32.NAKAMURA Takumi2013-01-252-2/+0
| | | | llvm-svn: 173415
* Add use-nullptr transform to cpp11-migrateEdwin Vane2013-01-223-0/+211
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