[PATCH] D53488: [clang-tidy] Catching narrowing from double to float.

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 22 13:12:59 PDT 2018


JonasToth added inline comments.


================
Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:58
+                       const QualType Rhs) {
+  assert(Lhs->isRealType());     // Either integer or floating point.
+  assert(Rhs->isFloatingType()); // Floating point only.
----------------
Couldn't be the conversion from an `int` to an `enum` be considered narrowing as well? (Not sure about the word of the standard) I think it makes sense to change the `assert` to `return false`


================
Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:82
+          << RhsType << LhsType;
   }
 }
----------------
could you please add a final `llvm_unreachable()` to ensure that all possibilites are properly handled?
If that would not fit I would prefer ealry returns instead to show "the end" for each logical path


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53488





More information about the cfe-commits mailing list