summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/cpp11-migrate/UseNullptr/NullptrActions.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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