diff options
| author | John McCall <rjmccall@apple.com> | 2010-01-15 19:13:16 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-01-15 19:13:16 +0000 |
| commit | d377e04489153352aad249b3a54cd4fb7c338611 (patch) | |
| tree | 68bc149e85aa2c74529499b3bf64a68698278eb2 /clang/lib/Sema | |
| parent | 86e61533823ed3b35fc10480b9af844d8f211036 (diff) | |
| download | bcm5719-llvm-d377e04489153352aad249b3a54cd4fb7c338611.tar.gz bcm5719-llvm-d377e04489153352aad249b3a54cd4fb7c338611.zip | |
Preserve type source information for C++ named casts through template
instantiation.
llvm-svn: 93533
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/Sema.h | 7 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaCXXCast.cpp | 19 | ||||
| -rw-r--r-- | clang/lib/Sema/TreeTransform.h | 36 |
3 files changed, 39 insertions, 23 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index e86da5d48fc..00a85f88518 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -1925,6 +1925,13 @@ public: ExprArg E, SourceLocation RParenLoc); + OwningExprResult BuildCXXNamedCast(SourceLocation OpLoc, + tok::TokenKind Kind, + TypeSourceInfo *Ty, + ExprArg E, + SourceRange AngleBrackets, + SourceRange Parens); + /// ActOnCXXTypeid - Parse typeid( something ). virtual OwningExprResult ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, diff --git a/clang/lib/Sema/SemaCXXCast.cpp b/clang/lib/Sema/SemaCXXCast.cpp index 178bc7a0140..57c4f9bc2a2 100644 --- a/clang/lib/Sema/SemaCXXCast.cpp +++ b/clang/lib/Sema/SemaCXXCast.cpp @@ -116,13 +116,26 @@ Sema::ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, SourceLocation RAngleBracketLoc, SourceLocation LParenLoc, ExprArg E, SourceLocation RParenLoc) { - Expr *Ex = E.takeAs<Expr>(); + TypeSourceInfo *DestTInfo; QualType DestType = GetTypeFromParser(Ty, &DestTInfo); if (!DestTInfo) DestTInfo = Context.getTrivialTypeSourceInfo(DestType, SourceLocation()); - SourceRange OpRange(OpLoc, RParenLoc); - SourceRange DestRange(LAngleBracketLoc, RAngleBracketLoc); + + return BuildCXXNamedCast(OpLoc, Kind, DestTInfo, move(E), + SourceRange(LAngleBracketLoc, RAngleBracketLoc), + SourceRange(LParenLoc, RParenLoc)); +} + +Action::OwningExprResult +Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, + TypeSourceInfo *DestTInfo, ExprArg E, + SourceRange AngleBrackets, SourceRange Parens) { + Expr *Ex = E.takeAs<Expr>(); + QualType DestType = DestTInfo->getType(); + + SourceRange OpRange(OpLoc, Parens.getEnd()); + SourceRange DestRange = AngleBrackets; // If the type is dependent, we won't do the semantic analysis now. // FIXME: should we check this in a more fine-grained manner? diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 469ff72d3fc..41f465f595c 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -1237,11 +1237,10 @@ public: SourceLocation LParenLoc, ExprArg SubExpr, SourceLocation RParenLoc) { - return getSema().ActOnCXXNamedCast(OpLoc, tok::kw_static_cast, - LAngleLoc, - TInfo->getType().getAsOpaquePtr(), - RAngleLoc, - LParenLoc, move(SubExpr), RParenLoc); + return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast, + TInfo, move(SubExpr), + SourceRange(LAngleLoc, RAngleLoc), + SourceRange(LParenLoc, RParenLoc)); } /// \brief Build a new C++ dynamic_cast expression. @@ -1255,11 +1254,10 @@ public: SourceLocation LParenLoc, ExprArg SubExpr, SourceLocation RParenLoc) { - return getSema().ActOnCXXNamedCast(OpLoc, tok::kw_dynamic_cast, - LAngleLoc, - TInfo->getType().getAsOpaquePtr(), - RAngleLoc, - LParenLoc, move(SubExpr), RParenLoc); + return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast, + TInfo, move(SubExpr), + SourceRange(LAngleLoc, RAngleLoc), + SourceRange(LParenLoc, RParenLoc)); } /// \brief Build a new C++ reinterpret_cast expression. @@ -1273,11 +1271,10 @@ public: SourceLocation LParenLoc, ExprArg SubExpr, SourceLocation RParenLoc) { - return getSema().ActOnCXXNamedCast(OpLoc, tok::kw_reinterpret_cast, - LAngleLoc, - TInfo->getType().getAsOpaquePtr(), - RAngleLoc, - LParenLoc, move(SubExpr), RParenLoc); + return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast, + TInfo, move(SubExpr), + SourceRange(LAngleLoc, RAngleLoc), + SourceRange(LParenLoc, RParenLoc)); } /// \brief Build a new C++ const_cast expression. @@ -1291,11 +1288,10 @@ public: SourceLocation LParenLoc, ExprArg SubExpr, SourceLocation RParenLoc) { - return getSema().ActOnCXXNamedCast(OpLoc, tok::kw_const_cast, - LAngleLoc, - TInfo->getType().getAsOpaquePtr(), - RAngleLoc, - LParenLoc, move(SubExpr), RParenLoc); + return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast, + TInfo, move(SubExpr), + SourceRange(LAngleLoc, RAngleLoc), + SourceRange(LParenLoc, RParenLoc)); } /// \brief Build a new C++ functional-style cast expression. |

