diff options
| author | John McCall <rjmccall@apple.com> | 2010-01-15 18:56:44 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-01-15 18:56:44 +0000 |
| commit | ebe547414807a4a5e1e02d9cf1471b2962f1bf98 (patch) | |
| tree | 40ff34b2a088ee26da4c929134f317bbd451c2d8 /clang/lib | |
| parent | 0c2538fee24253469a8fe042a8dcd44fa6e7b104 (diff) | |
| download | bcm5719-llvm-ebe547414807a4a5e1e02d9cf1471b2962f1bf98.tar.gz bcm5719-llvm-ebe547414807a4a5e1e02d9cf1471b2962f1bf98.zip | |
Don't lose type source information when rebuilding C-style cast expressions.
Also we don't need to recheck for altivec initializers, I think.
llvm-svn: 93529
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/Sema.h | 5 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 26 | ||||
| -rw-r--r-- | clang/lib/Sema/TreeTransform.h | 7 |
3 files changed, 25 insertions, 13 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index fab72929993..e86da5d48fc 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -1651,6 +1651,11 @@ public: 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(); } diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index edd2945232c..0b97d761b62 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3906,28 +3906,38 @@ bool Sema::CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *&CastExpr, 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 @@ Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc, TypeTy *Ty, 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)); } diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 65bf9e5c919..469ff72d3fc 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -1018,11 +1018,8 @@ public: 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. |

