[cfe-commits] r93533 - in /cfe/trunk/lib/Sema: Sema.h SemaCXXCast.cpp TreeTransform.h
John McCall
rjmccall at apple.com
Fri Jan 15 11:13:16 PST 2010
Author: rjmccall
Date: Fri Jan 15 13:13:16 2010
New Revision: 93533
URL: http://llvm.org/viewvc/llvm-project?rev=93533&view=rev
Log:
Preserve type source information for C++ named casts through template
instantiation.
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCXXCast.cpp
cfe/trunk/lib/Sema/TreeTransform.h
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=93533&r1=93532&r2=93533&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Fri Jan 15 13:13:16 2010
@@ -1925,6 +1925,13 @@
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,
Modified: cfe/trunk/lib/Sema/SemaCXXCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXCast.cpp?rev=93533&r1=93532&r2=93533&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Fri Jan 15 13:13:16 2010
@@ -116,13 +116,26 @@
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?
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=93533&r1=93532&r2=93533&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Fri Jan 15 13:13:16 2010
@@ -1237,11 +1237,10 @@
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 @@
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 @@
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 @@
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.
More information about the cfe-commits
mailing list