[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

Eugene Zelenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 19 18:00:15 PDT 2018


Eugene.Zelenko added inline comments.


================
Comment at: clang-tidy/readability/RedundantDataCallCheck.cpp:22
+
+const char kDefaultTypes[] =
+    "::std::basic_string;::std::basic_string_view;::std::vector;::std::array";
----------------
Actually you should use static, not anonymous namespace for variables and functions.


================
Comment at: docs/ReleaseNotes.rst:138
 
+- New :doc:`readability-redundant-data-call
+  <clang-tidy/checks/readability-redundant-data-call>` check
----------------
r is after p :-)


================
Comment at: docs/ReleaseNotes.rst:141
+
+  This check finds and suggests removing redundant `.data()` calls.
+
----------------
Please remove //This check// and enclose .data() in ``, not `. Same for documentation.


================
Comment at: docs/clang-tidy/checks/readability-redundant-data-call.rst:6
+
+This check finds and suggests removing redundant `.data()` calls.
+Currently this covers calling `.data()` and immediately doing array subscript
----------------
Please use as much of 80 characters as possible.


================
Comment at: docs/clang-tidy/checks/readability-redundant-data-call.rst:8
+Currently this covers calling `.data()` and immediately doing array subscript
+operation to obtain a single element, in which case simply calling `operator[]`
+suffice.
----------------
operator[] should be enclosed in ``, not `.


================
Comment at: docs/clang-tidy/checks/readability-redundant-data-call.rst:14
+.. code-block:: c++
+  std::string s = ...;
+  char c = s.data()[i];  // char c = s[i];
----------------
Please insert empty line above.


================
Comment at: docs/clang-tidy/checks/readability-redundant-data-call.rst:22
+
+   The list of type(s) that triggers this check. Default covers `std::string`,
+   `std::string_view`, `std::vector`, `std::array`.
----------------
I think will be good idea to specify default value as complete string.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45702





More information about the cfe-commits mailing list