diff options
-rw-r--r-- | clang/include/clang/AST/Expr.h | 18 | ||||
-rw-r--r-- | clang/include/clang/AST/ExprCXX.h | 31 | ||||
-rw-r--r-- | clang/lib/AST/ASTImporter.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Frontend/RewriteObjC.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaCXXCast.cpp | 14 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 5 |
7 files changed, 53 insertions, 27 deletions
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 20981f74a4a..c0fb275a9a8 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -1729,7 +1729,9 @@ public: const Expr *getSubExprAsWritten() const { return const_cast<CastExpr *>(this)->getSubExprAsWritten(); } - + + const CXXBaseSpecifierArray& getBasePath() { return BasePath; } + static bool classof(const Stmt *T) { StmtClass SC = T->getStmtClass(); if (SC >= CXXStaticCastExprClass && SC <= CXXFunctionalCastExprClass) @@ -1816,9 +1818,9 @@ class ExplicitCastExpr : public CastExpr { protected: ExplicitCastExpr(StmtClass SC, QualType exprTy, CastKind kind, - Expr *op, TypeSourceInfo *writtenTy) - : CastExpr(SC, exprTy, kind, op, CXXBaseSpecifierArray()), - TInfo(writtenTy) {} + Expr *op, CXXBaseSpecifierArray BasePath, + TypeSourceInfo *writtenTy) + : CastExpr(SC, exprTy, kind, op, BasePath), TInfo(writtenTy) {} /// \brief Construct an empty explicit cast. ExplicitCastExpr(StmtClass SC, EmptyShell Shell) @@ -1854,10 +1856,10 @@ class CStyleCastExpr : public ExplicitCastExpr { SourceLocation RPLoc; // the location of the right paren public: CStyleCastExpr(QualType exprTy, CastKind kind, Expr *op, - TypeSourceInfo *writtenTy, - SourceLocation l, SourceLocation r) : - ExplicitCastExpr(CStyleCastExprClass, exprTy, kind, op, writtenTy), - LPLoc(l), RPLoc(r) {} + CXXBaseSpecifierArray BasePath, TypeSourceInfo *writtenTy, + SourceLocation l, SourceLocation r) + : ExplicitCastExpr(CStyleCastExprClass, exprTy, kind, op, BasePath, + writtenTy), LPLoc(l), RPLoc(r) {} /// \brief Construct an empty C-style explicit cast. explicit CStyleCastExpr(EmptyShell Shell) diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 262d2b4ed92..fe6fdb7c351 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -118,8 +118,9 @@ private: protected: CXXNamedCastExpr(StmtClass SC, QualType ty, CastKind kind, Expr *op, - TypeSourceInfo *writtenTy, SourceLocation l) - : ExplicitCastExpr(SC, ty, kind, op, writtenTy), Loc(l) {} + CXXBaseSpecifierArray BasePath, TypeSourceInfo *writtenTy, + SourceLocation l) + : ExplicitCastExpr(SC, ty, kind, op, BasePath, writtenTy), Loc(l) {} explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell) : ExplicitCastExpr(SC, Shell) { } @@ -155,9 +156,10 @@ public: /// @c static_cast<int>(1.0). class CXXStaticCastExpr : public CXXNamedCastExpr { public: - CXXStaticCastExpr(QualType ty, CastKind kind, Expr *op, - TypeSourceInfo *writtenTy, SourceLocation l) - : CXXNamedCastExpr(CXXStaticCastExprClass, ty, kind, op, writtenTy, l) {} + CXXStaticCastExpr(QualType ty, CastKind kind, Expr *op, + CXXBaseSpecifierArray BasePath, TypeSourceInfo *writtenTy, + SourceLocation l) + : CXXNamedCastExpr(CXXStaticCastExprClass, ty, kind, op, BasePath, writtenTy, l) {} explicit CXXStaticCastExpr(EmptyShell Empty) : CXXNamedCastExpr(CXXStaticCastExprClass, Empty) { } @@ -176,9 +178,11 @@ public: /// @c dynamic_cast<Derived*>(BasePtr). class CXXDynamicCastExpr : public CXXNamedCastExpr { public: - CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op, - TypeSourceInfo *writtenTy, SourceLocation l) - : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, writtenTy, l) {} + CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op, + CXXBaseSpecifierArray BasePath, TypeSourceInfo *writtenTy, + SourceLocation l) + : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, BasePath, + writtenTy, l) {} explicit CXXDynamicCastExpr(EmptyShell Empty) : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty) { } @@ -198,8 +202,9 @@ public: class CXXReinterpretCastExpr : public CXXNamedCastExpr { public: CXXReinterpretCastExpr(QualType ty, CastKind kind, Expr *op, + CXXBaseSpecifierArray BasePath, TypeSourceInfo *writtenTy, SourceLocation l) - : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, kind, op, + : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, kind, op, BasePath, writtenTy, l) {} explicit CXXReinterpretCastExpr(EmptyShell Empty) @@ -220,7 +225,8 @@ class CXXConstCastExpr : public CXXNamedCastExpr { public: CXXConstCastExpr(QualType ty, Expr *op, TypeSourceInfo *writtenTy, SourceLocation l) - : CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op, writtenTy, l) {} + : CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op, + CXXBaseSpecifierArray(), writtenTy, l) {} explicit CXXConstCastExpr(EmptyShell Empty) : CXXNamedCastExpr(CXXConstCastExprClass, Empty) { } @@ -724,9 +730,10 @@ class CXXFunctionalCastExpr : public ExplicitCastExpr { public: CXXFunctionalCastExpr(QualType ty, TypeSourceInfo *writtenTy, SourceLocation tyBeginLoc, CastKind kind, - Expr *castExpr, SourceLocation rParenLoc) + Expr *castExpr, CXXBaseSpecifierArray BasePath, + SourceLocation rParenLoc) : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr, - writtenTy), + BasePath, writtenTy), TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} explicit CXXFunctionalCastExpr(EmptyShell Shell) diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index d9557d3e4c6..2b09575f342 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -2886,6 +2886,7 @@ Expr *ASTNodeImporter::VisitImplicitCastExpr(ImplicitCastExpr *E) { return 0; // FIXME: Initialize the base path. + assert(E->getBasePath().empty() && "FIXME: Must copy base path!"); CXXBaseSpecifierArray BasePath; return new (Importer.getToContext()) ImplicitCastExpr(T, E->getCastKind(), SubExpr, BasePath, @@ -2905,8 +2906,11 @@ Expr *ASTNodeImporter::VisitCStyleCastExpr(CStyleCastExpr *E) { if (!TInfo && E->getTypeInfoAsWritten()) return 0; + // FIXME: Initialize the base path. + assert(E->getBasePath().empty() && "FIXME: Must copy base path!"); + CXXBaseSpecifierArray BasePath; return new (Importer.getToContext()) CStyleCastExpr(T, E->getCastKind(), - SubExpr, TInfo, + SubExpr, BasePath, TInfo, Importer.Import(E->getLParenLoc()), Importer.Import(E->getRParenLoc())); } diff --git a/clang/lib/Frontend/RewriteObjC.cpp b/clang/lib/Frontend/RewriteObjC.cpp index e3d9955387e..5f3b27201f5 100644 --- a/clang/lib/Frontend/RewriteObjC.cpp +++ b/clang/lib/Frontend/RewriteObjC.cpp @@ -444,7 +444,7 @@ namespace { CStyleCastExpr* NoTypeInfoCStyleCastExpr(ASTContext *Ctx, QualType Ty, CastExpr::CastKind Kind, Expr *E) { TypeSourceInfo *TInfo = Ctx->getTrivialTypeSourceInfo(Ty, SourceLocation()); - return new (Ctx) CStyleCastExpr(Ty, Kind, E, TInfo, + return new (Ctx) CStyleCastExpr(Ty, Kind, E, CXXBaseSpecifierArray(), TInfo, SourceLocation(), SourceLocation()); } } diff --git a/clang/lib/Sema/SemaCXXCast.cpp b/clang/lib/Sema/SemaCXXCast.cpp index a6e5570752b..393c84a5d8a 100644 --- a/clang/lib/Sema/SemaCXXCast.cpp +++ b/clang/lib/Sema/SemaCXXCast.cpp @@ -150,26 +150,34 @@ Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, case tok::kw_dynamic_cast: { CastExpr::CastKind Kind = CastExpr::CK_Unknown; + // FIXME: Initialize base path! + CXXBaseSpecifierArray BasePath; if (!TypeDependent) CheckDynamicCast(*this, Ex, DestType, OpRange, DestRange, Kind); return Owned(new (Context)CXXDynamicCastExpr(DestType.getNonReferenceType(), - Kind, Ex, DestTInfo, OpLoc)); + Kind, Ex, BasePath, DestTInfo, + OpLoc)); } case tok::kw_reinterpret_cast: { CastExpr::CastKind Kind = CastExpr::CK_Unknown; + // FIXME: Initialize base path! + CXXBaseSpecifierArray BasePath; if (!TypeDependent) CheckReinterpretCast(*this, Ex, DestType, OpRange, DestRange, Kind); return Owned(new (Context) CXXReinterpretCastExpr( DestType.getNonReferenceType(), - Kind, Ex, DestTInfo, OpLoc)); + Kind, Ex, BasePath, DestTInfo, OpLoc)); } case tok::kw_static_cast: { CastExpr::CastKind Kind = CastExpr::CK_Unknown; + // FIXME: Initialize base path! + CXXBaseSpecifierArray BasePath; if (!TypeDependent) CheckStaticCast(*this, Ex, DestType, OpRange, Kind); return Owned(new (Context) CXXStaticCastExpr(DestType.getNonReferenceType(), - Kind, Ex, DestTInfo, OpLoc)); + Kind, Ex, BasePath, + DestTInfo, OpLoc)); } } diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 683cd39012b..f0b25f90ffa 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3957,13 +3957,15 @@ Sema::BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, Expr *castExpr = static_cast<Expr*>(Op.get()); CastExpr::CastKind Kind = CastExpr::CK_Unknown; + // FIXME: Initialize base path! + CXXBaseSpecifierArray BasePath; if (CheckCastTypes(SourceRange(LParenLoc, RParenLoc), Ty->getType(), castExpr, Kind)) return ExprError(); Op.release(); return Owned(new (Context) CStyleCastExpr(Ty->getType().getNonReferenceType(), - Kind, castExpr, Ty, + Kind, castExpr, BasePath, Ty, LParenLoc, RParenLoc)); } diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index e3ffb24d755..b382236e80d 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -501,6 +501,8 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, // if (NumExprs == 1) { CastExpr::CastKind Kind = CastExpr::CK_Unknown; + // FIXME: Initialize base path! + CXXBaseSpecifierArray BasePath; if (CheckCastTypes(TypeRange, Ty, Exprs[0], Kind, /*FunctionalStyle=*/true)) return ExprError(); @@ -508,7 +510,8 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, return Owned(new (Context) CXXFunctionalCastExpr(Ty.getNonReferenceType(), TInfo, TyBeginLoc, Kind, - Exprs[0], RParenLoc)); + Exprs[0], BasePath, + RParenLoc)); } if (const RecordType *RT = Ty->getAs<RecordType>()) { |