diff options
| author | John McCall <rjmccall@apple.com> | 2010-01-15 18:39:57 +0000 | 
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-01-15 18:39:57 +0000 | 
| commit | 9751396d702862b2eb4d200ac83838e744b1c355 (patch) | |
| tree | 58ed85e7242ae270ded1a337b37752a8543104a3 /clang/lib/Sema/SemaCXXCast.cpp | |
| parent | cc2ad08a11665ee752ab40b3e3ce62936802f27a (diff) | |
| download | bcm5719-llvm-9751396d702862b2eb4d200ac83838e744b1c355.tar.gz bcm5719-llvm-9751396d702862b2eb4d200ac83838e744b1c355.zip | |
Preserve type source information in explicit cast expressions.
Patch by Enea Zaffanella.
llvm-svn: 93522
Diffstat (limited to 'clang/lib/Sema/SemaCXXCast.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaCXXCast.cpp | 14 | 
1 files changed, 8 insertions, 6 deletions
| diff --git a/clang/lib/Sema/SemaCXXCast.cpp b/clang/lib/Sema/SemaCXXCast.cpp index f924bd3bb12..178bc7a0140 100644 --- a/clang/lib/Sema/SemaCXXCast.cpp +++ b/clang/lib/Sema/SemaCXXCast.cpp @@ -117,8 +117,10 @@ Sema::ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,                          SourceLocation LParenLoc, ExprArg E,                          SourceLocation RParenLoc) {    Expr *Ex = E.takeAs<Expr>(); -  // FIXME: Preserve type source info. -  QualType DestType = GetTypeFromParser(Ty); +  TypeSourceInfo *DestTInfo; +  QualType DestType = GetTypeFromParser(Ty, &DestTInfo); +  if (!DestTInfo) +    DestTInfo = Context.getTrivialTypeSourceInfo(DestType, SourceLocation());    SourceRange OpRange(OpLoc, RParenLoc);    SourceRange DestRange(LAngleBracketLoc, RAngleBracketLoc); @@ -133,14 +135,14 @@ Sema::ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,      if (!TypeDependent)        CheckConstCast(*this, Ex, DestType, OpRange, DestRange);      return Owned(new (Context) CXXConstCastExpr(DestType.getNonReferenceType(), -                                                Ex, DestType, OpLoc)); +                                                Ex, DestTInfo, OpLoc));    case tok::kw_dynamic_cast: {      CastExpr::CastKind Kind = CastExpr::CK_Unknown;      if (!TypeDependent)        CheckDynamicCast(*this, Ex, DestType, OpRange, DestRange, Kind);      return Owned(new (Context)CXXDynamicCastExpr(DestType.getNonReferenceType(), -                                                 Kind, Ex, DestType, OpLoc)); +                                                 Kind, Ex, DestTInfo, OpLoc));    }    case tok::kw_reinterpret_cast: {      CastExpr::CastKind Kind = CastExpr::CK_Unknown; @@ -148,7 +150,7 @@ Sema::ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,        CheckReinterpretCast(*this, Ex, DestType, OpRange, DestRange, Kind);      return Owned(new (Context) CXXReinterpretCastExpr(                                    DestType.getNonReferenceType(), -                                  Kind, Ex, DestType, OpLoc)); +                                  Kind, Ex, DestTInfo, OpLoc));    }    case tok::kw_static_cast: {      CastExpr::CastKind Kind = CastExpr::CK_Unknown; @@ -169,7 +171,7 @@ Sema::ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,      }      return Owned(new (Context) CXXStaticCastExpr(DestType.getNonReferenceType(), -                                                 Kind, Ex, DestType, OpLoc)); +                                                 Kind, Ex, DestTInfo, OpLoc));    }    } | 

