[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 23 07:52:33 PDT 2019

aaron.ballman added a comment.

In D59802#1474300 <https://reviews.llvm.org/D59802#1474300>, @hintonda wrote:

> @aaron.ballman, I just ran it over llvm/lib, including all in-tree headers, and it seems to work fine.  However, it did miss this one:
> - if (V && isa<Instruction>(V) && (EntInst = cast<Instruction>(V)) && +        if (isa_and_nonnull<Instruction>(V) && (EntInst = cast<Instruction>(V)) &&
>   It got the first, but not the second.  Not sure how to pick that one up.  Even ran it a second time on just that file, but still didn't pick it up.  Any ideas?

I don't think it's a critical case to cover for the check, but yeah, it looks like that code really wants to be `(EntInst = dyn_cast_or_null<Instruction>(V))`. I think that looking for a pattern to handle this case would be tricky though and given how infrequent it seems to show up in the code base, I am not too worried. Someone applying the check will still get a notice for the `Var && isa<Type>(Var)` part of the expression, so they can hopefully see there's more related cleanup to be done.

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list