Index: include/clang/AST/Expr.h =================================================================== --- include/clang/AST/Expr.h +++ include/clang/AST/Expr.h @@ -2821,7 +2821,6 @@ (op && op->containsUnexpandedParameterPack()))), Op(op) { CastExprBits.Kind = kind; - CastExprBits.PartOfExplicitCast = false; setBasePathSize(BasePathSize); assert(CastConsistency()); } @@ -2836,13 +2835,6 @@ CastKind getCastKind() const { return (CastKind) CastExprBits.Kind; } void setCastKind(CastKind K) { CastExprBits.Kind = K; } - bool getIsPartOfExplicitCast() const { - return CastExprBits.PartOfExplicitCast; - } - void setIsPartOfExplicitCast(bool PartOfExplicitCast) { - CastExprBits.PartOfExplicitCast = PartOfExplicitCast; - } - static const char *getCastKindName(CastKind CK); const char *getCastKindName() const { return getCastKindName(getCastKind()); } @@ -2917,18 +2909,29 @@ private: ImplicitCastExpr(QualType ty, CastKind kind, Expr *op, unsigned BasePathLength, ExprValueKind VK) - : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength) { + : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength) { + CastExprBits.PartOfExplicitCast = false; } /// Construct an empty implicit cast. explicit ImplicitCastExpr(EmptyShell Shell, unsigned PathSize) - : CastExpr(ImplicitCastExprClass, Shell, PathSize) { } + : CastExpr(ImplicitCastExprClass, Shell, PathSize) { + CastExprBits.PartOfExplicitCast = false; + } public: enum OnStack_t { OnStack }; ImplicitCastExpr(OnStack_t _, QualType ty, CastKind kind, Expr *op, ExprValueKind VK) - : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, 0) { + : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, 0) { + CastExprBits.PartOfExplicitCast = false; + } + + bool getIsPartOfExplicitCast() const { + return CastExprBits.PartOfExplicitCast; + } + void setIsPartOfExplicitCast(bool PartOfExplicitCast) { + CastExprBits.PartOfExplicitCast = PartOfExplicitCast; } static ImplicitCastExpr *Create(const ASTContext &Context, QualType T, Index: include/clang/AST/Stmt.h =================================================================== --- include/clang/AST/Stmt.h +++ include/clang/AST/Stmt.h @@ -198,6 +198,7 @@ class CastExprBitfields { friend class CastExpr; + friend class ImplicitCastExpr; unsigned : NumExprBits; Index: lib/AST/ASTDumper.cpp =================================================================== --- lib/AST/ASTDumper.cpp +++ lib/AST/ASTDumper.cpp @@ -521,6 +521,7 @@ // Exprs void VisitExpr(const Expr *Node); void VisitCastExpr(const CastExpr *Node); + void VisitImplicitCastExpr(const ImplicitCastExpr *Node); void VisitDeclRefExpr(const DeclRefExpr *Node); void VisitPredefinedExpr(const PredefinedExpr *Node); void VisitCharacterLiteral(const CharacterLiteral *Node); @@ -2117,7 +2118,10 @@ } dumpBasePath(OS, Node); OS << ">"; +} +void ASTDumper::VisitImplicitCastExpr(const ImplicitCastExpr *Node) { + VisitCastExpr(Node); if (Node->getIsPartOfExplicitCast()) OS << " part_of_explicit_cast"; } Index: lib/Sema/SemaCast.cpp =================================================================== --- lib/Sema/SemaCast.cpp +++ lib/Sema/SemaCast.cpp @@ -94,7 +94,7 @@ // ImplicitCastExpr's as being part of ExplicitCastExpr. The original CE // (which is a ExplicitCastExpr), and the OrigSrcExpr are not touched. while ((CE = dyn_cast(CE->getSubExpr()))) - CE->setIsPartOfExplicitCast(true); + dyn_cast(CE)->setIsPartOfExplicitCast(true); } /// Complete an apparently-successful cast operation that yields Index: lib/Serialization/ASTReaderStmt.cpp =================================================================== --- lib/Serialization/ASTReaderStmt.cpp +++ lib/Serialization/ASTReaderStmt.cpp @@ -723,7 +723,6 @@ assert(NumBaseSpecs == E->path_size()); E->setSubExpr(Record.readSubExpr()); E->setCastKind((CastKind)Record.readInt()); - E->setIsPartOfExplicitCast(Record.readInt()); CastExpr::path_iterator BaseI = E->path_begin(); while (NumBaseSpecs--) { auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier; @@ -770,6 +769,7 @@ void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) { VisitCastExpr(E); + E->setIsPartOfExplicitCast(Record.readInt()); } void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) { Index: lib/Serialization/ASTWriterStmt.cpp =================================================================== --- lib/Serialization/ASTWriterStmt.cpp +++ lib/Serialization/ASTWriterStmt.cpp @@ -665,7 +665,6 @@ Record.push_back(E->path_size()); Record.AddStmt(E->getSubExpr()); Record.push_back(E->getCastKind()); // FIXME: stable encoding - Record.push_back(E->getIsPartOfExplicitCast()); for (CastExpr::path_iterator PI = E->path_begin(), PE = E->path_end(); PI != PE; ++PI) @@ -714,6 +713,7 @@ void ASTStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr *E) { VisitCastExpr(E); + Record.push_back(E->getIsPartOfExplicitCast()); if (E->path_size() == 0) AbbrevToUse = Writer.getExprImplicitCastAbbrev();