.. index:: cpp11-migrate

===========================
cpp11-migrate User's Manual
===========================

.. toctree::
   :hidden:

   UseAutoTransform
   UseNullptrTransform
   LoopConvertTransform

:program:`cpp11-migrate` is a standalone tool used to automatically convert
C++98 and C++03 code to use features of the new C++11 standard where
appropriate.

Basic Usage
===========

``cpp11-migrate [options] <source0> [... <sourceN>]``

``<source0>...`` specify the paths of files in the CMake source tree,
with the same requirements as other tools built on LibTooling.

Command Line Options
--------------------

.. option:: -help

  Displays tool usage instructions and command line options.

.. option:: -loop-convert

  Makes use of C++11 range-based for loops where possible. See
  :doc:`LoopConvertTransform`.

.. option:: -use-nullptr

  Makes use of the new C++11 keyword ``nullptr`` where possible.
  See :doc:`UseNullptrTransform`.

.. option:: -use-auto

  Replace the type specifier of variable declarations with the ``auto`` type
  specifier. See :doc:`UseAutoTransform`.

.. option:: -p=<build-path>

  ``<build-path>`` is a CMake build directory containing a file named
  ``compile_commands.json`` which provides compiler options for building
  each source file and can be generated by specifying
  ``-DCMAKE_EXPORT_COMPILE_COMMANDS`` when running CMake. If ``<build-path>``
  is not provided the ``compile_commands.json`` file is searched for through
  all parent directories.

  Alternatively, one can provide compile options to be applied to every
  source file after the optional ``--``.

.. option:: -risk=<risk-level>

  Some transformations may cause a change in semantics. In such cases the
  maximum acceptable risk level specified through the ``-risk`` command
  line option decides whether or not a transformation is applied.

  Three different risk level options are available:

    ``-risk=safe``
      Perform only safe transformations.
    ``-risk=reasonable`` (default)
      Enable transformations that may change semantics.
    ``-risk=risky``
      Enable transformations that are likely to change semantics.

  The meaning of risk is handled differently for each transform. See
  :ref:`transform documentation <transforms>` for details.

.. option:: -final-syntax-check
 
  After applying the final transform to a file, parse the file to ensure the
  last transform did not introduce syntax errors. Syntax errors introduced by
  earlier transforms are already caught when subsequent transforms parse the
  file.

.. option:: -fatal-assembler-warnings

  Treat all compiler warnings as errors.


.. option:: -version

  Displays the version information of this tool.

.. _transforms:

Transformations
===============

* :doc:`LoopConvertTransform`

* :doc:`UseNullptrTransform`

* :doc:`UseAutoTransform`
