[cfe-dev] Preliminary reinterpret_cast Sema patch

Doug Gregor doug.gregor at gmail.com
Thu Oct 23 21:58:00 PDT 2008

Hi Sebastian,

On Thu, Oct 23, 2008 at 2:06 PM, Sebastian Redl
<sebastian.redl at getdesigned.at> wrote:
> Here you go. I split the check for casting away constness in its own
> function, since it will be needed for static and dynamic casts as well. Both
> const cast checker and the constness helper now use UnwrapSimilarPointers
> for the loop.

That came out really well. Thanks!

> +/// Check if the pointer conversion from SrcType to DestType casts away
> +/// constness as defined in C++ 5.2.11p8ff. This is used by the cast
> checkers.
> +/// Both arguments must denote pointer types.
> +bool
> +Sema::CastsAwayConstness(QualType SrcType, QualType DestType)
> +{
> + // Casting away constness is defined in C++ 5.2.11p8 with reference to
> +  // C++ 4.4.
> +  // We piggyback on Sema::IsQualificationConversion for this, since the
> rules
> +  // are non-trivial. So first we construct Tcv *...cv* as described in
> +  // C++ 5.2.11p8.

This came out really well. I suggest mapping SrcType and DestType to
their canonical types at this point, just to be safe.

Do you have write access to the Clang repository? If so, please check
in your patch with that minor tweak. If not, just ping me and I'll
check it in. Thanks again!

  - Doug

More information about the cfe-dev mailing list