[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 30 08:45:36 PDT 2017


JonasToth added inline comments.


================
Comment at: docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst:11
+The relevant sections in the `C++ Core Guidelines <https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md>`_ are I.11, C.33, R.3 and GSL.Views
+The definition of an ``gsl::owner<T*>`` is straight forward
+
----------------
s/an/a/


================
Comment at: docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst:17
+
+it is therefore simple to introduce the owner even without using an implementation of
+the `Guideline Support Library <https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#gsl-guideline-support-library>`_.
----------------
s/it/It/


================
Comment at: docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst:27
+
+  // Creating an owner with factory functions is caught.
+  gsl::owner<int*> function_that_returns_owner() { return gsl::owner<int*>(new int(42)); }
----------------
s/caught/checked/


================
Comment at: docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst:97
+  void bad_template_function(T some_object) {
+    // This line will trigger the warning, that an non-owner is assigned to an owner
+    gsl::owner<T*> new_owner = some_object;
----------------
s/an/a/


================
Comment at: docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst:131
+
+The semantic of an ``gsl::owner<T*>`` is mostly like a ``std::unique_ptr<T>``, therefore
+assignment of two ``gsl::owner<T*>`` is considered a move, but therefore the resource
----------------
therefore ... therefore


================
Comment at: docs/clang-tidy/checks/hicpp-signed-bitwise.rst:1
+.. title:: clang-tidy - hicpp-signed-bitwise
+
----------------
remove from diff


================
Comment at: docs/clang-tidy/checks/list.rst:83
    hicpp-noexcept-move (redirects to misc-noexcept-moveconstructor) <hicpp-noexcept-move>
+   hicpp-signed-bitwise
    hicpp-special-member-functions (redirects to cppcoreguidelines-special-member-functions) <hicpp-special-member-functions>
----------------
remove from diff


================
Comment at: test/clang-tidy/hicpp-signed-bitwise.cpp:1
+// RUN: %check_clang_tidy %s hicpp-signed-bitwise %t
+
----------------
remove from diff


https://reviews.llvm.org/D36354





More information about the cfe-commits mailing list