diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-03-24 23:38:29 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-03-24 23:38:29 +0000 | 
| commit | deb714ceeb8df9024498cc90e5d5b8df1c206b07 (patch) | |
| tree | 3ced8aa92bbc708b79b7d4d675d1ee33b1e9ea9d /clang/lib/Sema/SemaCXXCast.cpp | |
| parent | 1d38538fb61537d172123104c202fd8b3a210b42 (diff) | |
| download | bcm5719-llvm-deb714ceeb8df9024498cc90e5d5b8df1c206b07.tar.gz bcm5719-llvm-deb714ceeb8df9024498cc90e5d5b8df1c206b07.zip | |
Switch static_cast from the old reference-initialization code (via
CheckReferenceInit) over to the new initialization code
(InitializationSequence), which is better-tested and doesn't require
us to compute the entire conversion sequence twice.
llvm-svn: 99452
Diffstat (limited to 'clang/lib/Sema/SemaCXXCast.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaCXXCast.cpp | 37 | 
1 files changed, 17 insertions, 20 deletions
| diff --git a/clang/lib/Sema/SemaCXXCast.cpp b/clang/lib/Sema/SemaCXXCast.cpp index 014cec2b650..d3fe6aee5c9 100644 --- a/clang/lib/Sema/SemaCXXCast.cpp +++ b/clang/lib/Sema/SemaCXXCast.cpp @@ -913,27 +913,24 @@ TryStaticImplicitCast(Sema &Self, Expr *&SrcExpr, QualType DestType,      // At this point of CheckStaticCast, if the destination is a reference,      // this has to work. There is no other way that works.      // On the other hand, if we're checking a C-style cast, we've still got -    // the reinterpret_cast way. So in C-style mode, we first try the call -    // with an ICS to suppress errors. -    if (CStyle) { -      ImplicitConversionSequence ICS; -      if(Self.CheckReferenceInit(SrcExpr, DestType, OpRange.getBegin(), -                                 /*SuppressUserConversions=*/false, -                                 /*AllowExplicit=*/false, /*ForceRValue=*/false, -                                 &ICS)) -        return TC_NotApplicable; +    // the reinterpret_cast way. +    InitializedEntity Entity = InitializedEntity::InitializeTemporary(DestType); +    InitializationKind InitKind = InitializationKind::CreateCast(OpRange,  +                                                                 CStyle);     +    InitializationSequence InitSeq(Self, Entity, InitKind, &SrcExpr, 1); +    if (InitSeq.getKind() == InitializationSequence::FailedSequence && CStyle) +      return TC_NotApplicable; +     +    Sema::OwningExprResult Result +      = InitSeq.Perform(Self, Entity, InitKind, +                        Action::MultiExprArg(Self, (void**)&SrcExpr, 1)); +    if (Result.isInvalid()) { +      msg = 0; +      return TC_Failed;      } -    // Now we're committed either way. -    if(!Self.CheckReferenceInit(SrcExpr, DestType, OpRange.getBegin(), -                                /*SuppressUserConversions=*/false, -                                /*AllowExplicit=*/false, -                                /*ForceRValue=*/false, 0, -                                /*IgnoreBaseAccess=*/CStyle)) -      return TC_Success; - -    // We already got an error message. -    msg = 0; -    return TC_Failed; +     +    SrcExpr = Result.takeAs<Expr>(); +    return TC_Success;    }    if (DestType->isRecordType()) { | 

