[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 13 06:59:34 PDT 2017


JonasToth added a comment.

I added a clarifying comment for some outcommented code still in the patch. I would like to have a bit of discussion on it.
Maybe some parts of the check could be warning-area, i just implemented it here to have it on one place.



================
Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:47
+
+  /// This option is noise, therefore matching is configurable.
+  if (WarnOnMissingElse) {
----------------
s/noise/noisy/


================
Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:68-78
+#if 0
+/// Get the number of different values for the Type T, that is switched on.
+std::size_t getNumberOfPossibleValues(const Type *T,
+                                      const ASTContext &Context) {
+  // This Assertion fails in clang and llvm, when matching on enum types.
+  assert(T->isIntegralType(Context) &&
+         "expecting integral type for discrete set of values");
----------------
I originally tried to implement some logic, that will realize when all paths are covered explicitly.
It didn't work and i think it is irrelevant anyway, since manually covering all paths for integertypes is IMHO unrealistic.

Iam willing to remove the code i currently commented out, just wanted it to be there if there is explicit need for a 'is everything covered'-check.


================
Comment at: docs/clang-tidy/checks/list.rst:41
    cert-oop11-cpp (redirects to misc-move-constructor-init) <cert-oop11-cpp>
-   cppcoreguidelines-c-copy-assignment-signature
+   cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) <cppcoreguidelines-c-copy-assignment-signature>
    cppcoreguidelines-interfaces-global-init
----------------
remove


================
Comment at: test/clang-tidy/hicpp-multiway-paths-covered.cpp:7
+int return_integer() { return 42; }
+
+void problematic_switch(int i) {
----------------
explicitly test, that the warnings for `else` do not occur here.


Repository:
  rL LLVM

https://reviews.llvm.org/D37808





More information about the cfe-commits mailing list