diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -116,10 +116,10 @@ Expr &operator=(Expr&&) = delete; protected: - Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, - bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack) - : ValueStmt(SC) - { + Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, bool TD, + bool VD, bool ID, bool ContainsUnexpandedParameterPack, + bool ContainsErrors) + : ValueStmt(SC) { ExprBits.TypeDependent = TD; ExprBits.ValueDependent = VD; ExprBits.InstantiationDependent = ID; @@ -127,6 +127,7 @@ ExprBits.ObjectKind = OK; assert(ExprBits.ObjectKind == OK && "truncated kind"); ExprBits.ContainsUnexpandedParameterPack = ContainsUnexpandedParameterPack; + ExprBits.ContainsErrors = ContainsErrors; setType(T); } @@ -176,9 +177,7 @@ bool isTypeDependent() const { return ExprBits.TypeDependent; } /// Set whether this expression is type-dependent or not. - void setTypeDependent(bool TD) { - ExprBits.TypeDependent = TD; - } + void setTypeDependent(bool TD) { ExprBits.TypeDependent = TD; } /// Whether this expression is instantiation-dependent, meaning that /// it depends in some way on a template parameter, even if neither its type @@ -224,6 +223,10 @@ return ExprBits.ContainsUnexpandedParameterPack; } + /// Whether this expression contains subexpressions which had errors, e.g. a + /// TypoExpr. + bool containsErrors() const { return ExprBits.ContainsErrors; } + /// Set the bit that describes whether this expression /// contains an unexpanded parameter pack. void setContainsUnexpandedParameterPack(bool PP = true) { @@ -922,25 +925,26 @@ Stmt *SubExpr; FullExpr(StmtClass SC, Expr *subexpr) - : Expr(SC, subexpr->getType(), - subexpr->getValueKind(), subexpr->getObjectKind(), - subexpr->isTypeDependent(), subexpr->isValueDependent(), - subexpr->isInstantiationDependent(), - subexpr->containsUnexpandedParameterPack()), SubExpr(subexpr) {} - FullExpr(StmtClass SC, EmptyShell Empty) - : Expr(SC, Empty) {} -public: - const Expr *getSubExpr() const { return cast(SubExpr); } - Expr *getSubExpr() { return cast(SubExpr); } + : Expr(SC, subexpr->getType(), subexpr->getValueKind(), + subexpr->getObjectKind(), subexpr->isTypeDependent(), + subexpr->isValueDependent(), subexpr->isInstantiationDependent(), + subexpr->containsUnexpandedParameterPack(), + subexpr->containsErrors()), + SubExpr(subexpr) {} + FullExpr(StmtClass SC, EmptyShell Empty) : Expr(SC, Empty) {} - /// As with any mutator of the AST, be very careful when modifying an - /// existing AST to preserve its invariants. - void setSubExpr(Expr *E) { SubExpr = E; } + public: + const Expr *getSubExpr() const { return cast(SubExpr); } + Expr *getSubExpr() { return cast(SubExpr); } - static bool classof(const Stmt *T) { - return T->getStmtClass() >= firstFullExprConstant && - T->getStmtClass() <= lastFullExprConstant; - } + /// As with any mutator of the AST, be very careful when modifying an + /// existing AST to preserve its invariants. + void setSubExpr(Expr *E) { SubExpr = E; } + + static bool classof(const Stmt *T) { + return T->getStmtClass() >= firstFullExprConstant && + T->getStmtClass() <= lastFullExprConstant; + } }; /// ConstantExpr - An expression that occurs in a constant context and @@ -1048,17 +1052,16 @@ public: OpaqueValueExpr(SourceLocation Loc, QualType T, ExprValueKind VK, - ExprObjectKind OK = OK_Ordinary, - Expr *SourceExpr = nullptr) - : Expr(OpaqueValueExprClass, T, VK, OK, - T->isDependentType() || - (SourceExpr && SourceExpr->isTypeDependent()), - T->isDependentType() || - (SourceExpr && SourceExpr->isValueDependent()), - T->isInstantiationDependentType() || - (SourceExpr && SourceExpr->isInstantiationDependent()), - false), - SourceExpr(SourceExpr) { + ExprObjectKind OK = OK_Ordinary, Expr *SourceExpr = nullptr) + : Expr(OpaqueValueExprClass, T, VK, OK, + T->isDependentType() || + (SourceExpr && SourceExpr->isTypeDependent()), + T->isDependentType() || + (SourceExpr && SourceExpr->isValueDependent()), + T->isInstantiationDependentType() || + (SourceExpr && SourceExpr->isInstantiationDependent()), + false, SourceExpr && SourceExpr->containsErrors()), + SourceExpr(SourceExpr) { setIsUnique(false); OpaqueValueExprBits.Loc = Loc; } @@ -1514,9 +1517,9 @@ // type should be IntTy CharacterLiteral(unsigned value, CharacterKind kind, QualType type, SourceLocation l) - : Expr(CharacterLiteralClass, type, VK_RValue, OK_Ordinary, false, false, - false, false), - Value(value), Loc(l) { + : Expr(CharacterLiteralClass, type, VK_RValue, OK_Ordinary, false, false, + false, false, false), + Value(value), Loc(l) { CharacterLiteralBits.Kind = kind; } @@ -1633,9 +1636,9 @@ Stmt *Val; public: ImaginaryLiteral(Expr *val, QualType Ty) - : Expr(ImaginaryLiteralClass, Ty, VK_RValue, OK_Ordinary, false, false, - false, false), - Val(val) {} + : Expr(ImaginaryLiteralClass, Ty, VK_RValue, OK_Ordinary, false, false, + false, false, false), + Val(val) {} /// Build an empty imaginary literal. explicit ImaginaryLiteral(EmptyShell Empty) @@ -1966,12 +1969,11 @@ Stmt *Val; public: ParenExpr(SourceLocation l, SourceLocation r, Expr *val) - : Expr(ParenExprClass, val->getType(), - val->getValueKind(), val->getObjectKind(), - val->isTypeDependent(), val->isValueDependent(), - val->isInstantiationDependent(), - val->containsUnexpandedParameterPack()), - L(l), R(r), Val(val) {} + : Expr(ParenExprClass, val->getType(), val->getValueKind(), + val->getObjectKind(), val->isTypeDependent(), + val->isValueDependent(), val->isInstantiationDependent(), + val->containsUnexpandedParameterPack(), val->containsErrors()), + L(l), R(r), Val(val) {} /// Construct an empty parenthesized expression. explicit ParenExpr(EmptyShell Empty) @@ -2026,7 +2028,7 @@ input->isValueDependent(), (input->isInstantiationDependent() || type->isInstantiationDependentType()), - input->containsUnexpandedParameterPack()), + input->containsUnexpandedParameterPack(), input->containsErrors()), Val(input) { UnaryOperatorBits.Opc = opc; UnaryOperatorBits.CanOverflow = CanOverflow; @@ -2349,14 +2351,15 @@ public: UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, TypeSourceInfo *TInfo, QualType resultType, SourceLocation op, - SourceLocation rp) : - Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_RValue, OK_Ordinary, - false, // Never type-dependent (C++ [temp.dep.expr]p3). - // Value-dependent if the argument is type-dependent. - TInfo->getType()->isDependentType(), - TInfo->getType()->isInstantiationDependentType(), - TInfo->getType()->containsUnexpandedParameterPack()), - OpLoc(op), RParenLoc(rp) { + SourceLocation rp) + : Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_RValue, OK_Ordinary, + false, // Never type-dependent (C++ [temp.dep.expr]p3). + // Value-dependent if the argument is type-dependent. + TInfo->getType()->isDependentType(), + TInfo->getType()->isInstantiationDependentType(), + TInfo->getType()->containsUnexpandedParameterPack(), + /*ContainsErrors=*/false), + OpLoc(op), RParenLoc(rp) { UnaryExprOrTypeTraitExprBits.Kind = ExprKind; UnaryExprOrTypeTraitExprBits.IsType = true; Argument.Ty = TInfo; @@ -2436,16 +2439,16 @@ bool lhsIsBase() const { return getRHS()->getType()->isIntegerType(); } public: - ArraySubscriptExpr(Expr *lhs, Expr *rhs, QualType t, - ExprValueKind VK, ExprObjectKind OK, - SourceLocation rbracketloc) - : Expr(ArraySubscriptExprClass, t, VK, OK, - lhs->isTypeDependent() || rhs->isTypeDependent(), - lhs->isValueDependent() || rhs->isValueDependent(), - (lhs->isInstantiationDependent() || - rhs->isInstantiationDependent()), - (lhs->containsUnexpandedParameterPack() || - rhs->containsUnexpandedParameterPack())) { + ArraySubscriptExpr(Expr *lhs, Expr *rhs, QualType t, ExprValueKind VK, + ExprObjectKind OK, SourceLocation rbracketloc) + : Expr(ArraySubscriptExprClass, t, VK, OK, + lhs->isTypeDependent() || rhs->isTypeDependent(), + lhs->isValueDependent() || rhs->isValueDependent(), + (lhs->isInstantiationDependent() || + rhs->isInstantiationDependent()), + (lhs->containsUnexpandedParameterPack() || + rhs->containsUnexpandedParameterPack()), + (lhs->containsErrors() || rhs->containsErrors())) { SubExprs[LHS] = lhs; SubExprs[RHS] = rhs; ArraySubscriptExprBits.RBracketLoc = rbracketloc; @@ -3058,13 +3061,12 @@ public: CompoundLiteralExpr(SourceLocation lparenloc, TypeSourceInfo *tinfo, QualType T, ExprValueKind VK, Expr *init, bool fileScope) - : Expr(CompoundLiteralExprClass, T, VK, OK_Ordinary, - tinfo->getType()->isDependentType(), - init->isValueDependent(), - (init->isInstantiationDependent() || - tinfo->getType()->isInstantiationDependentType()), - init->containsUnexpandedParameterPack()), - LParenLoc(lparenloc), TInfoAndScope(tinfo, fileScope), Init(init) {} + : Expr(CompoundLiteralExprClass, T, VK, OK_Ordinary, + tinfo->getType()->isDependentType(), init->isValueDependent(), + (init->isInstantiationDependent() || + tinfo->getType()->isInstantiationDependentType()), + init->containsUnexpandedParameterPack(), init->containsErrors()), + LParenLoc(lparenloc), TInfoAndScope(tinfo, fileScope), Init(init) {} /// Construct an empty compound literal. explicit CompoundLiteralExpr(EmptyShell Empty) @@ -3143,7 +3145,8 @@ // unexpanded pack, even if its target type does. ((SC != ImplicitCastExprClass && ty->containsUnexpandedParameterPack()) || - (op && op->containsUnexpandedParameterPack()))), + (op && op->containsUnexpandedParameterPack())), + (op && op->containsErrors())), Op(op) { CastExprBits.Kind = kind; CastExprBits.PartOfExplicitCast = false; @@ -3409,15 +3412,16 @@ typedef BinaryOperatorKind Opcode; BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, - ExprValueKind VK, ExprObjectKind OK, - SourceLocation opLoc, FPOptions FPFeatures) - : Expr(BinaryOperatorClass, ResTy, VK, OK, - lhs->isTypeDependent() || rhs->isTypeDependent(), - lhs->isValueDependent() || rhs->isValueDependent(), - (lhs->isInstantiationDependent() || - rhs->isInstantiationDependent()), - (lhs->containsUnexpandedParameterPack() || - rhs->containsUnexpandedParameterPack())) { + ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, + FPOptions FPFeatures) + : Expr(BinaryOperatorClass, ResTy, VK, OK, + lhs->isTypeDependent() || rhs->isTypeDependent(), + lhs->isValueDependent() || rhs->isValueDependent(), + (lhs->isInstantiationDependent() || + rhs->isInstantiationDependent()), + (lhs->containsUnexpandedParameterPack() || + rhs->containsUnexpandedParameterPack()), + (lhs->containsErrors() || rhs->containsErrors())) { BinaryOperatorBits.Opc = opc; BinaryOperatorBits.FPFeatures = FPFeatures.getInt(); BinaryOperatorBits.OpLoc = opLoc; @@ -3594,15 +3598,16 @@ protected: BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, - ExprValueKind VK, ExprObjectKind OK, - SourceLocation opLoc, FPOptions FPFeatures, bool dead2) - : Expr(CompoundAssignOperatorClass, ResTy, VK, OK, - lhs->isTypeDependent() || rhs->isTypeDependent(), - lhs->isValueDependent() || rhs->isValueDependent(), - (lhs->isInstantiationDependent() || - rhs->isInstantiationDependent()), - (lhs->containsUnexpandedParameterPack() || - rhs->containsUnexpandedParameterPack())) { + ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, + FPOptions FPFeatures, bool dead2) + : Expr(CompoundAssignOperatorClass, ResTy, VK, OK, + lhs->isTypeDependent() || rhs->isTypeDependent(), + lhs->isValueDependent() || rhs->isValueDependent(), + (lhs->isInstantiationDependent() || + rhs->isInstantiationDependent()), + (lhs->containsUnexpandedParameterPack() || + rhs->containsUnexpandedParameterPack()), + (lhs->containsErrors() || rhs->containsErrors())) { BinaryOperatorBits.Opc = opc; BinaryOperatorBits.FPFeatures = FPFeatures.getInt(); BinaryOperatorBits.OpLoc = opLoc; @@ -3662,14 +3667,14 @@ friend class ASTStmtReader; protected: - AbstractConditionalOperator(StmtClass SC, QualType T, - ExprValueKind VK, ExprObjectKind OK, - bool TD, bool VD, bool ID, + AbstractConditionalOperator(StmtClass SC, QualType T, ExprValueKind VK, + ExprObjectKind OK, bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack, - SourceLocation qloc, + bool ContainsErrors, SourceLocation qloc, SourceLocation cloc) - : Expr(SC, T, VK, OK, TD, VD, ID, ContainsUnexpandedParameterPack), - QuestionLoc(qloc), ColonLoc(cloc) {} + : Expr(SC, T, VK, OK, TD, VD, ID, ContainsUnexpandedParameterPack, + ContainsErrors), + QuestionLoc(qloc), ColonLoc(cloc) {} AbstractConditionalOperator(StmtClass SC, EmptyShell Empty) : Expr(SC, Empty) { } @@ -3706,22 +3711,25 @@ friend class ASTStmtReader; public: ConditionalOperator(Expr *cond, SourceLocation QLoc, Expr *lhs, - SourceLocation CLoc, Expr *rhs, - QualType t, ExprValueKind VK, ExprObjectKind OK) - : AbstractConditionalOperator(ConditionalOperatorClass, t, VK, OK, - // FIXME: the type of the conditional operator doesn't - // depend on the type of the conditional, but the standard - // seems to imply that it could. File a bug! - (lhs->isTypeDependent() || rhs->isTypeDependent()), - (cond->isValueDependent() || lhs->isValueDependent() || - rhs->isValueDependent()), - (cond->isInstantiationDependent() || - lhs->isInstantiationDependent() || - rhs->isInstantiationDependent()), - (cond->containsUnexpandedParameterPack() || - lhs->containsUnexpandedParameterPack() || - rhs->containsUnexpandedParameterPack()), - QLoc, CLoc) { + SourceLocation CLoc, Expr *rhs, QualType t, + ExprValueKind VK, ExprObjectKind OK) + : AbstractConditionalOperator( + ConditionalOperatorClass, t, VK, OK, + // FIXME: the type of the conditional operator doesn't + // depend on the type of the conditional, but the standard + // seems to imply that it could. File a bug! + (lhs->isTypeDependent() || rhs->isTypeDependent()), + (cond->isValueDependent() || lhs->isValueDependent() || + rhs->isValueDependent()), + (cond->isInstantiationDependent() || + lhs->isInstantiationDependent() || + rhs->isInstantiationDependent()), + (cond->containsUnexpandedParameterPack() || + lhs->containsUnexpandedParameterPack() || + rhs->containsUnexpandedParameterPack()), + (cond->containsErrors() || lhs->containsErrors() || + rhs->containsErrors()), + QLoc, CLoc) { SubExprs[COND] = cond; SubExprs[LHS] = lhs; SubExprs[RHS] = rhs; @@ -3789,15 +3797,18 @@ Expr *cond, Expr *lhs, Expr *rhs, SourceLocation qloc, SourceLocation cloc, QualType t, ExprValueKind VK, ExprObjectKind OK) - : AbstractConditionalOperator(BinaryConditionalOperatorClass, t, VK, OK, - (common->isTypeDependent() || rhs->isTypeDependent()), - (common->isValueDependent() || rhs->isValueDependent()), - (common->isInstantiationDependent() || - rhs->isInstantiationDependent()), - (common->containsUnexpandedParameterPack() || - rhs->containsUnexpandedParameterPack()), - qloc, cloc), - OpaqueValue(opaqueValue) { + : AbstractConditionalOperator( + BinaryConditionalOperatorClass, t, VK, OK, + (common->isTypeDependent() || rhs->isTypeDependent()), + (common->isValueDependent() || rhs->isValueDependent()), + (common->isInstantiationDependent() || + rhs->isInstantiationDependent()), + (common->containsUnexpandedParameterPack() || + rhs->containsUnexpandedParameterPack()), + (common->containsErrors() || lhs->containsErrors() || + rhs->containsErrors()), + qloc, cloc), + OpaqueValue(opaqueValue) { SubExprs[COMMON] = common; SubExprs[COND] = cond; SubExprs[LHS] = lhs; @@ -3880,9 +3891,9 @@ public: AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelDecl *L, QualType t) - : Expr(AddrLabelExprClass, t, VK_RValue, OK_Ordinary, false, false, false, - false), - AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {} + : Expr(AddrLabelExprClass, t, VK_RValue, OK_Ordinary, false, false, false, + false, false), + AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {} /// Build an empty address of a label expression. explicit AddrLabelExpr(EmptyShell Empty) @@ -3925,11 +3936,12 @@ // FIXME: Does type-dependence need to be computed differently? // FIXME: Do we need to compute instantiation instantiation-dependence for // statements? (ugh!) - StmtExpr(CompoundStmt *substmt, QualType T, - SourceLocation lp, SourceLocation rp) : - Expr(StmtExprClass, T, VK_RValue, OK_Ordinary, - T->isDependentType(), false, false, false), - SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) { } + // FIXME: Do we need to compute ContainsErrors based on substmt? + StmtExpr(CompoundStmt *substmt, QualType T, SourceLocation lp, + SourceLocation rp) + : Expr(StmtExprClass, T, VK_RValue, OK_Ordinary, T->isDependentType(), + false, false, false, false), + SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) {} /// Build an empty statement expression. explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) { } @@ -4042,17 +4054,19 @@ explicit ConvertVectorExpr(EmptyShell Empty) : Expr(ConvertVectorExprClass, Empty) {} public: - ConvertVectorExpr(Expr* SrcExpr, TypeSourceInfo *TI, QualType DstType, - ExprValueKind VK, ExprObjectKind OK, - SourceLocation BuiltinLoc, SourceLocation RParenLoc) - : Expr(ConvertVectorExprClass, DstType, VK, OK, - DstType->isDependentType(), - DstType->isDependentType() || SrcExpr->isValueDependent(), - (DstType->isInstantiationDependentType() || - SrcExpr->isInstantiationDependent()), - (DstType->containsUnexpandedParameterPack() || - SrcExpr->containsUnexpandedParameterPack())), - SrcExpr(SrcExpr), TInfo(TI), BuiltinLoc(BuiltinLoc), RParenLoc(RParenLoc) {} + ConvertVectorExpr(Expr *SrcExpr, TypeSourceInfo *TI, QualType DstType, + ExprValueKind VK, ExprObjectKind OK, + SourceLocation BuiltinLoc, SourceLocation RParenLoc) + : Expr(ConvertVectorExprClass, DstType, VK, OK, + DstType->isDependentType(), + DstType->isDependentType() || SrcExpr->isValueDependent(), + (DstType->isInstantiationDependentType() || + SrcExpr->isInstantiationDependent()), + (DstType->containsUnexpandedParameterPack() || + SrcExpr->containsUnexpandedParameterPack()), + SrcExpr->containsErrors()), + SrcExpr(SrcExpr), TInfo(TI), BuiltinLoc(BuiltinLoc), + RParenLoc(RParenLoc) {} /// getSrcExpr - Return the Expr to be converted. Expr *getSrcExpr() const { return cast(SrcExpr); } @@ -4100,22 +4114,23 @@ SourceLocation BuiltinLoc, RParenLoc; bool CondIsTrue; public: - ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs, - QualType t, ExprValueKind VK, ExprObjectKind OK, - SourceLocation RP, bool condIsTrue, - bool TypeDependent, bool ValueDependent) - : Expr(ChooseExprClass, t, VK, OK, TypeDependent, ValueDependent, - (cond->isInstantiationDependent() || - lhs->isInstantiationDependent() || - rhs->isInstantiationDependent()), - (cond->containsUnexpandedParameterPack() || - lhs->containsUnexpandedParameterPack() || - rhs->containsUnexpandedParameterPack())), - BuiltinLoc(BLoc), RParenLoc(RP), CondIsTrue(condIsTrue) { - SubExprs[COND] = cond; - SubExprs[LHS] = lhs; - SubExprs[RHS] = rhs; - } + ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs, QualType t, + ExprValueKind VK, ExprObjectKind OK, SourceLocation RP, + bool condIsTrue, bool TypeDependent, bool ValueDependent) + : Expr(ChooseExprClass, t, VK, OK, TypeDependent, ValueDependent, + (cond->isInstantiationDependent() || + lhs->isInstantiationDependent() || + rhs->isInstantiationDependent()), + (cond->containsUnexpandedParameterPack() || + lhs->containsUnexpandedParameterPack() || + rhs->containsUnexpandedParameterPack()), + (cond->containsErrors() || lhs->containsErrors() || + rhs->containsErrors())), + BuiltinLoc(BLoc), RParenLoc(RP), CondIsTrue(condIsTrue) { + SubExprs[COND] = cond; + SubExprs[LHS] = lhs; + SubExprs[RHS] = rhs; + } /// Build an empty __builtin_choose_expr. explicit ChooseExpr(EmptyShell Empty) : Expr(ChooseExprClass, Empty) { } @@ -4180,9 +4195,9 @@ public: GNUNullExpr(QualType Ty, SourceLocation Loc) - : Expr(GNUNullExprClass, Ty, VK_RValue, OK_Ordinary, false, false, false, - false), - TokenLoc(Loc) { } + : Expr(GNUNullExprClass, Ty, VK_RValue, OK_Ordinary, false, false, false, + false, false), + TokenLoc(Loc) {} /// Build an empty GNU __null expression. explicit GNUNullExpr(EmptyShell Empty) : Expr(GNUNullExprClass, Empty) { } @@ -4216,10 +4231,12 @@ VAArgExpr(SourceLocation BLoc, Expr *e, TypeSourceInfo *TInfo, SourceLocation RPLoc, QualType t, bool IsMS) : Expr(VAArgExprClass, t, VK_RValue, OK_Ordinary, t->isDependentType(), - false, (TInfo->getType()->isInstantiationDependentType() || - e->isInstantiationDependent()), + false, + (TInfo->getType()->isInstantiationDependentType() || + e->isInstantiationDependent()), (TInfo->getType()->containsUnexpandedParameterPack() || - e->containsUnexpandedParameterPack())), + e->containsUnexpandedParameterPack()), + e->containsErrors()), Val(e), TInfo(TInfo, IsMS), BuiltinLoc(BLoc), RParenLoc(RPLoc) {} /// Create an empty __builtin_va_arg expression. @@ -4898,8 +4915,8 @@ class NoInitExpr : public Expr { public: explicit NoInitExpr(QualType ty) - : Expr(NoInitExprClass, ty, VK_RValue, OK_Ordinary, - false, false, ty->isInstantiationDependentType(), false) { } + : Expr(NoInitExprClass, ty, VK_RValue, OK_Ordinary, false, false, + ty->isInstantiationDependentType(), false, false) {} explicit NoInitExpr(EmptyShell Empty) : Expr(NoInitExprClass, Empty) { } @@ -4997,7 +5014,8 @@ CommonInit->isValueDependent() || ElementInit->isValueDependent(), T->isInstantiationDependentType(), CommonInit->containsUnexpandedParameterPack() || - ElementInit->containsUnexpandedParameterPack()), + ElementInit->containsUnexpandedParameterPack(), + CommonInit->containsErrors() || ElementInit->containsErrors()), SubExprs{CommonInit, ElementInit} {} /// Get the common subexpression shared by all initializations (the source @@ -5046,8 +5064,8 @@ public: explicit ArrayInitIndexExpr(QualType T) - : Expr(ArrayInitIndexExprClass, T, VK_RValue, OK_Ordinary, - false, false, false, false) {} + : Expr(ArrayInitIndexExprClass, T, VK_RValue, OK_Ordinary, false, false, + false, false, false) {} static bool classof(const Stmt *S) { return S->getStmtClass() == ArrayInitIndexExprClass; @@ -5078,8 +5096,8 @@ class ImplicitValueInitExpr : public Expr { public: explicit ImplicitValueInitExpr(QualType ty) - : Expr(ImplicitValueInitExprClass, ty, VK_RValue, OK_Ordinary, - false, false, ty->isInstantiationDependentType(), false) { } + : Expr(ImplicitValueInitExprClass, ty, VK_RValue, OK_Ordinary, false, + false, ty->isInstantiationDependentType(), false, false) {} /// Construct an empty implicit value initialization. explicit ImplicitValueInitExpr(EmptyShell Empty) @@ -5483,12 +5501,12 @@ public: ExtVectorElementExpr(QualType ty, ExprValueKind VK, Expr *base, IdentifierInfo &accessor, SourceLocation loc) - : Expr(ExtVectorElementExprClass, ty, VK, - (VK == VK_RValue ? OK_Ordinary : OK_VectorComponent), - base->isTypeDependent(), base->isValueDependent(), - base->isInstantiationDependent(), - base->containsUnexpandedParameterPack()), - Base(base), Accessor(&accessor), AccessorLoc(loc) {} + : Expr(ExtVectorElementExprClass, ty, VK, + (VK == VK_RValue ? OK_Ordinary : OK_VectorComponent), + base->isTypeDependent(), base->isValueDependent(), + base->isInstantiationDependent(), + base->containsUnexpandedParameterPack(), base->containsErrors()), + Base(base), Accessor(&accessor), AccessorLoc(loc) {} /// Build an empty vector element expression. explicit ExtVectorElementExpr(EmptyShell Empty) @@ -5542,11 +5560,11 @@ BlockDecl *TheBlock; public: BlockExpr(BlockDecl *BD, QualType ty) - : Expr(BlockExprClass, ty, VK_RValue, OK_Ordinary, - ty->isDependentType(), ty->isDependentType(), - ty->isInstantiationDependentType() || BD->isDependentContext(), - false), - TheBlock(BD) {} + : Expr(BlockExprClass, ty, VK_RValue, OK_Ordinary, ty->isDependentType(), + ty->isDependentType(), + ty->isInstantiationDependentType() || BD->isDependentContext(), + false, false), + TheBlock(BD) {} /// Build an empty block expression. explicit BlockExpr(EmptyShell Empty) : Expr(BlockExprClass, Empty) { } @@ -5596,17 +5614,17 @@ explicit AsTypeExpr(EmptyShell Empty) : Expr(AsTypeExprClass, Empty) {} public: - AsTypeExpr(Expr* SrcExpr, QualType DstType, - ExprValueKind VK, ExprObjectKind OK, - SourceLocation BuiltinLoc, SourceLocation RParenLoc) - : Expr(AsTypeExprClass, DstType, VK, OK, - DstType->isDependentType(), - DstType->isDependentType() || SrcExpr->isValueDependent(), - (DstType->isInstantiationDependentType() || - SrcExpr->isInstantiationDependent()), - (DstType->containsUnexpandedParameterPack() || - SrcExpr->containsUnexpandedParameterPack())), - SrcExpr(SrcExpr), BuiltinLoc(BuiltinLoc), RParenLoc(RParenLoc) {} + AsTypeExpr(Expr *SrcExpr, QualType DstType, ExprValueKind VK, + ExprObjectKind OK, SourceLocation BuiltinLoc, + SourceLocation RParenLoc) + : Expr(AsTypeExprClass, DstType, VK, OK, DstType->isDependentType(), + DstType->isDependentType() || SrcExpr->isValueDependent(), + (DstType->isInstantiationDependentType() || + SrcExpr->isInstantiationDependent()), + (DstType->containsUnexpandedParameterPack() || + SrcExpr->containsUnexpandedParameterPack()), + SrcExpr->containsErrors()), + SrcExpr(SrcExpr), BuiltinLoc(BuiltinLoc), RParenLoc(RParenLoc) {} /// getSrcExpr - Return the Expr to be converted. Expr *getSrcExpr() const { return cast(SrcExpr); } @@ -5929,7 +5947,8 @@ /*isTypeDependent*/ true, /*isValueDependent*/ true, /*isInstantiationDependent*/ true, - /*containsUnexpandedParameterPack*/ false) { + /*containsUnexpandedParameterPack*/ false, + /*containsErrors*/ true) { assert(T->isDependentType() && "TypoExpr given a non-dependent type"); } diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -555,7 +555,7 @@ public: CXXBoolLiteralExpr(bool Val, QualType Ty, SourceLocation Loc) : Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false, - false, false) { + false, false, false) { CXXBoolLiteralExprBits.Value = Val; CXXBoolLiteralExprBits.Loc = Loc; } @@ -593,7 +593,7 @@ public: CXXNullPtrLiteralExpr(QualType Ty, SourceLocation Loc) : Expr(CXXNullPtrLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, - false, false, false) { + false, false, false, false) { CXXNullPtrLiteralExprBits.Loc = Loc; } @@ -635,7 +635,8 @@ : Expr(CXXStdInitializerListExprClass, Ty, VK_RValue, OK_Ordinary, Ty->isDependentType(), SubExpr->isValueDependent(), SubExpr->isInstantiationDependent(), - SubExpr->containsUnexpandedParameterPack()), + SubExpr->containsUnexpandedParameterPack(), + SubExpr->containsErrors()), SubExpr(SubExpr) {} Expr *getSubExpr() { return static_cast(SubExpr); } @@ -684,7 +685,8 @@ // dependent Operand->getType()->isDependentType(), Operand->getType()->isInstantiationDependentType(), - Operand->getType()->containsUnexpandedParameterPack()), + Operand->getType()->containsUnexpandedParameterPack(), + /*containsErrors*/ false), Operand(Operand), Range(R) {} CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R) @@ -695,7 +697,8 @@ // dependent Operand->isTypeDependent() || Operand->isValueDependent(), Operand->isInstantiationDependent(), - Operand->containsUnexpandedParameterPack()), + Operand->containsUnexpandedParameterPack(), + Operand->containsErrors()), Operand(Operand), Range(R) {} CXXTypeidExpr(EmptyShell Empty, bool isExpr) @@ -781,14 +784,13 @@ MSPropertyRefExpr(Expr *baseExpr, MSPropertyDecl *decl, bool isArrow, QualType ty, ExprValueKind VK, - NestedNameSpecifierLoc qualifierLoc, - SourceLocation nameLoc) + NestedNameSpecifierLoc qualifierLoc, SourceLocation nameLoc) : Expr(MSPropertyRefExprClass, ty, VK, OK_Ordinary, /*type-dependent*/ false, baseExpr->isValueDependent(), baseExpr->isInstantiationDependent(), - baseExpr->containsUnexpandedParameterPack()), - BaseExpr(baseExpr), TheDecl(decl), - MemberLoc(nameLoc), IsArrow(isArrow), + baseExpr->containsUnexpandedParameterPack(), + baseExpr->containsErrors()), + BaseExpr(baseExpr), TheDecl(decl), MemberLoc(nameLoc), IsArrow(isArrow), QualifierLoc(qualifierLoc) {} MSPropertyRefExpr(EmptyShell Empty) : Expr(MSPropertyRefExprClass, Empty) {} @@ -859,7 +861,8 @@ ExprObjectKind OK, SourceLocation RBracketLoc) : Expr(MSPropertySubscriptExprClass, Ty, VK, OK, Idx->isTypeDependent(), Idx->isValueDependent(), Idx->isInstantiationDependent(), - Idx->containsUnexpandedParameterPack()), + Idx->containsUnexpandedParameterPack(), + (Base && Base->containsErrors()) || Idx->containsErrors()), RBracketLoc(RBracketLoc) { SubExprs[BASE_EXPR] = Base; SubExprs[IDX_EXPR] = Idx; @@ -918,13 +921,15 @@ : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, false, Operand->getType()->isDependentType(), Operand->getType()->isInstantiationDependentType(), - Operand->getType()->containsUnexpandedParameterPack()), + Operand->getType()->containsUnexpandedParameterPack(), + /*containsErrors*/ false), Operand(Operand), UuidStr(UuidStr), Range(R) {} CXXUuidofExpr(QualType Ty, Expr *Operand, StringRef UuidStr, SourceRange R) : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, false, Operand->isTypeDependent(), Operand->isInstantiationDependent(), - Operand->containsUnexpandedParameterPack()), + Operand->containsUnexpandedParameterPack(), + Operand->containsErrors()), Operand(Operand), UuidStr(UuidStr), Range(R) {} CXXUuidofExpr(EmptyShell Empty, bool isExpr) @@ -1011,7 +1016,8 @@ // member function is dependent (C++ [temp.dep.expr]p2) Ty->isDependentType(), Ty->isDependentType(), Ty->isInstantiationDependentType(), - /*ContainsUnexpandedParameterPack=*/false) { + /*ContainsUnexpandedParameterPack=*/false, + /*ContainsErrors*/ false) { CXXThisExprBits.IsImplicit = IsImplicit; CXXThisExprBits.Loc = L; } @@ -1061,7 +1067,8 @@ bool IsThrownVariableInScope) : Expr(CXXThrowExprClass, Ty, VK_RValue, OK_Ordinary, false, false, Operand && Operand->isInstantiationDependent(), - Operand && Operand->containsUnexpandedParameterPack()), + Operand && Operand->containsUnexpandedParameterPack(), + Operand && Operand->containsErrors()), Operand(Operand) { CXXThrowExprBits.ThrowLoc = Loc; CXXThrowExprBits.IsThrownVariableInScope = IsThrownVariableInScope; @@ -1118,14 +1125,14 @@ DeclContext *UsedContext; CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *Param, - DeclContext *UsedContext) + DeclContext *UsedContext) : Expr(SC, Param->hasUnparsedDefaultArg() ? Param->getType().getNonReferenceType() : Param->getDefaultArg()->getType(), Param->getDefaultArg()->getValueKind(), Param->getDefaultArg()->getObjectKind(), false, false, false, - false), + false, false), Param(Param), UsedContext(UsedContext) { CXXDefaultArgExprBits.Loc = Loc; } @@ -1283,12 +1290,12 @@ CXXTemporary *Temp = nullptr; Stmt *SubExpr = nullptr; - CXXBindTemporaryExpr(CXXTemporary *temp, Expr* SubExpr) - : Expr(CXXBindTemporaryExprClass, SubExpr->getType(), - VK_RValue, OK_Ordinary, SubExpr->isTypeDependent(), - SubExpr->isValueDependent(), - SubExpr->isInstantiationDependent(), - SubExpr->containsUnexpandedParameterPack()), + CXXBindTemporaryExpr(CXXTemporary *temp, Expr *SubExpr) + : Expr(CXXBindTemporaryExprClass, SubExpr->getType(), VK_RValue, + OK_Ordinary, SubExpr->isTypeDependent(), + SubExpr->isValueDependent(), SubExpr->isInstantiationDependent(), + SubExpr->containsUnexpandedParameterPack(), + SubExpr->containsErrors()), Temp(temp), SubExpr(SubExpr) {} public: @@ -1541,7 +1548,7 @@ CXXConstructorDecl *Ctor, bool ConstructsVirtualBase, bool InheritedFromVirtualBase) : Expr(CXXInheritedCtorInitExprClass, T, VK_RValue, OK_Ordinary, false, - false, false, false), + false, false, false, false), Constructor(Ctor), Loc(Loc), ConstructsVirtualBase(ConstructsVirtualBase), InheritedFromVirtualBase(InheritedFromVirtualBase) { @@ -1967,7 +1974,7 @@ SourceLocation RParenLoc) : Expr(CXXScalarValueInitExprClass, Type, VK_RValue, OK_Ordinary, false, false, Type->isInstantiationDependentType(), - Type->containsUnexpandedParameterPack()), + Type->containsUnexpandedParameterPack(), /*containsErrors*/ false), TypeInfo(TypeInfo) { CXXScalarValueInitExprBits.RParenLoc = RParenLoc; } @@ -2277,7 +2284,7 @@ FunctionDecl *OperatorDelete, Expr *Arg, SourceLocation Loc) : Expr(CXXDeleteExprClass, Ty, VK_RValue, OK_Ordinary, false, false, Arg->isInstantiationDependent(), - Arg->containsUnexpandedParameterPack()), + Arg->containsUnexpandedParameterPack(), Arg->containsErrors()), OperatorDelete(OperatorDelete), Argument(Arg) { CXXDeleteExprBits.GlobalDelete = GlobalDelete; CXXDeleteExprBits.ArrayForm = ArrayForm; @@ -2641,15 +2648,16 @@ friend class ASTStmtReader; ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att, - TypeSourceInfo *queried, uint64_t value, - Expr *dimension, SourceLocation rparen, QualType ty) - : Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, - false, queried->getType()->isDependentType(), + TypeSourceInfo *queried, uint64_t value, Expr *dimension, + SourceLocation rparen, QualType ty) + : Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, false, + queried->getType()->isDependentType(), (queried->getType()->isInstantiationDependentType() || (dimension && dimension->isInstantiationDependent())), - queried->getType()->containsUnexpandedParameterPack()), - ATT(att), Value(value), Dimension(dimension), - Loc(loc), RParen(rparen), QueriedType(queried) {} + queried->getType()->containsUnexpandedParameterPack(), + /*ContainsErrors*/ false), + ATT(att), Value(value), Dimension(dimension), Loc(loc), RParen(rparen), + QueriedType(queried) {} explicit ArrayTypeTraitExpr(EmptyShell Empty) : Expr(ArrayTypeTraitExprClass, Empty), ATT(0) {} @@ -2707,15 +2715,14 @@ public: friend class ASTStmtReader; - ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et, - Expr *queried, bool value, - SourceLocation rparen, QualType resultType) + ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et, Expr *queried, + bool value, SourceLocation rparen, QualType resultType) : Expr(ExpressionTraitExprClass, resultType, VK_RValue, OK_Ordinary, false, // Not type-dependent // Value-dependent if the argument is type-dependent. - queried->isTypeDependent(), - queried->isInstantiationDependent(), - queried->containsUnexpandedParameterPack()), + queried->isTypeDependent(), queried->isInstantiationDependent(), + queried->containsUnexpandedParameterPack(), + queried->containsErrors()), ET(et), Value(value), Loc(loc), RParen(rparen), QueriedExpression(queried) {} @@ -3874,7 +3881,8 @@ /*TypeDependent*/ false, /*ValueDependent*/ Val == CT_Dependent, Val == CT_Dependent || Operand->isInstantiationDependent(), - Operand->containsUnexpandedParameterPack()), + Operand->containsUnexpandedParameterPack(), + Operand->containsErrors()), Operand(Operand), Range(Keyword, RParen) { CXXNoexceptExprBits.Value = Val == CT_Cannot; } @@ -3939,7 +3947,8 @@ : Expr(PackExpansionExprClass, T, Pattern->getValueKind(), Pattern->getObjectKind(), /*TypeDependent=*/true, /*ValueDependent=*/true, /*InstantiationDependent=*/true, - /*ContainsUnexpandedParameterPack=*/false), + /*ContainsUnexpandedParameterPack=*/false, + Pattern->containsErrors()), EllipsisLoc(EllipsisLoc), NumExpansions(NumExpansions ? *NumExpansions + 1 : 0), Pattern(Pattern) {} @@ -4029,11 +4038,13 @@ /// the given parameter pack. SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, - Optional Length, ArrayRef PartialArgs) + Optional Length, + ArrayRef PartialArgs) : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary, /*TypeDependent=*/false, /*ValueDependent=*/!Length, /*InstantiationDependent=*/!Length, - /*ContainsUnexpandedParameterPack=*/false), + /*ContainsUnexpandedParameterPack=*/false, + /*ContainsErrors=*/false), OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc), Length(Length ? *Length : PartialArgs.size()), Pack(Pack) { assert((!Length || PartialArgs.empty()) && @@ -4133,7 +4144,8 @@ : Expr(SubstNonTypeTemplateParmExprClass, Ty, ValueKind, OK_Ordinary, Replacement->isTypeDependent(), Replacement->isValueDependent(), Replacement->isInstantiationDependent(), - Replacement->containsUnexpandedParameterPack()), + Replacement->containsUnexpandedParameterPack(), + Replacement->containsErrors()), Param(Param), Replacement(Replacement) { SubstNonTypeTemplateParmExprBits.NameLoc = Loc; } @@ -4347,10 +4359,11 @@ MaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference) : Expr(MaterializeTemporaryExprClass, T, - BoundToLvalueReference? VK_LValue : VK_XValue, OK_Ordinary, + BoundToLvalueReference ? VK_LValue : VK_XValue, OK_Ordinary, Temporary->isTypeDependent(), Temporary->isValueDependent(), Temporary->isInstantiationDependent(), - Temporary->containsUnexpandedParameterPack()), + Temporary->containsUnexpandedParameterPack(), + Temporary->containsErrors()), State(Temporary) {} MaterializeTemporaryExpr(EmptyShell Empty) @@ -4460,7 +4473,8 @@ SourceLocation RParenLoc, Optional NumExpansions) : Expr(CXXFoldExprClass, T, VK_RValue, OK_Ordinary, /*Dependent*/ true, true, true, - /*ContainsUnexpandedParameterPack*/ false), + /*ContainsUnexpandedParameterPack*/ false, + /*ContainsErrors*/ false), LParenLoc(LParenLoc), EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc), NumExpansions(NumExpansions ? *NumExpansions + 1 : 0), Opcode(Opcode) { SubExprs[0] = LHS; @@ -4541,7 +4555,9 @@ : Expr(SC, Resume->getType(), Resume->getValueKind(), Resume->getObjectKind(), Resume->isTypeDependent(), Resume->isValueDependent(), Common->isInstantiationDependent(), - Common->containsUnexpandedParameterPack()), + Common->containsUnexpandedParameterPack(), + Common->containsErrors() || (Ready && Ready->containsErrors()) || + Suspend->containsErrors() || Resume->containsErrors()), KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) { SubExprs[SubExpr::Common] = Common; SubExprs[SubExpr::Ready] = Ready; @@ -4552,7 +4568,8 @@ CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, QualType Ty, Expr *Common) : Expr(SC, Ty, VK_RValue, OK_Ordinary, true, true, true, - Common->containsUnexpandedParameterPack()), + Common->containsUnexpandedParameterPack(), + Common->containsErrors()), KeywordLoc(KeywordLoc) { assert(Common->isTypeDependent() && Ty->isDependentType() && "wrong constructor for non-dependent co_await/co_yield expression"); @@ -4659,7 +4676,7 @@ : Expr(DependentCoawaitExprClass, Ty, VK_RValue, OK_Ordinary, /*TypeDependent*/ true, /*ValueDependent*/ true, /*InstantiationDependent*/ true, - Op->containsUnexpandedParameterPack()), + Op->containsUnexpandedParameterPack(), Op->containsErrors()), KeywordLoc(KeywordLoc) { // NOTE: A co_await expression is dependent on the coroutines promise // type and may be dependent even when the `Op` expression is not. diff --git a/clang/include/clang/AST/ExprObjC.h b/clang/include/clang/AST/ExprObjC.h --- a/clang/include/clang/AST/ExprObjC.h +++ b/clang/include/clang/AST/ExprObjC.h @@ -54,7 +54,7 @@ public: ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L) : Expr(ObjCStringLiteralClass, T, VK_RValue, OK_Ordinary, false, false, - false, false), + false, false, false), String(SL), AtLoc(L) {} explicit ObjCStringLiteral(EmptyShell Empty) : Expr(ObjCStringLiteralClass, Empty) {} @@ -89,7 +89,7 @@ public: ObjCBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : Expr(ObjCBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false, - false, false), + false, false, false), Value(val), Loc(l) {} explicit ObjCBoolLiteralExpr(EmptyShell Empty) : Expr(ObjCBoolLiteralExprClass, Empty) {} @@ -129,12 +129,11 @@ public: friend class ASTStmtReader; - ObjCBoxedExpr(Expr *E, QualType T, ObjCMethodDecl *method, - SourceRange R) + ObjCBoxedExpr(Expr *E, QualType T, ObjCMethodDecl *method, SourceRange R) : Expr(ObjCBoxedExprClass, T, VK_RValue, OK_Ordinary, E->isTypeDependent(), E->isValueDependent(), E->isInstantiationDependent(), - E->containsUnexpandedParameterPack()), + E->containsUnexpandedParameterPack(), E->containsErrors()), SubExpr(E), BoxingMethod(method), Range(R) {} explicit ObjCBoxedExpr(EmptyShell Empty) : Expr(ObjCBoxedExprClass, Empty) {} @@ -409,13 +408,14 @@ SourceLocation AtLoc, RParenLoc; public: - ObjCEncodeExpr(QualType T, TypeSourceInfo *EncodedType, - SourceLocation at, SourceLocation rp) + ObjCEncodeExpr(QualType T, TypeSourceInfo *EncodedType, SourceLocation at, + SourceLocation rp) : Expr(ObjCEncodeExprClass, T, VK_LValue, OK_Ordinary, EncodedType->getType()->isDependentType(), EncodedType->getType()->isDependentType(), EncodedType->getType()->isInstantiationDependentType(), - EncodedType->getType()->containsUnexpandedParameterPack()), + EncodedType->getType()->containsUnexpandedParameterPack(), + /*ContainsErrors*/ false), EncodedType(EncodedType), AtLoc(at), RParenLoc(rp) {} explicit ObjCEncodeExpr(EmptyShell Empty) : Expr(ObjCEncodeExprClass, Empty){} @@ -456,10 +456,10 @@ SourceLocation AtLoc, RParenLoc; public: - ObjCSelectorExpr(QualType T, Selector selInfo, - SourceLocation at, SourceLocation rp) + ObjCSelectorExpr(QualType T, Selector selInfo, SourceLocation at, + SourceLocation rp) : Expr(ObjCSelectorExprClass, T, VK_RValue, OK_Ordinary, false, false, - false, false), + false, false, false), SelName(selInfo), AtLoc(at), RParenLoc(rp) {} explicit ObjCSelectorExpr(EmptyShell Empty) : Expr(ObjCSelectorExprClass, Empty) {} @@ -508,10 +508,10 @@ friend class ASTStmtReader; friend class ASTStmtWriter; - ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol, - SourceLocation at, SourceLocation protoLoc, SourceLocation rp) + ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol, SourceLocation at, + SourceLocation protoLoc, SourceLocation rp) : Expr(ObjCProtocolExprClass, T, VK_RValue, OK_Ordinary, false, false, - false, false), + false, false, false), TheProtocol(protocol), AtLoc(at), ProtoLoc(protoLoc), RParenLoc(rp) {} explicit ObjCProtocolExpr(EmptyShell Empty) : Expr(ObjCProtocolExprClass, Empty) {} @@ -558,15 +558,14 @@ bool IsFreeIvar : 1; public: - ObjCIvarRefExpr(ObjCIvarDecl *d, QualType t, - SourceLocation l, SourceLocation oploc, - Expr *base, - bool arrow = false, bool freeIvar = false) + ObjCIvarRefExpr(ObjCIvarDecl *d, QualType t, SourceLocation l, + SourceLocation oploc, Expr *base, bool arrow = false, + bool freeIvar = false) : Expr(ObjCIvarRefExprClass, t, VK_LValue, d->isBitField() ? OK_BitField : OK_Ordinary, /*TypeDependent=*/false, base->isValueDependent(), base->isInstantiationDependent(), - base->containsUnexpandedParameterPack()), + base->containsUnexpandedParameterPack(), base->containsErrors()), D(d), Base(base), Loc(l), OpLoc(oploc), IsArrow(arrow), IsFreeIvar(freeIvar) {} @@ -645,23 +644,22 @@ llvm::PointerUnion3 Receiver; public: - ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, - ExprValueKind VK, ExprObjectKind OK, - SourceLocation l, Expr *base) + ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK, + ExprObjectKind OK, SourceLocation l, Expr *base) : Expr(ObjCPropertyRefExprClass, t, VK, OK, /*TypeDependent=*/false, base->isValueDependent(), base->isInstantiationDependent(), - base->containsUnexpandedParameterPack()), + base->containsUnexpandedParameterPack(), base->containsErrors()), PropertyOrGetter(PD, false), IdLoc(l), Receiver(base) { assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject)); } - ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, - ExprValueKind VK, ExprObjectKind OK, - SourceLocation l, SourceLocation sl, QualType st) + ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK, + ExprObjectKind OK, SourceLocation l, SourceLocation sl, + QualType st) : Expr(ObjCPropertyRefExprClass, t, VK, OK, /*TypeDependent=*/false, false, st->isInstantiationDependentType(), - st->containsUnexpandedParameterPack()), + st->containsUnexpandedParameterPack(), /*ContainsErrors=*/false), PropertyOrGetter(PD, false), IdLoc(l), ReceiverLoc(sl), Receiver(st.getTypePtr()) { assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject)); @@ -672,7 +670,7 @@ SourceLocation IdLoc, Expr *Base) : Expr(ObjCPropertyRefExprClass, T, VK, OK, false, Base->isValueDependent(), Base->isInstantiationDependent(), - Base->containsUnexpandedParameterPack()), + Base->containsUnexpandedParameterPack(), Base->containsErrors()), PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0), IdLoc(IdLoc), Receiver(Base) { assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject)); @@ -680,9 +678,10 @@ ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, QualType T, ExprValueKind VK, ExprObjectKind OK, - SourceLocation IdLoc, - SourceLocation SuperLoc, QualType SuperTy) - : Expr(ObjCPropertyRefExprClass, T, VK, OK, false, false, false, false), + SourceLocation IdLoc, SourceLocation SuperLoc, + QualType SuperTy) + : Expr(ObjCPropertyRefExprClass, T, VK, OK, false, false, false, false, + false), PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0), IdLoc(IdLoc), ReceiverLoc(SuperLoc), Receiver(SuperTy.getTypePtr()) { assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject)); @@ -690,9 +689,10 @@ ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, QualType T, ExprValueKind VK, ExprObjectKind OK, - SourceLocation IdLoc, - SourceLocation ReceiverLoc, ObjCInterfaceDecl *Receiver) - : Expr(ObjCPropertyRefExprClass, T, VK, OK, false, false, false, false), + SourceLocation IdLoc, SourceLocation ReceiverLoc, + ObjCInterfaceDecl *Receiver) + : Expr(ObjCPropertyRefExprClass, T, VK, OK, false, false, false, false, + false), PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0), IdLoc(IdLoc), ReceiverLoc(ReceiverLoc), Receiver(Receiver) { assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject)); @@ -859,9 +859,8 @@ ObjCMethodDecl *SetAtIndexMethodDecl; public: - ObjCSubscriptRefExpr(Expr *base, Expr *key, QualType T, - ExprValueKind VK, ExprObjectKind OK, - ObjCMethodDecl *getMethod, + ObjCSubscriptRefExpr(Expr *base, Expr *key, QualType T, ExprValueKind VK, + ExprObjectKind OK, ObjCMethodDecl *getMethod, ObjCMethodDecl *setMethod, SourceLocation RB) : Expr(ObjCSubscriptRefExprClass, T, VK, OK, base->isTypeDependent() || key->isTypeDependent(), @@ -869,7 +868,8 @@ (base->isInstantiationDependent() || key->isInstantiationDependent()), (base->containsUnexpandedParameterPack() || - key->containsUnexpandedParameterPack())), + key->containsUnexpandedParameterPack()), + (base->containsErrors() || key->containsErrors())), RBracket(RB), GetAtIndexMethodDecl(getMethod), SetAtIndexMethodDecl(setMethod) { SubExprs[BASE] = base; SubExprs[KEY] = key; @@ -1508,7 +1508,7 @@ : Expr(ObjCIsaExprClass, ty, VK_LValue, OK_Ordinary, /*TypeDependent=*/false, base->isValueDependent(), base->isInstantiationDependent(), - /*ContainsUnexpandedParameterPack=*/false), + /*ContainsUnexpandedParameterPack=*/false, base->containsErrors()), Base(base), IsaMemberLoc(l), OpLoc(oploc), IsArrow(isarrow) {} /// Build an empty expression. @@ -1594,7 +1594,8 @@ : Expr(ObjCIndirectCopyRestoreExprClass, type, VK_LValue, OK_Ordinary, operand->isTypeDependent(), operand->isValueDependent(), operand->isInstantiationDependent(), - operand->containsUnexpandedParameterPack()), + operand->containsUnexpandedParameterPack(), + operand->containsErrors()), Operand(operand) { setShouldCopy(shouldCopy); } @@ -1706,7 +1707,7 @@ ObjCAvailabilityCheckExpr(VersionTuple VersionToCheck, SourceLocation AtLoc, SourceLocation RParen, QualType Ty) : Expr(ObjCAvailabilityCheckExprClass, Ty, VK_RValue, OK_Ordinary, false, - false, false, false), + false, false, false, false), VersionToCheck(VersionToCheck), AtLoc(AtLoc), RParen(RParen) {} explicit ObjCAvailabilityCheckExpr(EmptyShell Shell) diff --git a/clang/include/clang/AST/ExprOpenMP.h b/clang/include/clang/AST/ExprOpenMP.h --- a/clang/include/clang/AST/ExprOpenMP.h +++ b/clang/include/clang/AST/ExprOpenMP.h @@ -64,7 +64,10 @@ (Length && Length->isInstantiationDependent()), Base->containsUnexpandedParameterPack() || (LowerBound && LowerBound->containsUnexpandedParameterPack()) || - (Length && Length->containsUnexpandedParameterPack())), + (Length && Length->containsUnexpandedParameterPack()), + Base->containsErrors() || + (LowerBound && LowerBound->containsErrors()) || + (Length && Length->containsErrors())), ColonLoc(ColonLoc), RBracketLoc(RBracketLoc) { SubExprs[BASE] = Base; SubExprs[LOWER_BOUND] = LowerBound; diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -319,8 +319,9 @@ unsigned ValueDependent : 1; unsigned InstantiationDependent : 1; unsigned ContainsUnexpandedParameterPack : 1; + unsigned ContainsErrors : 1; }; - enum { NumExprBits = NumStmtBits + 9 }; + enum { NumExprBits = NumStmtBits + 10 }; class ConstantExprBitfields { friend class ASTStmtReader; diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -473,7 +473,8 @@ ExprValueKind VK, SourceLocation L, const DeclarationNameLoc &LocInfo, NonOdrUseReason NOUR) - : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false, false), + : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false, false, + false), D(D), DNLoc(LocInfo) { DeclRefExprBits.HasQualifier = false; DeclRefExprBits.HasTemplateKWAndArgsInfo = false; @@ -493,7 +494,8 @@ const DeclarationNameInfo &NameInfo, NamedDecl *FoundD, const TemplateArgumentListInfo *TemplateArgs, QualType T, ExprValueKind VK, NonOdrUseReason NOUR) - : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false, false), + : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false, false, + false), D(D), DNLoc(NameInfo.getInfo()) { DeclRefExprBits.Loc = NameInfo.getLoc(); DeclRefExprBits.HasQualifier = QualifierLoc ? 1 : 0; @@ -524,6 +526,7 @@ assert(!Dependent && "built a DeclRefExpr with dependent template args"); ExprBits.InstantiationDependent |= InstantiationDependent; ExprBits.ContainsUnexpandedParameterPack |= ContainsUnexpandedParameterPack; + // FIXME: compute ExprBits.ContainsErrors } else if (TemplateKWLoc.isValid()) { getTrailingObjects()->initializeFrom( TemplateKWLoc); @@ -605,7 +608,8 @@ : Expr(PredefinedExprClass, FNTy, VK_LValue, OK_Ordinary, FNTy->isDependentType(), FNTy->isDependentType(), FNTy->isInstantiationDependentType(), - /*ContainsUnexpandedParameterPack=*/false) { + /*ContainsUnexpandedParameterPack=*/false, + /*ContainsErrors=*/false) { PredefinedExprBits.Kind = IK; assert((getIdentKind() == IK) && "IdentKind do not fit in PredefinedExprBitfields!"); @@ -906,9 +910,9 @@ IntegerLiteral::IntegerLiteral(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l) - : Expr(IntegerLiteralClass, type, VK_RValue, OK_Ordinary, false, false, - false, false), - Loc(l) { + : Expr(IntegerLiteralClass, type, VK_RValue, OK_Ordinary, false, false, + false, false, false), + Loc(l) { assert(type->isIntegerType() && "Illegal type in IntegerLiteral"); assert(V.getBitWidth() == C.getIntWidth(type) && "Integer type is not the correct size for constant."); @@ -930,7 +934,7 @@ QualType type, SourceLocation l, unsigned Scale) : Expr(FixedPointLiteralClass, type, VK_RValue, OK_Ordinary, false, false, - false, false), + false, false, false), Loc(l), Scale(Scale) { assert(type->isFixedPointType() && "Illegal type in FixedPointLiteral"); assert(V.getBitWidth() == C.getTypeInfo(type).Width && @@ -958,8 +962,9 @@ FloatingLiteral::FloatingLiteral(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L) - : Expr(FloatingLiteralClass, Type, VK_RValue, OK_Ordinary, false, false, - false, false), Loc(L) { + : Expr(FloatingLiteralClass, Type, VK_RValue, OK_Ordinary, false, false, + false, false, false), + Loc(L) { setSemantics(V.getSemantics()); FloatingLiteralBits.IsExact = isexact; setValue(C, V); @@ -1023,7 +1028,7 @@ const SourceLocation *Loc, unsigned NumConcatenated) : Expr(StringLiteralClass, Ty, VK_LValue, OK_Ordinary, false, false, false, - false) { + false, false) { assert(Ctx.getAsConstantArrayType(Ty) && "StringLiteral must be of constant array type!"); unsigned CharByteWidth = mapCharByteWidth(Ctx.getTargetInfo(), Kind); @@ -1332,7 +1337,7 @@ ADLCallKind UsesADL) : Expr(SC, Ty, VK, OK_Ordinary, Fn->isTypeDependent(), Fn->isValueDependent(), Fn->isInstantiationDependent(), - Fn->containsUnexpandedParameterPack()), + Fn->containsUnexpandedParameterPack(), Fn->containsErrors()), RParenLoc(RParenLoc) { NumArgs = std::max(Args.size(), MinNumArgs); unsigned NumPreArgs = PreArgs.size(); @@ -1429,6 +1434,8 @@ ExprBits.InstantiationDependent = true; if (Arg->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + if (Arg->containsErrors()) + ExprBits.ContainsErrors = true; } Decl *Expr::getReferencedDeclOfCallee() { @@ -1560,16 +1567,16 @@ OffsetOfExpr::OffsetOfExpr(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, - ArrayRef comps, ArrayRef exprs, + ArrayRef comps, ArrayRef exprs, SourceLocation RParenLoc) - : Expr(OffsetOfExprClass, type, VK_RValue, OK_Ordinary, - /*TypeDependent=*/false, - /*ValueDependent=*/tsi->getType()->isDependentType(), - tsi->getType()->isInstantiationDependentType(), - tsi->getType()->containsUnexpandedParameterPack()), - OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi), - NumComps(comps.size()), NumExprs(exprs.size()) -{ + : Expr(OffsetOfExprClass, type, VK_RValue, OK_Ordinary, + /*TypeDependent=*/false, + /*ValueDependent=*/tsi->getType()->isDependentType(), + tsi->getType()->isInstantiationDependentType(), + tsi->getType()->containsUnexpandedParameterPack(), + /*ContainsErrors=*/false), + OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi), + NumComps(comps.size()), NumExprs(exprs.size()) { for (unsigned i = 0; i != comps.size(); ++i) { setComponent(i, comps[i]); } @@ -1579,6 +1586,8 @@ ExprBits.ValueDependent = true; if (exprs[i]->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + if (exprs[i]->containsErrors()) + ExprBits.ContainsErrors = true; setIndexExpr(i, exprs[i]); } @@ -1599,7 +1608,7 @@ false, // Never type-dependent (C++ [temp.dep.expr]p3). // Value-dependent if the argument is type-dependent. E->isTypeDependent(), E->isInstantiationDependent(), - E->containsUnexpandedParameterPack()), + E->containsUnexpandedParameterPack(), E->containsErrors()), OpLoc(op), RParenLoc(rp) { UnaryExprOrTypeTraitExprBits.Kind = ExprKind; UnaryExprOrTypeTraitExprBits.IsType = false; @@ -1637,7 +1646,7 @@ NonOdrUseReason NOUR) : Expr(MemberExprClass, T, VK, OK, Base->isTypeDependent(), Base->isValueDependent(), Base->isInstantiationDependent(), - Base->containsUnexpandedParameterPack()), + Base->containsUnexpandedParameterPack(), Base->containsErrors()), Base(Base), MemberDecl(MemberDecl), MemberDNLoc(NameInfo.getInfo()), MemberLoc(NameInfo.getLoc()) { assert(!NameInfo.getName() || @@ -2145,7 +2154,7 @@ SourceLocation BLoc, SourceLocation RParenLoc, DeclContext *ParentContext) : Expr(SourceLocExprClass, getDecayedSourceLocExprType(Ctx, Kind), - VK_RValue, OK_Ordinary, false, false, false, false), + VK_RValue, OK_Ordinary, false, false, false, false, false), BuiltinLoc(BLoc), RParenLoc(RParenLoc), ParentContext(ParentContext) { SourceLocExprBits.Kind = Kind; } @@ -2211,12 +2220,11 @@ } InitListExpr::InitListExpr(const ASTContext &C, SourceLocation lbraceloc, - ArrayRef initExprs, SourceLocation rbraceloc) - : Expr(InitListExprClass, QualType(), VK_RValue, OK_Ordinary, false, false, - false, false), - InitExprs(C, initExprs.size()), - LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(nullptr, true) -{ + ArrayRef initExprs, SourceLocation rbraceloc) + : Expr(InitListExprClass, QualType(), VK_RValue, OK_Ordinary, false, false, + false, false, false), + InitExprs(C, initExprs.size()), LBraceLoc(lbraceloc), + RBraceLoc(rbraceloc), AltForm(nullptr, true) { sawArrayRangeDesignator(false); for (unsigned I = 0; I != initExprs.size(); ++I) { if (initExprs[I]->isTypeDependent()) @@ -2227,6 +2235,8 @@ ExprBits.InstantiationDependent = true; if (initExprs[I]->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + if (initExprs[I]->containsErrors()) + ExprBits.ContainsErrors = true; } InitExprs.insert(C, InitExprs.end(), initExprs.begin(), initExprs.end()); @@ -3981,15 +3991,15 @@ } } -ShuffleVectorExpr::ShuffleVectorExpr(const ASTContext &C, ArrayRef args, +ShuffleVectorExpr::ShuffleVectorExpr(const ASTContext &C, ArrayRef args, QualType Type, SourceLocation BLoc, SourceLocation RP) - : Expr(ShuffleVectorExprClass, Type, VK_RValue, OK_Ordinary, - Type->isDependentType(), Type->isDependentType(), - Type->isInstantiationDependentType(), - Type->containsUnexpandedParameterPack()), - BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size()) -{ + : Expr(ShuffleVectorExprClass, Type, VK_RValue, OK_Ordinary, + Type->isDependentType(), Type->isDependentType(), + Type->isInstantiationDependentType(), + Type->containsUnexpandedParameterPack(), + /*ContainsErrors=*/false), + BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size()) { SubExprs = new (C) Stmt*[args.size()]; for (unsigned i = 0; i != args.size(); i++) { if (args[i]->isTypeDependent()) @@ -4000,6 +4010,8 @@ ExprBits.InstantiationDependent = true; if (args[i]->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + if (args[i]->containsErrors()) + ExprBits.ContainsErrors = true; SubExprs[i] = args[i]; } @@ -4024,13 +4036,15 @@ AssocExprs[ResultIndex]->isTypeDependent(), AssocExprs[ResultIndex]->isValueDependent(), AssocExprs[ResultIndex]->isInstantiationDependent(), - ContainsUnexpandedParameterPack), + ContainsUnexpandedParameterPack, + AssocExprs[ResultIndex]->containsErrors()), NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) { assert(AssocTypes.size() == AssocExprs.size() && "Must have the same number of association expressions" " and TypeSourceInfo!"); assert(ResultIndex < NumAssocs && "ResultIndex is out-of-bounds!"); + // FIXME: update containsErrors() based on other AssocExprs. GenericSelectionExprBits.GenericLoc = GenericLoc; getTrailingObjects()[ControllingIndex] = ControllingExpr; @@ -4049,9 +4063,11 @@ OK_Ordinary, /*isTypeDependent=*/true, /*isValueDependent=*/true, - /*isInstantiationDependent=*/true, ContainsUnexpandedParameterPack), + /*isInstantiationDependent=*/true, ContainsUnexpandedParameterPack, + /*ContainsErrors=*/false), NumAssocs(AssocExprs.size()), ResultIndex(ResultDependentIndex), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) { + // FIXME: update containsErrors() based on AssocExprs. assert(AssocTypes.size() == AssocExprs.size() && "Must have the same number of association expressions" " and TypeSourceInfo!"); @@ -4120,15 +4136,13 @@ llvm::ArrayRef Designators, SourceLocation EqualOrColonLoc, bool GNUSyntax, - ArrayRef IndexExprs, - Expr *Init) - : Expr(DesignatedInitExprClass, Ty, - Init->getValueKind(), Init->getObjectKind(), - Init->isTypeDependent(), Init->isValueDependent(), - Init->isInstantiationDependent(), - Init->containsUnexpandedParameterPack()), - EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax), - NumDesignators(Designators.size()), NumSubExprs(IndexExprs.size() + 1) { + ArrayRef IndexExprs, Expr *Init) + : Expr(DesignatedInitExprClass, Ty, Init->getValueKind(), + Init->getObjectKind(), Init->isTypeDependent(), + Init->isValueDependent(), Init->isInstantiationDependent(), + Init->containsUnexpandedParameterPack(), Init->containsErrors()), + EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax), + NumDesignators(Designators.size()), NumSubExprs(IndexExprs.size() + 1) { this->Designators = new (C) Designator[NumDesignators]; // Record the initializer itself. @@ -4151,6 +4165,9 @@ // Propagate unexpanded parameter packs. if (Index->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + // Proagate error indicator. + if (Index->containsErrors()) + ExprBits.ContainsErrors = true; // Copy the index expressions into permanent storage. *Child++ = IndexExprs[IndexIdx++]; @@ -4171,6 +4188,9 @@ if (Start->containsUnexpandedParameterPack() || End->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + // Proagate error indicator. + if (Start->containsErrors() || End->containsErrors()) + ExprBits.ContainsErrors = true; // Copy the start/end expressions into permanent storage. *Child++ = IndexExprs[IndexIdx++]; @@ -4282,9 +4302,11 @@ } DesignatedInitUpdateExpr::DesignatedInitUpdateExpr(const ASTContext &C, - SourceLocation lBraceLoc, Expr *baseExpr, SourceLocation rBraceLoc) - : Expr(DesignatedInitUpdateExprClass, baseExpr->getType(), VK_RValue, - OK_Ordinary, false, false, false, false) { + SourceLocation lBraceLoc, + Expr *baseExpr, + SourceLocation rBraceLoc) + : Expr(DesignatedInitUpdateExprClass, baseExpr->getType(), VK_RValue, + OK_Ordinary, false, false, false, false, false) { BaseAndUpdaterExprs[0] = baseExpr; InitListExpr *ILE = new (C) InitListExpr(C, lBraceLoc, None, rBraceLoc); @@ -4303,7 +4325,7 @@ ParenListExpr::ParenListExpr(SourceLocation LParenLoc, ArrayRef Exprs, SourceLocation RParenLoc) : Expr(ParenListExprClass, QualType(), VK_RValue, OK_Ordinary, false, false, - false, false), + false, false, false), LParenLoc(LParenLoc), RParenLoc(RParenLoc) { ParenListExprBits.NumExprs = Exprs.size(); @@ -4316,6 +4338,8 @@ ExprBits.InstantiationDependent = true; if (Exprs[I]->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + if (Exprs[I]->containsErrors()) + ExprBits.ContainsErrors = true; getTrailingObjects()[I] = Exprs[I]; } @@ -4392,10 +4416,10 @@ } PseudoObjectExpr::PseudoObjectExpr(QualType type, ExprValueKind VK, - Expr *syntax, ArrayRef semantics, + Expr *syntax, ArrayRef semantics, unsigned resultIndex) - : Expr(PseudoObjectExprClass, type, VK, OK_Ordinary, - /*filled in at end of ctor*/ false, false, false, false) { + : Expr(PseudoObjectExprClass, type, VK, OK_Ordinary, + /*filled in at end of ctor*/ false, false, false, false, false) { PseudoObjectExprBits.NumSubExprs = semantics.size() + 1; PseudoObjectExprBits.ResultIndex = resultIndex + 1; @@ -4411,6 +4435,8 @@ ExprBits.InstantiationDependent = true; if (E->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + if (E->containsErrors()) + ExprBits.ContainsErrors = true; if (isa(E)) assert(cast(E)->getSourceExpr() != nullptr && @@ -4443,12 +4469,11 @@ return const_child_range(&Argument.Ex, &Argument.Ex + 1); } -AtomicExpr::AtomicExpr(SourceLocation BLoc, ArrayRef args, - QualType t, AtomicOp op, SourceLocation RP) - : Expr(AtomicExprClass, t, VK_RValue, OK_Ordinary, - false, false, false, false), - NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op) -{ +AtomicExpr::AtomicExpr(SourceLocation BLoc, ArrayRef args, QualType t, + AtomicOp op, SourceLocation RP) + : Expr(AtomicExprClass, t, VK_RValue, OK_Ordinary, false, false, false, + false, false), + NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op) { assert(args.size() == getNumSubExprs(op) && "wrong number of subexpressions"); for (unsigned i = 0; i != args.size(); i++) { if (args[i]->isTypeDependent()) @@ -4459,6 +4484,8 @@ ExprBits.InstantiationDependent = true; if (args[i]->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + if (args[i]->containsErrors()) + ExprBits.ContainsErrors = true; SubExprs[i] = args[i]; } diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -104,7 +104,7 @@ SourceRange DirectInitRange) : Expr(CXXNewExprClass, Ty, VK_RValue, OK_Ordinary, Ty->isDependentType(), Ty->isDependentType(), Ty->isInstantiationDependentType(), - Ty->containsUnexpandedParameterPack()), + Ty->containsUnexpandedParameterPack(), /*ContainsError*/ false), OperatorNew(OperatorNew), OperatorDelete(OperatorDelete), AllocatedTypeInfo(AllocatedTypeInfo), Range(Range), DirectInitRange(DirectInitRange) { @@ -128,6 +128,8 @@ ExprBits.InstantiationDependent = true; if (SizeExpr->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + if (SizeExpr->containsErrors()) + ExprBits.ContainsErrors = true; } getTrailingObjects()[arraySizeOffset()] = *ArraySize; @@ -138,6 +140,8 @@ ExprBits.InstantiationDependent = true; if (Initializer->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + if (Initializer->containsErrors()) + ExprBits.ContainsErrors = true; getTrailingObjects()[initExprOffset()] = Initializer; } @@ -147,6 +151,8 @@ ExprBits.InstantiationDependent = true; if (PlacementArgs[I]->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + if (PlacementArgs[I]->containsErrors()) + ExprBits.ContainsErrors = true; getTrailingObjects()[placementNewArgsOffset() + I] = PlacementArgs[I]; @@ -254,40 +260,42 @@ Location = Info->getTypeLoc().getLocalSourceRange().getBegin(); } -CXXPseudoDestructorExpr::CXXPseudoDestructorExpr(const ASTContext &Context, - Expr *Base, bool isArrow, SourceLocation OperatorLoc, - NestedNameSpecifierLoc QualifierLoc, TypeSourceInfo *ScopeType, - SourceLocation ColonColonLoc, SourceLocation TildeLoc, - PseudoDestructorTypeStorage DestroyedType) - : Expr(CXXPseudoDestructorExprClass, - Context.BoundMemberTy, - VK_RValue, OK_Ordinary, - /*isTypeDependent=*/(Base->isTypeDependent() || - (DestroyedType.getTypeSourceInfo() && - DestroyedType.getTypeSourceInfo()->getType()->isDependentType())), - /*isValueDependent=*/Base->isValueDependent(), - (Base->isInstantiationDependent() || - (QualifierLoc && - QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent()) || - (ScopeType && - ScopeType->getType()->isInstantiationDependentType()) || - (DestroyedType.getTypeSourceInfo() && - DestroyedType.getTypeSourceInfo()->getType() - ->isInstantiationDependentType())), - // ContainsUnexpandedParameterPack - (Base->containsUnexpandedParameterPack() || - (QualifierLoc && - QualifierLoc.getNestedNameSpecifier() - ->containsUnexpandedParameterPack()) || - (ScopeType && - ScopeType->getType()->containsUnexpandedParameterPack()) || - (DestroyedType.getTypeSourceInfo() && - DestroyedType.getTypeSourceInfo()->getType() - ->containsUnexpandedParameterPack()))), - Base(static_cast(Base)), IsArrow(isArrow), - OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc), - ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc), - DestroyedType(DestroyedType) {} +CXXPseudoDestructorExpr::CXXPseudoDestructorExpr( + const ASTContext &Context, Expr *Base, bool isArrow, + SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, + TypeSourceInfo *ScopeType, SourceLocation ColonColonLoc, + SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType) + : Expr(CXXPseudoDestructorExprClass, Context.BoundMemberTy, VK_RValue, + OK_Ordinary, + /*isTypeDependent=*/ + (Base->isTypeDependent() || + (DestroyedType.getTypeSourceInfo() && + DestroyedType.getTypeSourceInfo()->getType()->isDependentType())), + /*isValueDependent=*/Base->isValueDependent(), + (Base->isInstantiationDependent() || + (QualifierLoc && QualifierLoc.getNestedNameSpecifier() + ->isInstantiationDependent()) || + (ScopeType && + ScopeType->getType()->isInstantiationDependentType()) || + (DestroyedType.getTypeSourceInfo() && + DestroyedType.getTypeSourceInfo() + ->getType() + ->isInstantiationDependentType())), + // ContainsUnexpandedParameterPack + (Base->containsUnexpandedParameterPack() || + (QualifierLoc && QualifierLoc.getNestedNameSpecifier() + ->containsUnexpandedParameterPack()) || + (ScopeType && + ScopeType->getType()->containsUnexpandedParameterPack()) || + (DestroyedType.getTypeSourceInfo() && + DestroyedType.getTypeSourceInfo() + ->getType() + ->containsUnexpandedParameterPack())), + Base->containsErrors()), + Base(static_cast(Base)), IsArrow(isArrow), + OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc), + ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc), + DestroyedType(DestroyedType) {} QualType CXXPseudoDestructorExpr::getDestroyedType() const { if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo()) @@ -386,7 +394,8 @@ (KnownContainsUnexpandedParameterPack || NameInfo.containsUnexpandedParameterPack() || (QualifierLoc && QualifierLoc.getNestedNameSpecifier() - ->containsUnexpandedParameterPack()))), + ->containsUnexpandedParameterPack())), + /*ContainsErrors*/ false), NameInfo(NameInfo), QualifierLoc(QualifierLoc) { unsigned NumResults = End - Begin; OverloadExprBits.NumResults = NumResults; @@ -457,7 +466,8 @@ QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())), (NameInfo.containsUnexpandedParameterPack() || (QualifierLoc && QualifierLoc.getNestedNameSpecifier() - ->containsUnexpandedParameterPack()))), + ->containsUnexpandedParameterPack())), + /*ContainsErrors*/ false), QualifierLoc(QualifierLoc), NameInfo(NameInfo) { DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo = (Args != nullptr) || TemplateKWLoc.isValid(); @@ -913,14 +923,14 @@ return cast(getCalleeDecl())->getLiteralIdentifier(); } -CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &Ctx, SourceLocation Loc, - FieldDecl *Field, QualType Ty, - DeclContext *UsedContext) +CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &Ctx, + SourceLocation Loc, FieldDecl *Field, + QualType Ty, DeclContext *UsedContext) : Expr(CXXDefaultInitExprClass, Ty.getNonLValueExprType(Ctx), - Ty->isLValueReferenceType() ? VK_LValue : Ty->isRValueReferenceType() - ? VK_XValue - : VK_RValue, - /*FIXME*/ OK_Ordinary, false, false, false, false), + Ty->isLValueReferenceType() + ? VK_LValue + : Ty->isRValueReferenceType() ? VK_XValue : VK_RValue, + /*FIXME*/ OK_Ordinary, false, false, false, false, false), Field(Field), UsedContext(UsedContext) { CXXDefaultInitExprBits.Loc = Loc; assert(Field->hasInClassInitializer()); @@ -1023,7 +1033,7 @@ SourceRange ParenOrBraceRange) : Expr(SC, Ty, VK_RValue, OK_Ordinary, Ty->isDependentType(), Ty->isDependentType(), Ty->isInstantiationDependentType(), - Ty->containsUnexpandedParameterPack()), + Ty->containsUnexpandedParameterPack(), /*ContainsErrors*/ false), Constructor(Ctor), ParenOrBraceRange(ParenOrBraceRange), NumArgs(Args.size()) { CXXConstructExprBits.Elidable = Elidable; @@ -1044,6 +1054,8 @@ ExprBits.InstantiationDependent = true; if (Args[I]->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + if (Args[I]->containsErrors()) + ExprBits.ContainsErrors = true; TrailingArgs[I] = Args[I]; } @@ -1101,7 +1113,8 @@ bool ContainsUnexpandedParameterPack) : Expr(LambdaExprClass, T, VK_RValue, OK_Ordinary, T->isDependentType(), T->isDependentType(), T->isDependentType(), - ContainsUnexpandedParameterPack), + ContainsUnexpandedParameterPack, /*ContainsErrors*/ false), + // FIXME: pass ContainsErrors. IntroducerRange(IntroducerRange), CaptureDefaultLoc(CaptureDefaultLoc), NumCaptures(Captures.size()), CaptureDefault(CaptureDefault), ExplicitParams(ExplicitParams), ExplicitResultType(ExplicitResultType), @@ -1282,13 +1295,16 @@ OK_Ordinary, TSI->getType()->isDependentType() || TSI->getType()->getContainedDeducedType(), - true, true, TSI->getType()->containsUnexpandedParameterPack()), + true, true, TSI->getType()->containsUnexpandedParameterPack(), + /*ContainsErrors*/ false), TSI(TSI), LParenLoc(LParenLoc), RParenLoc(RParenLoc) { CXXUnresolvedConstructExprBits.NumArgs = Args.size(); auto **StoredArgs = getTrailingObjects(); for (unsigned I = 0; I != Args.size(); ++I) { if (Args[I]->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + if (Args[I]->containsErrors()) + ExprBits.ContainsErrors = true; StoredArgs[I] = Args[I]; } @@ -1323,7 +1339,8 @@ ((Base && Base->containsUnexpandedParameterPack()) || (QualifierLoc && QualifierLoc.getNestedNameSpecifier() ->containsUnexpandedParameterPack()) || - MemberNameInfo.containsUnexpandedParameterPack())), + MemberNameInfo.containsUnexpandedParameterPack()), + Base && Base->containsErrors()), Base(Base), BaseType(BaseType), QualifierLoc(QualifierLoc), MemberNameInfo(MemberNameInfo) { CXXDependentScopeMemberExprBits.IsArrow = IsArrow; @@ -1533,14 +1550,11 @@ return new (Storage) SizeOfPackExpr(EmptyShell(), NumPartialArgs); } -SubstNonTypeTemplateParmPackExpr:: -SubstNonTypeTemplateParmPackExpr(QualType T, - ExprValueKind ValueKind, - NonTypeTemplateParmDecl *Param, - SourceLocation NameLoc, - const TemplateArgument &ArgPack) +SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr( + QualType T, ExprValueKind ValueKind, NonTypeTemplateParmDecl *Param, + SourceLocation NameLoc, const TemplateArgument &ArgPack) : Expr(SubstNonTypeTemplateParmPackExprClass, T, ValueKind, OK_Ordinary, - true, true, true, true), + true, true, true, true, /*ContainsErrors*/ false), Param(Param), Arguments(ArgPack.pack_begin()), NumArguments(ArgPack.pack_size()), NameLoc(NameLoc) {} @@ -1553,7 +1567,7 @@ unsigned NumParams, VarDecl *const *Params) : Expr(FunctionParmPackExprClass, T, VK_LValue, OK_Ordinary, true, true, - true, true), + true, true, /*ContainsErrors*/ false), ParamPack(ParamPack), NameLoc(NameLoc), NumParameters(NumParams) { if (Params) std::uninitialized_copy(Params, Params + NumParams, @@ -1596,13 +1610,13 @@ TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind, ArrayRef Args, - SourceLocation RParenLoc, - bool Value) + SourceLocation RParenLoc, bool Value) : Expr(TypeTraitExprClass, T, VK_RValue, OK_Ordinary, /*TypeDependent=*/false, /*ValueDependent=*/false, /*InstantiationDependent=*/false, - /*ContainsUnexpandedParameterPack=*/false), + /*ContainsUnexpandedParameterPack=*/false, + /*ContainsErrors=*/false), Loc(Loc), RParenLoc(RParenLoc) { TypeTraitExprBits.Kind = Kind; TypeTraitExprBits.Value = Value; diff --git a/clang/lib/AST/ExprObjC.cpp b/clang/lib/AST/ExprObjC.cpp --- a/clang/lib/AST/ExprObjC.cpp +++ b/clang/lib/AST/ExprObjC.cpp @@ -26,7 +26,7 @@ ObjCArrayLiteral::ObjCArrayLiteral(ArrayRef Elements, QualType T, ObjCMethodDecl *Method, SourceRange SR) : Expr(ObjCArrayLiteralClass, T, VK_RValue, OK_Ordinary, false, false, - false, false), + false, false, /*ContainsErros*/ false), NumElements(Elements.size()), Range(SR), ArrayWithObjectsMethod(Method) { Expr **SaveElements = getElements(); for (unsigned I = 0, N = Elements.size(); I != N; ++I) { @@ -36,6 +36,8 @@ ExprBits.InstantiationDependent = true; if (Elements[I]->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + if (Elements[I]->containsErrors()) + ExprBits.ContainsErrors = true; SaveElements[I] = Elements[I]; } @@ -60,7 +62,7 @@ ObjCMethodDecl *method, SourceRange SR) : Expr(ObjCDictionaryLiteralClass, T, VK_RValue, OK_Ordinary, false, false, - false, false), + false, false, false), NumElements(VK.size()), HasPackExpansions(HasPackExpansions), Range(SR), DictWithObjectsMethod(method) { KeyValuePair *KeyValues = getTrailingObjects(); @@ -77,6 +79,8 @@ (VK[I].Key->containsUnexpandedParameterPack() || VK[I].Value->containsUnexpandedParameterPack())) ExprBits.ContainsUnexpandedParameterPack = true; + if (VK[I].Key->containsErrors() || VK[I].Value->containsErrors()) + ExprBits.ContainsErrors = true; KeyValues[I].Key = VK[I].Key; KeyValues[I].Value = VK[I].Value; @@ -130,7 +134,7 @@ : Expr(ObjCMessageExprClass, T, VK, OK_Ordinary, /*TypeDependent=*/false, /*ValueDependent=*/false, /*InstantiationDependent=*/false, - /*ContainsUnexpandedParameterPack=*/false), + /*ContainsUnexpandedParameterPack=*/false, /*ContainsErrors=*/false), SelectorOrMethod( reinterpret_cast(Method ? Method : Sel.getAsOpaquePtr())), Kind(IsInstanceSuper ? SuperInstance : SuperClass), @@ -150,7 +154,7 @@ SourceLocation RBracLoc, bool isImplicit) : Expr(ObjCMessageExprClass, T, VK, OK_Ordinary, T->isDependentType(), T->isDependentType(), T->isInstantiationDependentType(), - T->containsUnexpandedParameterPack()), + T->containsUnexpandedParameterPack(), /*ContainsErrors*/ false), SelectorOrMethod( reinterpret_cast(Method ? Method : Sel.getAsOpaquePtr())), Kind(Class), HasMethod(Method != nullptr), IsDelegateInitCall(false), @@ -168,7 +172,8 @@ : Expr(ObjCMessageExprClass, T, VK, OK_Ordinary, Receiver->isTypeDependent(), Receiver->isTypeDependent(), Receiver->isInstantiationDependent(), - Receiver->containsUnexpandedParameterPack()), + Receiver->containsUnexpandedParameterPack(), + Receiver->containsErrors()), SelectorOrMethod( reinterpret_cast(Method ? Method : Sel.getAsOpaquePtr())), Kind(Instance), HasMethod(Method != nullptr), IsDelegateInitCall(false), @@ -191,6 +196,8 @@ ExprBits.InstantiationDependent = true; if (Args[I]->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; + if (Args[I]->containsErrors()) + ExprBits.ContainsErrors = true; MyArgs[I] = Args[I]; }