[PATCH] D59802: [clang-tidy] Add new checker: llvm-avoid-cast-in-conditional

Don Hinton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 28 00:37:06 PDT 2019


hintonda added a comment.

I looked at the IR generated at `-O2`, and found that while `if (isa<X>(y))` is a modest win over `if (dyn_cast<X>(y)`,  `if (dyn_cast_or_null<X>(y))` generates exactly the same IR that `if(y && isa<X>(y))` does.  Also, if `y` is actually an expression that makes a function call, it's more expensive because it will make the call twice.

So I don't seen any reason to replace `dyn_cast_or_null<>` in conditionals.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59802/new/

https://reviews.llvm.org/D59802





More information about the cfe-commits mailing list