74 lines · plain
1.. title:: clang-tidy - modernize-use-nullptr2 3modernize-use-nullptr4=====================5 6The check converts the usage of null pointer constants (e.g. ``NULL``, ``0``)7to use the new C++11 and C23 ``nullptr`` keyword.8 9Example10-------11 12.. code-block:: c++13 14 void assignment() {15 char *a = NULL;16 char *b = 0;17 char c = 0;18 }19 20 int *ret_ptr() {21 return 0;22 }23 24 25transforms to:26 27.. code-block:: c++28 29 void assignment() {30 char *a = nullptr;31 char *b = nullptr;32 char c = 0;33 }34 35 int *ret_ptr() {36 return nullptr;37 }38 39Options40-------41 42.. option:: IgnoredTypes43 44 Semicolon-separated list of regular expressions to match pointer types for45 which implicit casts will be ignored. Default value:46 `std::_CmpUnspecifiedParam::;^std::__cmp_cat::__unspec`.47 48.. option:: NullMacros49 50 Comma-separated list of macro names that will be transformed along with51 ``NULL``. By default this check will only replace the ``NULL`` macro and will52 skip any similar user-defined macros.53 54Example55^^^^^^^56 57.. code-block:: c++58 59 #define MY_NULL (void*)060 void assignment() {61 void *p = MY_NULL;62 }63 64transforms to:65 66.. code-block:: c++67 68 #define MY_NULL NULL69 void assignment() {70 int *p = nullptr;71 }72 73if the :option:`NullMacros` option is set to ``MY_NULL``.74