• Stephan Bergmann's avatar
    New loplugin:faileddyncast · 75f0f9d5
    Stephan Bergmann yazdı
    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 548c4323
    "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
    63b67ab5 "Use public derivation, and remove
    then-unnecessary downcasts")---but not so.
    
    Change-Id: I962ee19820758f9c601f4a292da7f37fa9dff5ce
    75f0f9d5
Adı
Son kayıt (commit)
Son güncelleme
..
clang Loading commit data...
.gitignore Loading commit data...
Makefile Loading commit data...
Makefile-clang.mk Loading commit data...
Makefile.mk Loading commit data...
README Loading commit data...