diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2013-04-26 20:20:30 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2013-04-26 20:20:30 +0000 |
commit | 84bf8a8c705ba6b4f86c58a49e72afa7b38c2b05 (patch) | |
tree | 2d3ade7bafa97d0ffab8cb88330ed211acdf5a14 /docs | |
parent | 002f9281e010202b87cc120195b67df06ef3e17f (diff) |
Documentation: improve description of make_shared transformation, as suggested by David Blaikie
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180627 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs')
-rw-r--r-- | docs/ClangTools.rst | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/docs/ClangTools.rst b/docs/ClangTools.rst index c3303c7248..d7f03a53ae 100644 --- a/docs/ClangTools.rst +++ b/docs/ClangTools.rst @@ -124,14 +124,16 @@ Ideas for new Tools ``foo.begin()`` into ``begin(foo)`` and similarly for ``end()``, where ``foo`` is a standard container. We could also detect similar patterns for arrays. -* ``make_shared`` / ``make_unique`` conversion. This transformation can be - incorporated into the ``auto`` transformation. Will convert +* ``make_shared`` / ``make_unique`` conversion. Part of this transformation +can be incorporated into the ``auto`` transformation. Will convert .. code-block:: c++ std::shared_ptr<Foo> sp(new Foo); std::unique_ptr<Foo> up(new Foo); + func(std::shared_ptr<Foo>(new Foo), bar()); + into: .. code-block:: c++ @@ -139,6 +141,10 @@ Ideas for new Tools auto sp = std::make_shared<Foo>(); auto up = std::make_unique<Foo>(); // In C++14 mode. + // This also affects correctness. For the cases where bar() throws, + // make_shared() is safe and the original code may leak. + func(std::make_shared<Foo>(), bar()); + * ``tr1`` removal tool. Will migrate source code from using TR1 library features to C++11 library. For example: |