modernize-avoid-c-style-cast

Finds usages of C-style casts.

C-style casts can perform a variety of different conversions (const_cast, static_cast, reinterpret_cast, or a combination). This makes them dangerous as the intent is not clear, and they can silently perform unsafe conversions between incompatible types.

This check is similar to -Wold-style-cast, but it suggests automated fixes in some cases. The reported locations should not be different from the ones generated by -Wold-style-cast.

Examples

class A {
  public:
  std::string v;
};

A a;
double *num = (double*)(&a);           // Compiles! Hides danger
// num = static_cast<double*>(&a);     // Won't compile (good!)
num = reinterpret_cast<double*>(&a);   // Compiles, danger is explicit

References

Corresponding cpplint.py check name: readability/casting.