Edwin Vane | e4e7c24 | 2013-03-09 03:33:50 +0000 | [diff] [blame] | 1 | .. index:: cpp11-migrate |
| 2 | |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 3 | ============================ |
| 4 | C++11 Migrator User's Manual |
| 5 | ============================ |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 6 | |
Edwin Vane | 3b9f08d | 2013-03-08 23:26:00 +0000 | [diff] [blame] | 7 | .. toctree:: |
| 8 | :hidden: |
| 9 | |
| 10 | UseAutoTransform |
Edwin Vane | e4e7c24 | 2013-03-09 03:33:50 +0000 | [diff] [blame] | 11 | UseNullptrTransform |
| 12 | LoopConvertTransform |
Edwin Vane | 8ef7fa1 | 2013-04-09 20:49:49 +0000 | [diff] [blame] | 13 | AddOverrideTransform |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 14 | MigratorUsage |
Edwin Vane | 3b9f08d | 2013-03-08 23:26:00 +0000 | [diff] [blame] | 15 | |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 16 | :program:`cpp11-migrate` is a standalone tool used to automatically convert |
| 17 | C++98 and C++03 code to use features of the new C++11 standard where |
| 18 | appropriate. |
| 19 | |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 20 | Getting Started |
| 21 | --------------- |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 22 | |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 23 | To build from source: |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 24 | |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 25 | 1. Read `Getting Started with the LLVM System`_ and `Clang Tools |
| 26 | Documentation`_ for information on getting sources for LLVM, Clang, and |
| 27 | Clang Extra Tools. |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 28 | |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 29 | 2. `Getting Started with the LLVM System`_ and `Building LLVM with CMake`_ give |
| 30 | directions for how to build. With sources all checked out into the |
| 31 | right place the LLVM build will build Clang Extra Tools and their |
| 32 | dependencies automatically. |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 33 | |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 34 | * If using CMake, you can also use the ``cpp11-migrate`` target to build |
| 35 | just the Migrator and its dependencies. |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 36 | |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 37 | Before continuing, take a look at :doc:`MigratorUsage` to see how to invoke the |
| 38 | Migrator. |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 39 | |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 40 | Before running the Migrator on code you'll need the arguments you'd normally |
| 41 | pass to the compiler. If you're migrating a single file with few compiler |
| 42 | arguments, it might be easier to pass the compiler args on the command line |
| 43 | after ``--``. If you're working with multiple files or even a single file |
| 44 | with many compiler args, it's probably best to use a *compilation database*. |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 45 | |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 46 | A `compilation database`_ contains the command-line arguments for multiple |
| 47 | files. If the code you want to transform can be built with CMake, you can |
| 48 | generate this database easily by running CMake with the |
| 49 | ``-DCMAKE_EXPORT_COMPILE_COMMANDS`` option. The Ninja_ build system, since |
| 50 | v1.2, can create this file too using the *compdb* tool: ``ninja -t compdb``. If |
| 51 | you're not already using either of these tools or cannot easily make use of |
| 52 | them you might consider looking into Bear_. |
Edwin Vane | e4e7c24 | 2013-03-09 03:33:50 +0000 | [diff] [blame] | 53 | |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 54 | In addition to the compiler arguments you usually build your code with, you must |
| 55 | provide the option for enabling C++11 features. For clang and versions of gcc |
| 56 | ≥ v4.8 this is ``-std=c++11``. |
Edwin Vane | e4e7c24 | 2013-03-09 03:33:50 +0000 | [diff] [blame] | 57 | |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 58 | Now with compiler arguments, the Migrator can be applied to source. Sources are |
| 59 | transformed in place and changes are only written to disk if compilation errors |
| 60 | aren't caused by the transforms. Each transform will re-parse the output from |
| 61 | the previous transform. The output from the last transform is not checked |
| 62 | unless ``-final-syntax-check`` is enabled. |
Edwin Vane | bdcd135 | 2013-03-09 03:38:20 +0000 | [diff] [blame] | 63 | |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 64 | |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 65 | .. _Ninja: http://martine.github.io/ninja/ |
| 66 | .. _Bear: https://github.com/rizsotto/Bear |
| 67 | .. _compilation database: http://clang.llvm.org/docs/JSONCompilationDatabase.html |
| 68 | .. _Getting Started with the LLVM System: http://llvm.org/docs/GettingStarted.html |
| 69 | .. _Building LLVM with CMake: http://llvm.org/docs/CMake.html |
| 70 | .. _Clang Tools Documentation: http://clang.llvm.org/docs/ClangTools.html |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 71 | |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 72 | Getting Involved |
| 73 | ---------------- |
| 74 | |
| 75 | If you find a bug |
| 76 | |
| 77 | .. raw:: html |
| 78 | |
| 79 | <input type="button" id="logbug" value="Log a Bug!" /> |
| 80 | <script type="text/javascript" src="https://cpp11-migrate.atlassian.net/s/en_USpfg3b3-1988229788/6095/34/1.4.0-m2/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector.js?collectorId=50813874"></script> |
| 81 | <script type="text/javascript">window.ATL_JQ_PAGE_PROPS = { |
| 82 | "triggerFunction": function(showCollectorDialog) { |
| 83 | //Requries that jQuery is available! |
| 84 | jQuery("#logbug").click(function(e) { |
| 85 | e.preventDefault(); |
| 86 | showCollectorDialog(); |
| 87 | }); |
| 88 | }}; |
| 89 | </script> |
| 90 | |
| 91 | Bugs and feature development of the Migrator are tracked at |
| 92 | http://cpp11-migrate.atlassian.net. If you want to get involved the front page |
| 93 | shows a list of outstanding issues or you can browse around the project to get |
| 94 | familiar. To take on issues or contribute feature requests and/or bug reports |
| 95 | you need to sign up for an account from the `log in page`_. An account also |
| 96 | lets you sign up for notifications on issues or vote for unassigned issues to |
| 97 | be completed. |
| 98 | |
| 99 | .. _log in page: https://cpp11-migrate.atlassian.net/login |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 100 | |
Edwin Vane | e4e7c24 | 2013-03-09 03:33:50 +0000 | [diff] [blame] | 101 | .. _transforms: |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 102 | |
| 103 | Transformations |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 104 | --------------- |
| 105 | |
| 106 | The Migrator is a collection of independent transforms which can be |
| 107 | independently enabled. The transforms currently implemented are: |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 108 | |
Edwin Vane | e4e7c24 | 2013-03-09 03:33:50 +0000 | [diff] [blame] | 109 | * :doc:`LoopConvertTransform` |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 110 | |
Edwin Vane | e4e7c24 | 2013-03-09 03:33:50 +0000 | [diff] [blame] | 111 | * :doc:`UseNullptrTransform` |
Edwin Vane | 30f7004 | 2013-02-25 20:37:03 +0000 | [diff] [blame] | 112 | |
Edwin Vane | e4e7c24 | 2013-03-09 03:33:50 +0000 | [diff] [blame] | 113 | * :doc:`UseAutoTransform` |
Edwin Vane | 573ec4f | 2013-06-06 14:30:14 +0000 | [diff] [blame^] | 114 | |
| 115 | * :doc:`AddOverrideTransform` |