Commit Graph

2 Commits

Author SHA1 Message Date
Stephan Bergmann
9308f35318 Adapt to Clang 3.4 (in preparation of a buildbot on CentOS 7)
Change-Id: Ie2859f03b31c57deb7fd0deba3285f782e33b239
2016-06-28 16:26:33 +02:00
Stephan Bergmann
75f0f9d553 New loplugin:faileddyncast
Offline discussion about tdf#96067 "Crash on undo row inserts" brought up the
idea to warn about cases where uses of dynamic_cast are statically knwon to
always fail.  Clang's clang::AST::CXXDynamicCastExpr::isAlwaysNull already
implements such a check, reporting true if the casted-from class is final, but
has two issues:

For one, it does not work for template code, when one of the involved types is a
template parameter type (so e.g., DestType->castAs<PointerType>() can crash).

For another, it misses the opportunity to report true if the casted-to type is
final and only derives from the casted-from type non-publicly.  My hope was that
this, after the "final" decorations in 548c43238d
"Mark some classes as final," might turn up the culprit of tdf#96067 (with a
scenario similar to the failed dynamic_cast on private derivation in
63b67ab5ca "Use public derivation, and remove
then-unnecessary downcasts")---but not so.

Change-Id: I962ee19820758f9c601f4a292da7f37fa9dff5ce
2016-01-12 15:00:33 +01:00