Commit: 3cb4c513080ebeead7c5629a7f0503fae9513803 Author: Sergey Sharybin Date: Fri Nov 6 16:05:40 2020 +0100 Branches: master https://developer.blender.org/rB3cb4c513080ebeead7c5629a7f0503fae9513803
Cleanup: Clang-Tidy, modernize-make-unique =================================================================== M .clang-tidy M source/blender/blenlib/intern/mesh_intersect.cc M source/blender/blenlib/tests/BLI_map_test.cc M source/blender/blenlib/tests/BLI_set_test.cc M source/blender/blenlib/tests/BLI_stack_cxx_test.cc M source/blender/blenlib/tests/BLI_vector_set_test.cc M source/blender/blenlib/tests/BLI_vector_test.cc M source/blender/freestyle/intern/view_map/AutoPtrHelper.h M source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp =================================================================== diff --git a/.clang-tidy b/.clang-tidy index af1f779a056..70851d0023f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -45,7 +45,6 @@ Checks: > -modernize-loop-convert, -modernize-pass-by-value, -modernize-use-default-member-init, - -modernize-make-unique, -modernize-raw-string-literal, -modernize-avoid-bind, -modernize-use-override, diff --git a/source/blender/blenlib/intern/mesh_intersect.cc b/source/blender/blenlib/intern/mesh_intersect.cc index b1b8bd61b40..6647f8b8c92 100644 --- a/source/blender/blenlib/intern/mesh_intersect.cc +++ b/source/blender/blenlib/intern/mesh_intersect.cc @@ -519,7 +519,7 @@ class IMeshArena::IMeshArenaImpl : NonCopyable, NonMovable { IMeshArena::IMeshArena() { - pimpl_ = std::unique_ptr<IMeshArenaImpl>(new IMeshArenaImpl()); + pimpl_ = std::unique_ptr<IMeshArenaImpl>(std::make_unique<IMeshArenaImpl>()); } IMeshArena::~IMeshArena() diff --git a/source/blender/blenlib/tests/BLI_map_test.cc b/source/blender/blenlib/tests/BLI_map_test.cc index e61d638c681..ecdf2627520 100644 --- a/source/blender/blenlib/tests/BLI_map_test.cc +++ b/source/blender/blenlib/tests/BLI_map_test.cc @@ -419,9 +419,9 @@ TEST(map, Clear) TEST(map, UniquePtrValue) { - auto value1 = std::unique_ptr<int>(new int()); - auto value2 = std::unique_ptr<int>(new int()); - auto value3 = std::unique_ptr<int>(new int()); + auto value1 = std::unique_ptr<int>(std::make_unique<int>()); + auto value2 = std::unique_ptr<int>(std::make_unique<int>()); + auto value3 = std::unique_ptr<int>(std::make_unique<int>()); int *value1_ptr = value1.get(); @@ -429,12 +429,12 @@ TEST(map, UniquePtrValue) map.add_new(1, std::move(value1)); map.add(2, std::move(value2)); map.add_overwrite(3, std::move(value3)); - map.lookup_or_add_cb(4, []() { return std::unique_ptr<int>(new int()); }); - map.add_new(5, std::unique_ptr<int>(new int())); - map.add(6, std::unique_ptr<int>(new int())); - map.add_overwrite(7, std::unique_ptr<int>(new int())); - map.lookup_or_add(8, std::unique_ptr<int>(new int())); - map.pop_default(9, std::unique_ptr<int>(new int())); + map.lookup_or_add_cb(4, []() { return std::unique_ptr<int>(std::make_unique<int>()); }); + map.add_new(5, std::unique_ptr<int>(std::make_unique<int>())); + map.add(6, std::unique_ptr<int>(std::make_unique<int>())); + map.add_overwrite(7, std::unique_ptr<int>(std::make_unique<int>())); + map.lookup_or_add(8, std::unique_ptr<int>(std::make_unique<int>())); + map.pop_default(9, std::unique_ptr<int>(std::make_unique<int>())); EXPECT_EQ(map.lookup(1).get(), value1_ptr); EXPECT_EQ(map.lookup_ptr(100), nullptr); diff --git a/source/blender/blenlib/tests/BLI_set_test.cc b/source/blender/blenlib/tests/BLI_set_test.cc index dbe820c9d15..840472e4c0b 100644 --- a/source/blender/blenlib/tests/BLI_set_test.cc +++ b/source/blender/blenlib/tests/BLI_set_test.cc @@ -221,10 +221,10 @@ TEST(set, OftenAddRemoveContained) TEST(set, UniquePtrValues) { Set<std::unique_ptr<int>> set; - set.add_new(std::unique_ptr<int>(new int())); - auto value1 = std::unique_ptr<int>(new int()); + set.add_new(std::unique_ptr<int>(std::make_unique<int>())); + auto value1 = std::unique_ptr<int>(std::make_unique<int>()); set.add_new(std::move(value1)); - set.add(std::unique_ptr<int>(new int())); + set.add(std::unique_ptr<int>(std::make_unique<int>())); EXPECT_EQ(set.size(), 3); } diff --git a/source/blender/blenlib/tests/BLI_stack_cxx_test.cc b/source/blender/blenlib/tests/BLI_stack_cxx_test.cc index c03893c5596..57e7bfdfdce 100644 --- a/source/blender/blenlib/tests/BLI_stack_cxx_test.cc +++ b/source/blender/blenlib/tests/BLI_stack_cxx_test.cc @@ -170,8 +170,8 @@ TEST(stack, Peek) TEST(stack, UniquePtrValues) { Stack<std::unique_ptr<int>> stack; - stack.push(std::unique_ptr<int>(new int())); - stack.push(std::unique_ptr<int>(new int())); + stack.push(std::unique_ptr<int>(std::make_unique<int>())); + stack.push(std::unique_ptr<int>(std::make_unique<int>())); std::unique_ptr<int> a = stack.pop(); std::unique_ptr<int> &b = stack.peek(); UNUSED_VARS(a, b); diff --git a/source/blender/blenlib/tests/BLI_vector_set_test.cc b/source/blender/blenlib/tests/BLI_vector_set_test.cc index 320cb15f450..cbdc597255a 100644 --- a/source/blender/blenlib/tests/BLI_vector_set_test.cc +++ b/source/blender/blenlib/tests/BLI_vector_set_test.cc @@ -142,9 +142,9 @@ TEST(vector_set, AddMultipleTimes) TEST(vector_set, UniquePtrValue) { VectorSet<std::unique_ptr<int>> set; - set.add_new(std::unique_ptr<int>(new int())); - set.add(std::unique_ptr<int>(new int())); - set.index_of_try(std::unique_ptr<int>(new int())); + set.add_new(std::unique_ptr<int>(std::make_unique<int>())); + set.add(std::unique_ptr<int>(std::make_unique<int>())); + set.index_of_try(std::unique_ptr<int>(std::make_unique<int>())); std::unique_ptr<int> value = set.pop(); UNUSED_VARS(value); } diff --git a/source/blender/blenlib/tests/BLI_vector_test.cc b/source/blender/blenlib/tests/BLI_vector_test.cc index e6b2e7c6365..ffdebd33873 100644 --- a/source/blender/blenlib/tests/BLI_vector_test.cc +++ b/source/blender/blenlib/tests/BLI_vector_test.cc @@ -456,10 +456,10 @@ TEST(vector, AppendNTimes) TEST(vector, UniquePtrValue) { Vector<std::unique_ptr<int>> vec; - vec.append(std::unique_ptr<int>(new int())); - vec.append(std::unique_ptr<int>(new int())); - vec.append(std::unique_ptr<int>(new int())); - vec.append(std::unique_ptr<int>(new int())); + vec.append(std::unique_ptr<int>(std::make_unique<int>())); + vec.append(std::unique_ptr<int>(std::make_unique<int>())); + vec.append(std::unique_ptr<int>(std::make_unique<int>())); + vec.append(std::unique_ptr<int>(std::make_unique<int>())); EXPECT_EQ(vec.size(), 4); std::unique_ptr<int> &a = vec.last(); diff --git a/source/blender/freestyle/intern/view_map/AutoPtrHelper.h b/source/blender/freestyle/intern/view_map/AutoPtrHelper.h index 94fd80bc0fb..cfcfa5e651b 100644 --- a/source/blender/freestyle/intern/view_map/AutoPtrHelper.h +++ b/source/blender/freestyle/intern/view_map/AutoPtrHelper.h @@ -27,6 +27,8 @@ namespace Freestyle { template<typename T> class AutoPtr : public std::unique_ptr<T> { public: + using std::unique_ptr<T>::unique_ptr; + AutoPtr() : std::unique_ptr<T>() { } @@ -42,6 +44,8 @@ template<typename T> class AutoPtr : public std::unique_ptr<T> { other.release(); } + using std::unique_ptr<T>::operator=; + template<typename X> AutoPtr &operator=(AutoPtr<X> &other) = delete; }; diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp index e7d4ec6aa6e..91f3aeac184 100644 --- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp @@ -1381,17 +1381,17 @@ void ViewMapBuilder::ComputeCumulativeVisibility(ViewMap *ioViewMap, AutoPtr<OccluderSource> source; if (_orthographicProjection) { - transform.reset(new BoxGrid::Transform); + transform = std::make_unique<BoxGrid::Transform>(); } else { - transform.reset(new SphericalGrid::Transform); + transform = std::make_unique<SphericalGrid::Transform>(); } if (cull) { - source.reset(new CulledOccluderSource(*transform, we, *ioViewMap, true)); + source = std::make_unique<CulledOccluderSource>(*transform, we, *ioViewMap, true); } else { - source.reset(new OccluderSource(*transform, we)); + source = std::make_unique<OccluderSource>(*transform, we); } AutoPtr<GridDensityProvider> density(factory.newGridDensityProvider(*source, bbox, *transform)); @@ -1419,17 +1419,17 @@ void ViewMapBuilder::ComputeDetailedVisibility(ViewMap *ioViewMap, AutoPtr<OccluderSource> source; if (_orthographicProjection) { - transform.reset(new BoxGrid::Transform); + transform = std::make_unique<BoxGrid::Transform>(); } else { - transform.reset(new SphericalGrid::Transform); + transform = std::make_unique<SphericalGrid::Transform>(); } if (cull) { - source.reset(new CulledOccluderSource(*transform, we, *ioViewMap, true)); + source = std::make_unique<CulledOccluderSource>(*transform, we, *ioViewMap, true); } else { - source.reset(new OccluderSource(*transform, we)); + source = std::make_unique<OccluderSource>(*transform, we); } AutoPtr<GridDensityProvider> density(factory.newGridDensityProvider(*source, bbox, *transform)); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs