sbenza added inline comments. ================ Comment at: test/clang-tidy/cppcoreguidelines-pro-type-static-cast-downcast.cpp:19 @@ +18,3 @@ + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use static_cast to cast from base to derived. Use dynamic_cast instead. (C++ Core Guidelines, rule Type.2) [cppcoreguidelines-pro-type-static-cast-downcast] + // CHECK-FIXES: auto B0 = dynamic_cast<Derived*>(new Base()); + ---------------- This is not a valid dynamic_cast<> because Base is not polymorphic.
================ Comment at: test/clang-tidy/cppcoreguidelines-pro-type-static-cast-downcast.cpp:47 @@ +46,3 @@ + auto B0 = static_cast<B*>(new D()); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use static_cast to cast from base to derived. Use dynamic_cast instead. (C++ Core Guidelines, rule Type.2) [cppcoreguidelines-pro-type-static-cast-downcast] + // CHECK-FIXES: auto B0 = dynamic_cast<B*>(new D()); ---------------- I don't think we should warn here. Whether it is a downcast or whether dynamic_cast<> is correct will depend on the specific instantiation. A fix like this can break valid code. http://reviews.llvm.org/D13368 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits