llvm-redundant-casting¶
Points out uses of cast<>, dyn_cast<>, isa<> and their or_null
variants that are unnecessary because the argument already is of the target
type, or a derived type thereof.
struct A {};
A a;
// Finds:
A x = cast<A>(a);
// replaced by:
A x = a;
struct B : public A {};
B b;
// Finds:
A y = cast<A>(b);
// replaced by:
A y = b;
struct C : public A {};
C c;
// Finds:
bool r1 = isa<A>(a) // always true
bool r2 = isa<A>(b) // always true
bool r3 = isa<B, C>(c) // always true
- Supported functions:
llvm::castllvm::cast_or_nullllvm::cast_if_presentllvm::dyn_castllvm::dyn_cast_or_nullllvm::dyn_cast_if_presentllvm::isallvm::isa_and_nonnullllvm::isa_and_present