Derived Class in BaseToDerived static cast


If i have a static_cast(b): is the ‘real’ class of D, which b will be casted to at runtime, known at compile-time? In CodeGen/CGExpr.cpp the explicit case “BaseToDerived” is handled and you can retrieve TypeSourceInfo using the function getTypeInfoAsWritten(). It seems that this information enough to get the exact type of this cast at compile-time and should also work for Template programming, as my understanding is that clang should have abstracted the code into specific types at this point. Am I wrong here?
Is there any case where the type is not known at compile time? Can the ‘real’ type be hidden behind a pointer?

Thanks in advance.