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 | 9d125033a9853f3b572a4c9e2f9e2d4e5e346973 (patch) | |
tree | 2dd9dfebc8fadb1196b20665ad0943f9e344307e /lib/Sema/SemaCXXCast.cpp | |
parent | 8b456e841ea33b937ad6e5b2cccc0ca8173bf7bb (diff) |
Preserve type source information in explicit cast expressions.
Patch by Enea Zaffanella.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93522 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCXXCast.cpp')
-rw-r--r-- | lib/Sema/SemaCXXCast.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp index f924bd3bb1..178bc7a014 100644 --- a/lib/Sema/SemaCXXCast.cpp +++ b/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)); } } |