[cfe-commits] r93529 - in /cfe/trunk/lib/Sema: Sema.h SemaExpr.cpp TreeTransform.h
John McCall
rjmccall at apple.com
Fri Jan 15 10:56:45 PST 2010
Author: rjmccall
Date: Fri Jan 15 12:56:44 2010
New Revision: 93529
URL: http://llvm.org/viewvc/llvm-project?rev=93529&view=rev
Log:
Don't lose type source information when rebuilding C-style cast expressions.
Also we don't need to recheck for altivec initializers, I think.
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.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=93529&r1=93528&r2=93529&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Fri Jan 15 12:56:44 2010
@@ -1651,6 +1651,11 @@
virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
TypeTy *Ty, SourceLocation RParenLoc,
ExprArg Op);
+ OwningExprResult BuildCStyleCastExpr(SourceLocation LParenLoc,
+ TypeSourceInfo *Ty,
+ SourceLocation RParenLoc,
+ ExprArg Op);
+
virtual bool TypeIsVectorType(TypeTy *Ty) {
return GetTypeFromParser(Ty)->isVectorType();
}
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=93529&r1=93528&r2=93529&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jan 15 12:56:44 2010
@@ -3906,28 +3906,38 @@
Action::OwningExprResult
Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc, TypeTy *Ty,
SourceLocation RParenLoc, ExprArg Op) {
- CastExpr::CastKind Kind = CastExpr::CK_Unknown;
-
assert((Ty != 0) && (Op.get() != 0) &&
"ActOnCastExpr(): missing type or expr");
- Expr *castExpr = (Expr *)Op.get();
TypeSourceInfo *castTInfo;
QualType castType = GetTypeFromParser(Ty, &castTInfo);
if (!castTInfo)
castTInfo = Context.getTrivialTypeSourceInfo(castType, SourceLocation());
// If the Expr being casted is a ParenListExpr, handle it specially.
+ // FIXME: preserve type source info.
+ Expr *castExpr = (Expr *)Op.get();
if (isa<ParenListExpr>(castExpr))
return ActOnCastOfParenListExpr(S, LParenLoc, RParenLoc, move(Op),castType);
+
+ return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, move(Op));
+}
+
+Action::OwningExprResult
+Sema::BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty,
+ SourceLocation RParenLoc, ExprArg Op) {
+ Expr *castExpr = static_cast<Expr*>(Op.get());
+
CXXMethodDecl *Method = 0;
- if (CheckCastTypes(SourceRange(LParenLoc, RParenLoc), castType, castExpr,
+ CastExpr::CastKind Kind = CastExpr::CK_Unknown;
+ if (CheckCastTypes(SourceRange(LParenLoc, RParenLoc), Ty->getType(), castExpr,
Kind, Method))
return ExprError();
if (Method) {
- OwningExprResult CastArg = BuildCXXCastArgument(LParenLoc, castType, Kind,
- Method, move(Op));
+ // FIXME: preserve type source info here
+ OwningExprResult CastArg = BuildCXXCastArgument(LParenLoc, Ty->getType(),
+ Kind, Method, move(Op));
if (CastArg.isInvalid())
return ExprError();
@@ -3937,8 +3947,8 @@
Op.release();
}
- return Owned(new (Context) CStyleCastExpr(castType.getNonReferenceType(),
- Kind, castExpr, castTInfo,
+ return Owned(new (Context) CStyleCastExpr(Ty->getType().getNonReferenceType(),
+ Kind, castExpr, Ty,
LParenLoc, RParenLoc));
}
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=93529&r1=93528&r2=93529&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Fri Jan 15 12:56:44 2010
@@ -1018,11 +1018,8 @@
TypeSourceInfo *TInfo,
SourceLocation RParenLoc,
ExprArg SubExpr) {
- return getSema().ActOnCastExpr(/*Scope=*/0,
- LParenLoc,
- TInfo->getType().getAsOpaquePtr(),
- RParenLoc,
- move(SubExpr));
+ return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
+ move(SubExpr));
}
/// \brief Build a new compound literal expression.
More information about the cfe-commits
mailing list