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

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 23 06:07:47 PDT 2018


hokein added a comment.

Could you also update the check documentation `clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst`?



================
Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:83
+  } else {
+    llvm_unreachable("Invalid state");
   }
----------------
We expect that there are only two possible cases here, how about rearrange the code like below, which I think it would simpler and improve code readability.

```
if (const auto *Op = Nodes.getNodeAs<BinaryOperator>("op")) {
  // handle case for "op".
  return;
}
const auto *Cast = Nodes.getNodeAs<ImplicitCastExpr>("cast");
assert(Cast && "must be cast cases");
// ...
```


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53488





More information about the cfe-commits mailing list