Author: omtcyfz Date: Wed Aug 3 01:54:24 2016 New Revision: 277577 URL: http://llvm.org/viewvc/llvm-project?rev=277577&view=rev Log: [clang-tidy] address concerns with rL277340
alexfh raised a concern with https://reviews.llvm.org/rL277340 After retabbing indentation of .. code-block:: was increased to 8, 4 spaces indentation should be enough. Reviewers: alexfh Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst?rev=277577&r1=277576&r2=277577&view=diff ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst (original) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst Wed Aug 3 01:54:24 2016 @@ -20,25 +20,25 @@ Before: .. code:: c++ - std::vector<MyClass> v; - v.push_back(MyClass(21, 37)); + std::vector<MyClass> v; + v.push_back(MyClass(21, 37)); - std::vector<std::pair<int,int>> w; + std::vector<std::pair<int,int>> w; - w.push_back(std::pair<int,int>(21, 37)); - w.push_back(std::make_pair(21L, 37L)); + w.push_back(std::pair<int,int>(21, 37)); + w.push_back(std::make_pair(21L, 37L)); After: .. code:: c++ - std::vector<MyClass> v; - v.emplace_back(21, 37); + std::vector<MyClass> v; + v.emplace_back(21, 37); - std::vector<std::pair<int,int>> w; - w.emplace_back(21, 37); - // This will be fixed to w.push_back(21, 37); in next version - w.emplace_back(std::make_pair(21L, 37L); + std::vector<std::pair<int,int>> w; + w.emplace_back(21, 37); + // This will be fixed to w.push_back(21, 37); in next version + w.emplace_back(std::make_pair(21L, 37L); The other situation is when we pass arguments that will be converted to a type inside a container. @@ -47,15 +47,15 @@ Before: .. code:: c++ - std::vector<boost::optional<std::string> > v; - v.push_back("abc"); + std::vector<boost::optional<std::string> > v; + v.push_back("abc"); After: .. code:: c++ - std::vector<boost::optional<std::string> > v; - v.emplace_back("abc"); + std::vector<boost::optional<std::string> > v; + v.emplace_back("abc"); In some cases the transformation would be valid, but the code @@ -65,9 +65,9 @@ In this case the calls of ``push_back`` .. code:: c++ std::vector<std::unique_ptr<int>> v; - v.push_back(std::unique_ptr<int>(new int(0))); - auto *ptr = new int(1); - v.push_back(std::unique_ptr<int>(ptr)); + v.push_back(std::unique_ptr<int>(new int(0))); + auto *ptr = new int(1); + v.push_back(std::unique_ptr<int>(ptr)); This is because replacing it with ``emplace_back`` could cause a leak of this pointer if ``emplace_back`` would throw exception before emplacement _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits