[clang] [Clang] Diagnose down casting static_cast (PR #117914)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 5 13:18:18 PST 2024


5chmidti wrote:

> I think the checker can be removed if clang has this kind of compilation time warning and can totally cover the checker.

It only covers the whole check if `StrictMode` is not set to `false`, because that enables diagnosing down-casts for non-polymorphic types as well.

> Perhaps that check should ensure this warning is enabled and otherwise do nothing? 

Afaik that would be a first. If there is an equivalent warning for a check, then the check can be removed I favor of the warning. In this case, I think that the check is probably going to stay, but I think that will be a question for the time when this PR is finalized/merged, as to how much the warning covers the check.

@cor3ntin with CRTP there shouldn't be virtual functions, otherwise why use CRTP, which means the record fails the check for being polymorphic.

https://github.com/llvm/llvm-project/pull/117914


More information about the cfe-commits mailing list