Use dynamic_cast where appropriate

Done using the cppcoreguidelines-pro-type-cstyle-cast check of clang-tidy
2 files changed