On Thu, Dec 17, 2015 at 6:49 AM, Alexander Kornienko via cfe-commits <cfe-commits@lists.llvm.org> wrote: > Author: alexfh > Date: Thu Dec 17 05:49:19 2015 > New Revision: 255886 > > URL: http://llvm.org/viewvc/llvm-project?rev=255886&view=rev > Log: > Remove clang-modernize. > > Summary: > clang-modernize transforms have moved to clang-tidy. Removing > the old tool now.
Awesome, thank you! ~Aaron > > Reviewers: klimek > > Subscribers: cfe-commits > > Differential Revision: http://reviews.llvm.org/D15606 > > Removed: > clang-tools-extra/trunk/clang-modernize/ > clang-tools-extra/trunk/docs/AddOverrideTransform.rst > clang-tools-extra/trunk/docs/LoopConvertTransform.rst > clang-tools-extra/trunk/docs/MigratorUsage.rst > clang-tools-extra/trunk/docs/ModernizerUsage.rst > clang-tools-extra/trunk/docs/PassByValueTransform.rst > clang-tools-extra/trunk/docs/ReplaceAutoPtrTransform.rst > clang-tools-extra/trunk/docs/UseAutoTransform.rst > clang-tools-extra/trunk/docs/UseNullptrTransform.rst > clang-tools-extra/trunk/test/clang-modernize/ > clang-tools-extra/trunk/unittests/clang-modernize/ > clang-tools-extra/trunk/unittests/include/common/Utility.h > Modified: > clang-tools-extra/trunk/CMakeLists.txt > clang-tools-extra/trunk/Makefile > clang-tools-extra/trunk/docs/clang-modernize.rst > clang-tools-extra/trunk/docs/cpp11-migrate.rst > clang-tools-extra/trunk/docs/index.rst > clang-tools-extra/trunk/test/CMakeLists.txt > clang-tools-extra/trunk/unittests/CMakeLists.txt > clang-tools-extra/trunk/unittests/Makefile > > Modified: clang-tools-extra/trunk/CMakeLists.txt > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/CMakeLists.txt?rev=255886&r1=255885&r2=255886&view=diff > ============================================================================== > --- clang-tools-extra/trunk/CMakeLists.txt (original) > +++ clang-tools-extra/trunk/CMakeLists.txt Thu Dec 17 05:49:19 2015 > @@ -1,5 +1,4 @@ > add_subdirectory(clang-apply-replacements) > -add_subdirectory(clang-modernize) > add_subdirectory(clang-rename) > add_subdirectory(modularize) > if(CLANG_ENABLE_STATIC_ANALYZER) > > Modified: clang-tools-extra/trunk/Makefile > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/Makefile?rev=255886&r1=255885&r2=255886&view=diff > ============================================================================== > --- clang-tools-extra/trunk/Makefile (original) > +++ clang-tools-extra/trunk/Makefile Thu Dec 17 05:49:19 2015 > @@ -12,8 +12,7 @@ CLANG_LEVEL := ../.. > include $(CLANG_LEVEL)/../../Makefile.config > > PARALLEL_DIRS := tool-template modularize pp-trace > -DIRS := clang-apply-replacements clang-modernize clang-rename clang-tidy \ > - clang-query unittests > +DIRS := clang-apply-replacements clang-rename clang-tidy clang-query > unittests > > include $(CLANG_LEVEL)/Makefile > > > Removed: clang-tools-extra/trunk/docs/AddOverrideTransform.rst > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/AddOverrideTransform.rst?rev=255885&view=auto > ============================================================================== > --- clang-tools-extra/trunk/docs/AddOverrideTransform.rst (original) > +++ clang-tools-extra/trunk/docs/AddOverrideTransform.rst (removed) > @@ -1,54 +0,0 @@ > -.. index:: Add-Override Transform > - > -====================== > -Add-Override Transform > -====================== > - > -The Add-Override Transform adds the ``override`` specifier to member > -functions that override a virtual function in a base class and that > -don't already have the specifier. The transform is enabled with the > -:option:`-add-override` option of :program:`clang-modernize`. > -For example: > - > -.. code-block:: c++ > - > - class A { > - public: > - virtual void h() const; > - }; > - > - class B : public A { > - public: > - void h() const; > - > - // The declaration of h is transformed to > - void h() const override; > - }; > - > -Using Expands-to-Override Macros > -================================ > - > -Like LLVM's ``LLVM_OVERRIDE``, several projects have macros that > conditionally > -expand to the ``override`` keyword when compiling with C++11 features > enabled. > -To maintain compatibility with non-C++11 builds, the Add-Override Transform > -supports detection and use of these macros instead of using the ``override`` > -keyword directly. Specify ``-override-macros`` on the command line to the > -Modernizer to enable this behavior. > - > - > -Known Limitations > -================= > -* This transform will not insert the override keyword if a method is > - pure. At the moment it's not possible to track down the pure > - specifier location. > - > -.. code-block:: c++ > - > - class B : public A { > - public: > - virtual void h() const = 0; > - > - // The declaration of h is NOT transformed to > - virtual void h() const override = 0; > - }; > - > > Removed: clang-tools-extra/trunk/docs/LoopConvertTransform.rst > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/LoopConvertTransform.rst?rev=255885&view=auto > ============================================================================== > --- clang-tools-extra/trunk/docs/LoopConvertTransform.rst (original) > +++ clang-tools-extra/trunk/docs/LoopConvertTransform.rst (removed) > @@ -1,257 +0,0 @@ > -.. index:: Loop Convert Transform > - > -====================== > -Loop Convert Transform > -====================== > - > -The Loop Convert Transform is a transformation to convert ``for(...; ...; > -...)`` loops to use the new range-based loops in C++11. The transform is > enabled > -with the :option:`-loop-convert` option of :program:`clang-modernize`. > - > -Three kinds of loops can be converted: > - > -- Loops over statically allocated arrays > -- Loops over containers, using iterators > -- Loops over array-like containers, using ``operator[]`` and ``at()`` > - > -Risk > -==== > - > -Risky > ------ > - > -In loops where the container expression is more complex than just a > -reference to a declared expression (a variable, function, enum, etc.), > -and some part of it appears elsewhere in the loop, we lower our confidence > -in the transformation due to the increased risk of changing semantics. > -Transformations for these loops are marked as `risky`, and thus will only > -be converted if the acceptable risk level is set to ``-risk=risky``. > - > -.. code-block:: c++ > - > - int arr[10][20]; > - int l = 5; > - > - for (int j = 0; j < 20; ++j) > - int k = arr[l][j] + l; // using l outside arr[l] is considered risky > - > - for (int i = 0; i < obj.getVector().size(); ++i) > - obj.foo(10); // using 'obj' is considered risky > - > -See > -:ref:`Range-based loops evaluate end() only > once<IncorrectRiskyTransformation>` > -for an example of an incorrect transformation when the maximum acceptable > risk > -level is set to `risky`. > - > -Reasonable (Default) > --------------------- > - > -If a loop calls ``.end()`` or ``.size()`` after each iteration, the > -transformation for that loop is marked as `reasonable`, and thus will > -be converted if the acceptable risk level is set to ``-risk=reasonable`` > -(default) or higher. > - > -.. code-block:: c++ > - > - // using size() is considered reasonable > - for (int i = 0; i < container.size(); ++i) > - cout << container[i]; > - > -Safe > ----- > - > -Any other loops that do not match the above criteria to be marked as > -`risky` or `reasonable` are marked `safe`, and thus will be converted > -if the acceptable risk level is set to ``-risk=safe`` or higher. > - > -.. code-block:: c++ > - > - int arr[] = {1,2,3}; > - > - for (int i = 0; i < 3; ++i) > - cout << arr[i]; > - > -Example > -======= > - > -Original: > - > -.. code-block:: c++ > - > - const int N = 5; > - int arr[] = {1,2,3,4,5}; > - vector<int> v; > - v.push_back(1); > - v.push_back(2); > - v.push_back(3); > - > - // safe transform > - for (int i = 0; i < N; ++i) > - cout << arr[i]; > - > - // reasonable transform > - for (vector<int>::iterator it = v.begin(); it != v.end(); ++it) > - cout << *it;* > - > - // reasonable transform > - for (int i = 0; i < v.size(); ++i) > - cout << v[i]; > - > -After transformation with risk level set to ``-risk=reasonable`` (default): > - > -.. code-block:: c++ > - > - const int N = 5; > - int arr[] = {1,2,3,4,5}; > - vector<int> v; > - v.push_back(1); > - v.push_back(2); > - v.push_back(3); > - > - // safe transform > - for (auto & elem : arr) > - cout << elem; > - > - // reasonable transform > - for (auto & elem : v) > - cout << elem; > - > - // reasonable transform > - for (auto & elem : v) > - cout << elem; > - > -Limitations > -=========== > - > -There are certain situations where the tool may erroneously perform > -transformations that remove information and change semantics. Users of the > tool > -should be aware of the behaviour and limitations of the transform outlined by > -the cases below. > - > -Comments inside loop headers > ----------------------------- > - > -Comments inside the original loop header are ignored and deleted when > -transformed. > - > -.. code-block:: c++ > - > - for (int i = 0; i < N; /* This will be deleted */ ++i) { } > - > -Range-based loops evaluate end() only once > ------------------------------------------- > - > -The C++11 range-based for loop calls ``.end()`` only once during the > -initialization of the loop. If in the original loop ``.end()`` is called > after > -each iteration the semantics of the transformed loop may differ. > - > -.. code-block:: c++ > - > - // The following is semantically equivalent to the C++11 range-based for > loop, > - // therefore the semantics of the header will not change. > - for (iterator it = container.begin(), e = container.end(); it != e; ++it) > { } > - > - // Instead of calling .end() after each iteration, this loop will be > - // transformed to call .end() only once during the initialization of the > loop, > - // which may affect semantics. > - for (iterator it = container.begin(); it != container.end(); ++it) { } > - > -.. _IncorrectRiskyTransformation: > - > -As explained above, calling member functions of the container in the body > -of the loop is considered `risky`. If the called member function modifies the > -container the semantics of the converted loop will differ due to ``.end()`` > -being called only once. > - > -.. code-block:: c++ > - > - bool flag = false; > - for (vector<T>::iterator it = vec.begin(); it != vec.end(); ++it) { > - // Add a copy of the first element to the end of the vector. > - if (!flag) { > - // This line makes this transformation 'risky'. > - vec.push_back(*it); > - flag = true; > - } > - cout << *it; > - } > - > -The original code above prints out the contents of the container including > the > -newly added element while the converted loop, shown below, will only print > the > -original contents and not the newly added element. > - > -.. code-block:: c++ > - > - bool flag = false; > - for (auto & elem : vec) { > - // Add a copy of the first element to the end of the vector. > - if (!flag) { > - // This line makes this transformation 'risky' > - vec.push_back(elem); > - flag = true; > - } > - cout << elem; > - } > - > -Semantics will also be affected if ``.end()`` has side effects. For example, > in > -the case where calls to ``.end()`` are logged the semantics will change in > the > -transformed loop if ``.end()`` was originally called after each iteration. > - > -.. code-block:: c++ > - > - iterator end() { > - num_of_end_calls++; > - return container.end(); > - } > - > -Overloaded operator->() with side effects > ------------------------------------------ > - > -Similarly, if ``operator->()`` was overloaded to have side effects, such as > -logging, the semantics will change. If the iterator's ``operator->()`` was > used > -in the original loop it will be replaced with ``<container > element>.<member>`` > -instead due to the implicit dereference as part of the range-based for loop. > -Therefore any side effect of the overloaded ``operator->()`` will no longer > be > -performed. > - > -.. code-block:: c++ > - > - for (iterator it = c.begin(); it != c.end(); ++it) { > - it->func(); // Using operator->() > - } > - // Will be transformed to: > - for (auto & elem : c) { > - elem.func(); // No longer using operator->() > - } > - > -Pointers and references to containers > -------------------------------------- > - > -While most of the transform's risk analysis is dedicated to determining > whether > -the iterator or container was modified within the loop, it is possible to > -circumvent the analysis by accessing and modifying the container through a > -pointer or reference. > - > -If the container were directly used instead of using the pointer or reference > -the following transformation would have only been applied at the > ``-risk=risky`` > -level since calling a member function of the container is considered `risky`. > -The transform cannot identify expressions associated with the container that > are > -different than the one used in the loop header, therefore the transformation > -below ends up being performed at the ``-risk=safe`` level. > - > -.. code-block:: c++ > - > - vector<int> vec; > - > - vector<int> *ptr = &vec; > - vector<int> &ref = vec; > - > - for (vector<int>::iterator it = vec.begin(), e = vec.end(); it != e; ++it) > { > - if (!flag) { > - // Accessing and modifying the container is considered risky, but the > risk > - // level is not raised here. > - ptr->push_back(*it); > - ref.push_back(*it); > - flag = true; > - } > - } > > Removed: clang-tools-extra/trunk/docs/MigratorUsage.rst > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/MigratorUsage.rst?rev=255885&view=auto > ============================================================================== > --- clang-tools-extra/trunk/docs/MigratorUsage.rst (original) > +++ clang-tools-extra/trunk/docs/MigratorUsage.rst (removed) > @@ -1,6 +0,0 @@ > -=================== > -cpp11-migrate Usage > -=================== > - > -This program has been renamed :doc:`clang-modernize <clang-modernize>`, and > its usage is now > -found in :doc:`ModernizerUsage`. > > Removed: clang-tools-extra/trunk/docs/ModernizerUsage.rst > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ModernizerUsage.rst?rev=255885&view=auto > ============================================================================== > --- clang-tools-extra/trunk/docs/ModernizerUsage.rst (original) > +++ clang-tools-extra/trunk/docs/ModernizerUsage.rst (removed) > @@ -1,313 +0,0 @@ > -===================== > -clang-modernize Usage > -===================== > - > -``clang-modernize [options] [<sources>...] [-- [args]]`` > - > -``<source#>`` specifies the path to the source to migrate. This path may be > -relative to the current directory. If no sources are provided, a compilation > -database provided with `-p`_ can be used to provide sources together with the > -`include/exclude options`_. > - > -By default all transformations are applied. There are two ways to enable a > -subset of the transformations: > - > -1. Explicitly, by referring to the transform options directly, see > - :ref:`transform-specific-command-line-options`. > -2. Implicitly, based on the compilers to support, see > - :ref:`-for-compilers=\<string\> <for-compilers-option>`. > - > -If both ways of specifying transforms are used only explicitly specified > -transformations that are supported by the given compilers will be applied. > - > -General Command Line Options > -============================ > - > -.. option:: -help > - > - Displays tool usage instructions and command line options. > - > -.. option:: -version > - > - Displays the version information of this tool. > - > -.. _-p: > - > -.. option:: -p=<build-path> > - > - ``<build-path>`` is the directory containing a *compilation databasefile*, > a > - file named ``compile_commands.json``, which provides compiler arguments for > - building each source file. CMake can generate this file by specifying > - ``-DCMAKE_EXPORT_COMPILE_COMMANDS=ON`` when running CMake. Ninja_, since > v1.2 > - can also generate this file with ``ninja -t compdb``. If the compilation > - database cannot be used for any reason, an error is reported. > - > - This option is ignored if ``--`` is present. > - > - Files in the compilation database will be transformed if no sources are > - provided and paths to files are explicitly included using ``-include`` or > - ``-include-from``. > - In order to transform all files in a compilation database the following > - command line can be used: > - > - ``clang-modernize -p=<build-path> -include=<project_root>`` > - > - Use ``-exclude`` or ``-exclude-from`` to limit the scope of ``-include``. > - > -.. _Ninja: http://martine.github.io/ninja/ > - > -.. option:: -- [args] > - > - Another way to provide compiler arguments is to specify all arguments on > the > - command line following ``--``. Arguments provided this way are used for > - *every* source file. > - > - If neither ``--`` nor ``-p`` are specified a compilation database is > - searched for starting with the path of the first-provided source file and > - proceeding through parent directories. If no compilation database is found > or > - one is found and cannot be used for any reason then ``-std=c++11`` is used > as > - the only compiler argument. > - > -.. 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:: -summary > - > - Displays a summary of the number of changes each transform made or could > have > - made to each source file immediately after each transform is applied. > - **Accepted** changes are those actually made. **Rejected** changes are > those > - that could have been made if the acceptable risk level were higher. > - **Deferred** changes are those that might be possible but they might > conflict > - with other accepted changes. Re-applying the transform will resolve > deferred > - changes. > - > -.. _for-compilers-option: > - > -.. option:: -for-compilers=<string> > - > - Select transforms targeting the intersection of language features > supported by > - the given compilers. > - > - Four compilers are supported. The transforms are enabled according to this > - table: > - > - =============== ===== === ==== ==== > - Transforms clang gcc icc mscv > - =============== ===== === ==== ==== > - AddOverride (1) 3.0 4.7 14 8 > - LoopConvert 3.0 4.6 13 11 > - PassByValue 3.0 4.6 13 11 > - ReplaceAutoPtr 3.0 4.6 13 11 > - UseAuto 2.9 4.4 12 10 > - UseNullptr 3.0 4.6 12.1 10 > - =============== ===== === ==== ==== > - > - (1): if *-override-macros* is provided it's assumed that the macros are > C++11 > - aware and the transform is enabled without regard to the supported > compilers. > - > - The structure of the argument to the `-for-compilers` option is > - **<compiler>-<major ver>[.<minor ver>]** where **<compiler>** is one of the > - compilers from the above table. > - > - Some examples: > - > - 1. To support `Clang >= 3.0`, `gcc >= 4.6` and `MSVC >= 11`: > - > - ``clang-modernize -for-compilers=clang-3.0,gcc-4.6,msvc-11 <args..>`` > - > - Enables LoopConvert, ReplaceAutoPtr, UseAuto, UseNullptr. > - > - 2. To support `icc >= 12` while using a C++11-aware macro for the > `override` > - virtual specifier: > - > - ``clang-modernize -for-compilers=icc-12 -override-macros <args..>`` > - > - Enables AddOverride and UseAuto. > - > - .. warning:: > - > - If your version of Clang depends on the GCC headers (e.g: when `libc++` > is > - not used), then you probably want to add the GCC version to the targeted > - platforms as well. > - > -.. option:: -perf[=<directory>] > - > - Turns on performance measurement and output functionality. The time it > takes to > - apply each transform is recorded by the migrator and written in JSON format > - to a uniquely named file in the given ``<directory>``. All sources > processed > - by a single Modernizer process are written to the same output file. If > - ``<directory>`` is not provided the default is ``./migrate_perf/``. > - > - The time recorded for a transform includes parsing and creating source code > - replacements. > - > -.. option:: -serialize-replacements > - > - Causes the modernizer to generate replacements and serialize them to disk > but > - not apply them. This can be useful for debugging or for manually running > - ``clang-apply-replacements``. Replacements are serialized in YAML_ format. > - By default serialzied replacements are written to a temporary directory > whose > - name is written to stderr when serialization is complete. > - > -.. _YAML: http://www.yaml.org/ > - > -.. option:: -serialize-dir=<string> > - > - Choose a directory to serialize replacements to. The directory must exist. > - > -.. _include/exclude options: > - > -Path Inclusion/Exclusion Options > -================================ > - > -.. option:: -include=<path1>,<path2>,...,<pathN> > - > - Use this option to indicate which directories contain files that can be > - changed by the modernizer. Inidividual files may be specified if desired. > - Multiple paths can be specified as a comma-separated list. Sources > mentioned > - explicitly on the command line are always included so this option controls > - which other files (e.g. headers) may be changed while transforming > - translation units. > - > -.. option:: -exclude=<path1>,<path2>,...,<pathN> > - > - Used with ``-include`` to provide finer control over which files and > - directories can be transformed. Individual files and files within > directories > - specified by this option **will not** be transformed. Multiple paths can be > - specified as a comma-separated list. > - > -.. option:: -include-from=<filename> > - > - Like ``-include`` but read paths from the given file. Paths should be one > per > - line. > - > -.. option:: -exclude-from=<filename> > - > - Like ``-exclude`` but read paths from the given file. Paths are listed one > - per line. > - > -Formatting Command Line Options > -=============================== > - > -.. option:: -format > - > - Enable reformatting of code changed by transforms. Formatting is done after > - every transform. > - > -.. option:: -style=<string> > - > - Specifies how formatting should be done. The behaviour of this option is > - identical to the same option provided by clang-format_. Refer to > - `clang-format's style options`_ for more details. > - > -.. option:: -style-config=<dir> > - > - When using ``-style=file``, the default behaviour is to look for > - ``.clang-format`` starting in the current directory and then in ancestors. > To > - specify a directory to find the style configuration file, use this option. > - > -Example: > - > -.. code-block:: c++ > - :emphasize-lines: 10-12,18 > - > - // file.cpp > - for (std::vector<int>::const_iterator I = my_container.begin(), > - E = my_container.end(); > - I != E; ++I) { > - std::cout << *I << std::endl; > - } > - > - // No reformatting: > - // clang-modernize -use-auto file.cpp > - for (auto I = my_container.begin(), > - E = my_container.end(); > - I != E; ++I) { > - std::cout << *I << std::endl; > - } > - > - // With reformatting enabled: > - // clang-modernize -format -use-auto file.cpp > - for (auto I = my_container.begin(), E = my_container.end(); I != E; ++I) > { > - std::cout << *I << std::endl; > - } > - > -.. _clang-format: http://clang.llvm.org/docs/ClangFormat.html > -.. _clang-format's style options: > http://clang.llvm.org/docs/ClangFormatStyleOptions.html > - > - > -.. _transform-specific-command-line-options: > - > -Transform-Specific 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:: -user-null-macros=<string> > - > - ``<string>`` is a comma-separated list of user-defined macros that behave > like > - the ``NULL`` macro. The :option:`-use-nullptr` transform will replace these > - macros along with ``NULL``. See :doc:`UseNullptrTransform`. > - > -.. option:: -use-auto > - > - Replace the type specifier of variable declarations with the ``auto`` type > - specifier. See :doc:`UseAutoTransform`. > - > -.. option:: -add-override > - > - Adds the override specifier to member functions where it is appropriate. > That > - is, the override specifier is added to member functions that override a > - virtual function in a base class and that don't already have the specifier. > - See :doc:`AddOverrideTransform`. > - > -.. option:: -override-macros > - > - Tells the Add Override Transform to locate a macro that expands to > - ``override`` and use that macro instead of the ``override`` keyword > directly. > - If no such macro is found, ``override`` is still used. This option enables > - projects that use such macros to maintain build compatibility with > non-C++11 > - code. > - > -.. option:: -pass-by-value > - > - Replace const-reference parameters by values in situations where it can be > - beneficial. > - See :doc:`PassByValueTransform`. > - > -.. option:: -replace-auto_ptr > - > - Replace ``std::auto_ptr`` (deprecated in C++11) by ``std::unique_ptr`` and > - wrap calls to the copy constructor and assignment operator with > - ``std::move()``. > - See :doc:`ReplaceAutoPtrTransform`. > > Removed: clang-tools-extra/trunk/docs/PassByValueTransform.rst > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/PassByValueTransform.rst?rev=255885&view=auto > ============================================================================== > --- clang-tools-extra/trunk/docs/PassByValueTransform.rst (original) > +++ clang-tools-extra/trunk/docs/PassByValueTransform.rst (removed) > @@ -1,165 +0,0 @@ > -.. index:: Pass-By-Value Transform > - > -======================= > -Pass-By-Value Transform > -======================= > - > -The Pass-By-Value Transform makes use of the pass-by-value idiom when > possible. > - > -With move semantics added to the language and the standard library updated > with > -move constructors added for many types it is now interesting to take an > argument > -directly by value, instead of by const-reference, and then copy. This > -transformation allows the compiler to take care of choosing the best way to > -construct the copy. > - > -The transformation is usually beneficial when the calling code passes an > -*rvalue* and assumes the move construction is a cheap operation. This short > -example illustrates how the construction of the value happens: > - > - .. code-block:: c++ > - > - void foo(std::string s); > - std::string get_str(); > - > - void f(const std::string &str) { > - foo(str); // lvalue -> copy construction > - foo(get_str()); // prvalue -> move construction > - } > - > -.. note:: > - > - Currently only constructors are transformed to make use of pass-by-value. > - Contributions that handle other situations are welcome! > - > - > -Pass-by-value in constructors > ------------------------------ > - > -Replaces the uses of const-references constructor parameters that are copied > -into class fields. The parameter is then moved with `std::move()`. > - > -Since `std::move()` is a library function declared in `<utility>` it may be > -necessary to add this include. The transform will add the include directive > when > -necessary. > - > -Example:: > - > - $ clang-modernize -pass-by-value ctor.cpp > - > -**ctor.cpp** > - > - .. code-block:: c++ > - > - #include <string> > - > - class Foo { > - public: > - - Foo(const std::string &Copied, const std::string &ReadOnly) > - - : Copied(Copied), ReadOnly(ReadOnly) > - + Foo(std::string Copied, const std::string &ReadOnly) > - + : Copied(std::move(Copied)), ReadOnly(ReadOnly) > - {} > - > - private: > - std::string Copied; > - const std::string &ReadOnly; > - }; > - > - std::string get_cwd(); > - > - void f(const std::string &Path) { > - // The parameter corresponding to 'get_cwd()' is move-constructed. By > - // using pass-by-value in the Foo constructor we managed to avoid a > - // copy-construction. > - Foo foo(get_cwd(), Path); > - } > - > - > -If the parameter is used more than once no transformation is performed since > -moved objects have an undefined state. It means the following code will be > left > -untouched: > - > -.. code-block:: c++ > - > - #include <string> > - > - void pass(const std::string &S); > - > - struct Foo { > - Foo(const std::string &S) : Str(S) { > - pass(S); > - } > - > - std::string Str; > - }; > - > - > -Risk > -^^^^ > - > -This modification is considered **reasonably safe** (see :option:`-risk` > -option). > - > -A situation where the generated code can be wrong is when the object > referenced > -is modified before the assignment in the init-list through a "hidden" > reference. > - > -Example: > - > -.. code-block:: c++ > - > - std::string s("foo"); > - > - struct Base { > - Base() { > - s = "bar"; > - } > - }; > - > - struct Derived : Base { > - - Derived(const std::string &S) : Field(S) > - + Derived(std::string S) : Field(std::move(S)) > - { } > - > - std::string Field; > - }; > - > - void f() { > - - Derived d(s); // d.Field holds "bar" > - + Derived d(s); // d.Field holds "foo" > - } > - > - > -Note about delayed template parsing > -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > - > -When delayed template parsing is enabled, constructors part of templated > -contexts; templated constructors, constructors in class templates, > constructors > -of inner classes of template classes, etc., are not transformed. Delayed > -template parsing is enabled by default on Windows as a Microsoft extension: > -`Clang Compiler User’s Manual - Microsoft extensions`_. > - > -Delayed template parsing can be enabled using the > `-fdelayed-template-parsing` > -flag and disabled using `-fno-delayed-template-parsing`. > - > -Example: > - > -.. code-block:: c++ > - > - template <typename T> class C { > - std::string S; > - > - public: > - = // using -fdelayed-template-parsing (default on Windows) > - = C(const std::string &S) : S(S) {} > - > - + // using -fno-delayed-template-parsing (default on non-Windows systems) > - + C(std::string S) : S(std::move(S)) {} > - }; > - > -.. _Clang Compiler User’s Manual - Microsoft extensions: > http://clang.llvm.org/docs/UsersManual.html#microsoft-extensions > - > -.. seealso:: > - > - For more information about the pass-by-value idiom, read: `Want Speed? > Pass by Value`_. > - > - .. _Want Speed? Pass by Value: > http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/ > > Removed: clang-tools-extra/trunk/docs/ReplaceAutoPtrTransform.rst > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReplaceAutoPtrTransform.rst?rev=255885&view=auto > ============================================================================== > --- clang-tools-extra/trunk/docs/ReplaceAutoPtrTransform.rst (original) > +++ clang-tools-extra/trunk/docs/ReplaceAutoPtrTransform.rst (removed) > @@ -1,72 +0,0 @@ > -.. index:: Replace-AutoPtr Transform > - > -========================= > -Replace-AutoPtr Transform > -========================= > - > -The Replace-AutoPtr Transform replaces the uses of the deprecated class > -``std::auto_ptr`` by ``std::unique_ptr`` (introduced in C++11). The transfer > of > -ownership, done by the copy-constructor and the assignment operator, is > changed > -to match ``std::unique_ptr`` usage by using explicit calls to > ``std::move()``. > -The transform is enabled with the :option:`-replace-auto_ptr` option of > -:program:`clang-modernize`. > - > -Migration example: > - > -.. code-block:: c++ > - > - -void take_ownership_fn(std::auto_ptr<int> int_ptr); > - +void take_ownership_fn(std::unique_ptr<int> int_ptr); > - > - void f(int x) { > - - std::auto_ptr<int> a(new int(x)); > - - std::auto_ptr<int> b; > - + std::unique_ptr<int> a(new int(x)); > - + std::unique_ptr<int> b; > - > - - b = a; > - - take_ownership_fn(b); > - + b = std::move(a); > - + take_ownership_fn(std::move(b)); > - } > - > - > -Known Limitations > -================= > -* If headers modification is not activated or if a header is not allowed to > be > - changed this transform will produce broken code (compilation error), where > the > - the headers' code will stay unchanged while the code using them will be > - changed. > - > -* Client code that declares a reference to an ``std::auto_ptr`` coming from > code > - that can't be migrated (such as a header coming from a 3\ :sup:`rd` party > - library) will produce a compilation error after migration. This is because > the > - type of the reference will be changed to ``std::unique_ptr`` but the type > - returned by the library won't change, binding a reference to > - ``std::unique_ptr`` from an ``std::auto_ptr``. This pattern doesn't make > much > - sense and usually ``std::auto_ptr`` are stored by value (otherwise what is > the > - point in using them instead of a reference or a pointer?). > - > - .. code-block:: c++ > - > - // <3rd-party header...> > - std::auto_ptr<int> get_value(); > - const std::auto_ptr<int> & get_ref(); > - > - // <calling code (with migration)...> > - -std::auto_ptr<int> a(get_value()); > - +std::unique_ptr<int> a(get_value()); // ok, unique_ptr constructed from > auto_ptr > - > - -const std::auto_ptr<int> & p = get_ptr(); > - +const std::unique_ptr<int> & p = get_ptr(); // won't compile > - > -* Non-instantiated templates aren't modified. > - > - .. code-block:: c++ > - > - template <typename X> > - void f() { > - std::auto_ptr<X> p; > - } > - > - // only 'f<int>()' (or similar) will trigger the replacement > > Removed: clang-tools-extra/trunk/docs/UseAutoTransform.rst > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/UseAutoTransform.rst?rev=255885&view=auto > ============================================================================== > --- clang-tools-extra/trunk/docs/UseAutoTransform.rst (original) > +++ clang-tools-extra/trunk/docs/UseAutoTransform.rst (removed) > @@ -1,137 +0,0 @@ > -.. index:: Use-Auto Transform > - > -================== > -Use-Auto Transform > -================== > - > -The Use-Auto Transform is responsible for using the ``auto`` type specifier > for > -variable declarations to *improve code readability and maintainability*. The > -transform is enabled with the :option:`-use-auto` option of > -:program:`clang-modernize`. For example: > - > -.. code-block:: c++ > - > - std::vector<int>::iterator I = my_container.begin(); > - > - // transforms to: > - > - auto I = my_container.begin(); > - > -The ``auto`` type specifier will only be introduced in situations where the > -variable type matches the type of the initializer expression. In other words > -``auto`` should deduce the same type that was originally spelled in the > source. > -However, not every situation should be transformed: > - > -.. code-block:: c++ > - > - int val = 42; > - InfoStruct &I = SomeObject.getInfo(); > - > - // Should not become: > - > - auto val = 42; > - auto &I = SomeObject.getInfo(); > - > -In this example using ``auto`` for builtins doesn't improve readability. In > -other situations it makes the code less self-documenting impairing > readability > -and maintainability. As a result, ``auto`` is used only introduced in > specific > -situations described below. > - > -Iterators > -========= > - > -Iterator type specifiers tend to be long and used frequently, especially in > -loop constructs. Since the functions generating iterators have a common > format, > -the type specifier can be replaced without obscuring the meaning of code > while > -improving readability and maintainability. > - > -.. code-block:: c++ > - > - for (std::vector<int>::iterator I = my_container.begin(), > - E = my_container.end(); > - I != E; ++I) { > - } > - > - // becomes > - > - for (auto I = my_container.begin(), E = my_container.end(); I != E; ++I) { > - } > - > -The transform will only replace iterator type-specifiers when all of the > -following conditions are satisfied: > -* The iterator is for one of the standard container in ``std`` namespace: > - > - * ``array`` > - > - * ``deque`` > - > - * ``forward_list`` > - > - * ``list`` > - > - * ``vector`` > - > - * ``map`` > - > - * ``multimap`` > - > - * ``set`` > - > - * ``multiset`` > - > - * ``unordered_map`` > - > - * ``unordered_multimap`` > - > - * ``unordered_set`` > - > - * ``unordered_multiset`` > - > - * ``queue`` > - > - * ``priority_queue`` > - > - * ``stack`` > - > -* The iterator is one of the possible iterator types for standard containers: > - > - * ``iterator`` > - > - * ``reverse_iterator`` > - > - * ``const_iterator`` > - > - * ``const_reverse_iterator`` > - > -* In addition to using iterator types directly, typedefs or other ways of > - referring to those types are also allowed. However, implementation-specific > - types for which a type like ``std::vector<int>::iterator`` is itself a > - typedef will not be transformed. Consider the following examples: > - > -.. code-block:: c++ > - > - // The following direct uses of iterator types will be transformed. > - std::vector<int>::iterator I = MyVec.begin(); > - { > - using namespace std; > - list<int>::iterator I = MyList.begin(); > - } > - > - // The type specifier for J would transform to auto since it's a typedef > - // to a standard iterator type. > - typedef std::map<int, std::string>::const_iterator map_iterator; > - map_iterator J = MyMap.begin(); > - > - // The following implementation-specific iterator type for which > - // std::vector<int>::iterator could be a typedef would not be transformed. > - __gnu_cxx::__normal_iterator<int*, std::vector> K = MyVec.begin(); > - > -* The initializer for the variable being declared is not a braced initializer > - list. Otherwise, use of ``auto`` would cause the type of the variable to be > - deduced as``std::initializer_list``. > - > -Known Limitations > -================= > -* If the initializer is an explicit conversion constructor, the transform > will > - not replace the type specifier even though it would be safe to do so. > -* User-defined iterators are not handled at this time. > > Removed: clang-tools-extra/trunk/docs/UseNullptrTransform.rst > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/UseNullptrTransform.rst?rev=255885&view=auto > ============================================================================== > --- clang-tools-extra/trunk/docs/UseNullptrTransform.rst (original) > +++ clang-tools-extra/trunk/docs/UseNullptrTransform.rst (removed) > @@ -1,82 +0,0 @@ > -.. index:: Use-Nullptr Transform > - > -===================== > -Use-Nullptr Transform > -===================== > - > -The Use-Nullptr Transform is a transformation to convert the usage of null > -pointer constants (eg. ``NULL``, ``0``) to use the new C++11 ``nullptr`` > -keyword. The transform is enabled with the :option:`-use-nullptr` option of > -:program:`clang-modernize`. > - > -Example > -======= > - > -.. code-block:: c++ > - > - void assignment() { > - char *a = NULL; > - char *b = 0; > - char c = 0; > - } > - > - int *ret_ptr() { > - return 0; > - } > - > - > -transforms to: > - > -.. code-block:: c++ > - > - void assignment() { > - char *a = nullptr; > - char *b = nullptr; > - char c = 0; > - } > - > - int *ret_ptr() { > - return nullptr; > - } > - > - > -User defined macros > -=================== > - > -By default this transform will only replace the ``NULL`` macro and will skip > any > -user-defined macros that behaves like ``NULL``. The user can use the > -:option:`-user-null-macros` option to specify a comma-separated list of macro > -names that will be transformed along with ``NULL``. > - > -Example > -------- > - > -.. code-block:: c++ > - > - #define MY_NULL (void*)0 > - void assignment() { > - void *p = MY_NULL; > - } > - > - > -using the command-line > - > -.. code-block:: bash > - > - clang-modernize -use-nullptr -user-null-macros=MY_NULL foo.cpp > - > - > -transforms to: > - > -.. code-block:: c++ > - > - #define MY_NULL NULL > - void assignment() { > - int *p = nullptr; > - } > - > - > -Risk > -==== > - > -:option:`-risk` has no effect in this transform. > > Modified: clang-tools-extra/trunk/docs/clang-modernize.rst > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-modernize.rst?rev=255886&r1=255885&r2=255886&view=diff > ============================================================================== > --- clang-tools-extra/trunk/docs/clang-modernize.rst (original) > +++ clang-tools-extra/trunk/docs/clang-modernize.rst Thu Dec 17 05:49:19 2015 > @@ -1,112 +1,2 @@ > -.. index:: clang-modernize > - > -.. note:: > - > - **Deprecation** > - > - As of September 2015 all :program:`clang-modernize` transforms have been > - ported to :doc:`clang-tidy/index`. :program:`clang-modernize` is > deprecated > - and is going to be removed soon. > - > - > -================================== > -Clang C++ Modernizer User's Manual > -================================== > - > -.. toctree:: > - :hidden: > - > - UseAutoTransform > - UseNullptrTransform > - LoopConvertTransform > - AddOverrideTransform > - PassByValueTransform > - ReplaceAutoPtrTransform > - ModernizerUsage > - cpp11-migrate > - MigratorUsage > - > -:program:`clang-modernize` is a standalone tool used to automatically convert > -C++ code written against old standards to use features of the newest C++ > -standard where appropriate. > - > -Getting Started > -=============== > - > -To build from source: > - > -1. Read `Getting Started with the LLVM System`_ and `Clang Tools > - Documentation`_ for information on getting sources for LLVM, Clang, and > - Clang Extra Tools. > - > -2. `Getting Started with the LLVM System`_ and `Building LLVM with CMake`_ > give > - directions for how to build. With sources all checked out into the > - right place the LLVM build will build Clang Extra Tools and their > - dependencies automatically. > - > - * If using CMake, you can also use the ``clang-modernize`` target to build > - just the Modernizer and its dependencies. > - > -Before continuing, take a look at :doc:`ModernizerUsage` to see how to invoke > -the Modernizer. > - > -Before running the Modernizer on code you'll need the arguments you'd > normally > -pass to the compiler. If you're migrating a single file with few compiler > -arguments, it might be easier to pass the compiler args on the command line > -after ``--``. If you don't have any compiler arguments then ``--`` is not > needed. > -If you're working with multiple files or even a single file with many > compiler > -args, it's probably best to use a *compilation database*. > - > -A `compilation database`_ contains the command-line arguments for multiple > -files. If the code you want to transform can be built with CMake, you can > -generate this database easily by running CMake with the > -``-DCMAKE_EXPORT_COMPILE_COMMANDS=ON`` option. The Ninja_ build system, since > -v1.2, can create this file too using the *compdb* tool: ``ninja -t compdb``. > If > -you're not already using either of these tools or cannot easily make use of > -them you might consider looking into Bear_. > - > -In addition to the compiler arguments you usually build your code with, you > must > -provide the option for enabling C++11 features. For clang and versions of gcc > -≥ v4.8 this is ``-std=c++11``. > - > -With compiler arguments in hand, the modernizer can be applied to sources. > Each > -transform is applied to all sources before the next transform. All the > changes > -generated by each transform pass are serialized to disk and applied using > -``clang-apply-replacements``. This executable must be located on the ``PATH`` > -or be present in the same directory as the ``clang-modernizer`` executable. > If > -any changes fail to apply, the modernizer will **not** proceed to the next > -transform and will halt. > - > -There's a small chance that changes made by a transform will produce code > that > -doesn't compile, also causing the modernizer to halt. This can happen with > -bugs in the transforms or use of the pre-processor to make the same code > behave > -differently between translation units. Before logging a bug, be sure which > -situation you are dealing with. > - > -.. _Ninja: http://martine.github.io/ninja/ > -.. _Bear: https://github.com/rizsotto/Bear > -.. _compilation database: > http://clang.llvm.org/docs/JSONCompilationDatabase.html > -.. _Getting Started with the LLVM System: > http://llvm.org/docs/GettingStarted.html > -.. _Building LLVM with CMake: http://llvm.org/docs/CMake.html > -.. _Clang Tools Documentation: http://clang.llvm.org/docs/ClangTools.html > - > - > -.. _transforms: > - > -Transformations > -=============== > - > -The Modernizer is a collection of independent transforms which can be > -independently enabled. The transforms currently implemented are: > - > -* :doc:`LoopConvertTransform` > - > -* :doc:`UseNullptrTransform` > - > -* :doc:`UseAutoTransform` > - > -* :doc:`AddOverrideTransform` > - > -* :doc:`PassByValueTransform` > - > -* :doc:`ReplaceAutoPtrTransform` > +All :program:`clang-modernize` transforms have moved to > :doc:`clang-tidy/index` > +(see the ``modernize`` module). > > Modified: clang-tools-extra/trunk/docs/cpp11-migrate.rst > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/cpp11-migrate.rst?rev=255886&r1=255885&r2=255886&view=diff > ============================================================================== > --- clang-tools-extra/trunk/docs/cpp11-migrate.rst (original) > +++ clang-tools-extra/trunk/docs/cpp11-migrate.rst Thu Dec 17 05:49:19 2015 > @@ -1,5 +1,2 @@ > -============================ > -C++11 Migrator User's Manual > -============================ > - > -This tool has been renamed :doc:`clang-modernize <clang-modernize>`. > +All :program:`clang-modernize` transforms have moved to > :doc:`clang-tidy/index` > +(see the ``modernize`` module). > > Modified: clang-tools-extra/trunk/docs/index.rst > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/index.rst?rev=255886&r1=255885&r2=255886&view=diff > ============================================================================== > --- clang-tools-extra/trunk/docs/index.rst (original) > +++ clang-tools-extra/trunk/docs/index.rst Thu Dec 17 05:49:19 2015 > @@ -15,7 +15,6 @@ Contents > .. toctree:: > :maxdepth: 1 > > - clang-modernize > clang-tidy/index > modularize > pp-trace > > Modified: clang-tools-extra/trunk/test/CMakeLists.txt > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=255886&r1=255885&r2=255886&view=diff > ============================================================================== > --- clang-tools-extra/trunk/test/CMakeLists.txt (original) > +++ clang-tools-extra/trunk/test/CMakeLists.txt Thu Dec 17 05:49:19 2015 > @@ -36,7 +36,6 @@ set(CLANG_TOOLS_TEST_DEPS > > # Individual tools we test. > clang-apply-replacements > - clang-modernize > clang-rename > clang-query > clang-tidy > > Modified: clang-tools-extra/trunk/unittests/CMakeLists.txt > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/CMakeLists.txt?rev=255886&r1=255885&r2=255886&view=diff > ============================================================================== > --- clang-tools-extra/trunk/unittests/CMakeLists.txt (original) > +++ clang-tools-extra/trunk/unittests/CMakeLists.txt Thu Dec 17 05:49:19 2015 > @@ -6,7 +6,6 @@ function(add_extra_unittest test_dirname > endfunction() > > add_subdirectory(clang-apply-replacements) > -add_subdirectory(clang-modernize) > add_subdirectory(clang-rename) > add_subdirectory(clang-query) > add_subdirectory(clang-tidy) > > Modified: clang-tools-extra/trunk/unittests/Makefile > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/Makefile?rev=255886&r1=255885&r2=255886&view=diff > ============================================================================== > --- clang-tools-extra/trunk/unittests/Makefile (original) > +++ clang-tools-extra/trunk/unittests/Makefile Thu Dec 17 05:49:19 2015 > @@ -10,6 +10,6 @@ > CLANG_LEVEL := ../../.. > include $(CLANG_LEVEL)/../../Makefile.config > > -PARALLEL_DIRS := clang-apply-replacements clang-modernize clang-query > clang-tidy clang-rename > +PARALLEL_DIRS := clang-apply-replacements clang-query clang-tidy clang-rename > > include $(CLANG_LEVEL)/Makefile > > Removed: clang-tools-extra/trunk/unittests/include/common/Utility.h > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include/common/Utility.h?rev=255885&view=auto > ============================================================================== > --- clang-tools-extra/trunk/unittests/include/common/Utility.h (original) > +++ clang-tools-extra/trunk/unittests/include/common/Utility.h (removed) > @@ -1,25 +0,0 @@ > -//=-- clang-modernize/Utility.h - Utility functions and macros---*- C++ > -*-===// > -// > -// The LLVM Compiler Infrastructure > -// > -// This file is distributed under the University of Illinois Open Source > -// License. See LICENSE.TXT for details. > -// > -//===----------------------------------------------------------------------===// > - > -#ifndef CLANG_MODERNIZE_UNITTESTS_UTILITY_H > -#define CLANG_MODERNIZE_UNITTESTS_UTILITY_H > - > -// FIXME: copied from unittests/Support/Path.cpp > -#define ASSERT_NO_ERROR(x) > \ > - if (std::error_code ASSERT_NO_ERROR_ec = x) { > \ > - llvm::SmallString<128> MessageStorage; > \ > - llvm::raw_svector_ostream Message(MessageStorage); > \ > - Message << #x ": did not return errc::success.\n" > \ > - << "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" > \ > - << "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; > \ > - GTEST_FATAL_FAILURE_(MessageStorage.c_str()); > \ > - } else { > \ > - } > - > -#endif // CLANG_MODERNIZE_UNITTESTS_UTILITY_H > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits