|
@@ -57,9 +57,12 @@ class Expr : public Stmt {
|
|
|
|
|
|
protected:
|
|
|
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK,
|
|
|
- bool TD, bool VD, bool ContainsUnexpandedParameterPack) : Stmt(SC) {
|
|
|
+ bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)
|
|
|
+ : Stmt(SC)
|
|
|
+ {
|
|
|
ExprBits.TypeDependent = TD;
|
|
|
ExprBits.ValueDependent = VD;
|
|
|
+ ExprBits.InstantiationDependent = ID;
|
|
|
ExprBits.ValueKind = VK;
|
|
|
ExprBits.ObjectKind = OK;
|
|
|
ExprBits.ContainsUnexpandedParameterPack = ContainsUnexpandedParameterPack;
|
|
@@ -95,7 +98,11 @@ public:
|
|
|
bool isValueDependent() const { return ExprBits.ValueDependent; }
|
|
|
|
|
|
/// \brief Set whether this expression is value-dependent or not.
|
|
|
- void setValueDependent(bool VD) { ExprBits.ValueDependent = VD; }
|
|
|
+ void setValueDependent(bool VD) {
|
|
|
+ ExprBits.ValueDependent = VD;
|
|
|
+ if (VD)
|
|
|
+ ExprBits.InstantiationDependent = true;
|
|
|
+ }
|
|
|
|
|
|
/// isTypeDependent - Determines whether this expression is
|
|
|
/// type-dependent (C++ [temp.dep.expr]), which means that its type
|
|
@@ -111,7 +118,37 @@ public:
|
|
|
bool isTypeDependent() const { return ExprBits.TypeDependent; }
|
|
|
|
|
|
/// \brief Set whether this expression is type-dependent or not.
|
|
|
- void setTypeDependent(bool TD) { ExprBits.TypeDependent = TD; }
|
|
|
+ void setTypeDependent(bool TD) {
|
|
|
+ ExprBits.TypeDependent = TD;
|
|
|
+ if (TD)
|
|
|
+ ExprBits.InstantiationDependent = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// \brief Whether this expression is instantiation-dependent, meaning that
|
|
|
+ /// it depends in some way on a template parameter, even if neither its type
|
|
|
+ /// nor (constant) value can change due to the template instantiation.
|
|
|
+ ///
|
|
|
+ /// In the following example, the expression \c sizeof(sizeof(T() + T())) is
|
|
|
+ /// instantiation-dependent (since it involves a template parameter \c T), but
|
|
|
+ /// is neither type- nor value-dependent, since the type of the inner
|
|
|
+ /// \c sizeof is known (\c std::size_t) and therefore the size of the outer
|
|
|
+ /// \c sizeof is known.
|
|
|
+ ///
|
|
|
+ /// \code
|
|
|
+ /// template<typename T>
|
|
|
+ /// void f(T x, T y) {
|
|
|
+ /// sizeof(sizeof(T() + T());
|
|
|
+ /// }
|
|
|
+ /// \endcode
|
|
|
+ ///
|
|
|
+ bool isInstantiationDependent() const {
|
|
|
+ return ExprBits.InstantiationDependent;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// \brief Set whether this expression is instantiation-dependent or not.
|
|
|
+ void setInstantiationDependent(bool ID) {
|
|
|
+ ExprBits.InstantiationDependent = ID;
|
|
|
+ }
|
|
|
|
|
|
/// \brief Whether this expression contains an unexpanded parameter
|
|
|
/// pack (for C++0x variadic templates).
|
|
@@ -595,7 +632,9 @@ public:
|
|
|
OpaqueValueExpr(SourceLocation Loc, QualType T, ExprValueKind VK,
|
|
|
ExprObjectKind OK = OK_Ordinary)
|
|
|
: Expr(OpaqueValueExprClass, T, VK, OK,
|
|
|
- T->isDependentType(), T->isDependentType(), false),
|
|
|
+ T->isDependentType(), T->isDependentType(),
|
|
|
+ T->isInstantiationDependentType(),
|
|
|
+ false),
|
|
|
SourceExpr(0), Loc(Loc) {
|
|
|
}
|
|
|
|
|
@@ -664,7 +703,8 @@ struct ExplicitTemplateArgumentList {
|
|
|
|
|
|
void initializeFrom(const TemplateArgumentListInfo &List);
|
|
|
void initializeFrom(const TemplateArgumentListInfo &List,
|
|
|
- bool &Dependent, bool &ContainsUnexpandedParameterPack);
|
|
|
+ bool &Dependent, bool &InstantiationDependent,
|
|
|
+ bool &ContainsUnexpandedParameterPack);
|
|
|
void copyInto(TemplateArgumentListInfo &List) const;
|
|
|
static std::size_t sizeFor(unsigned NumTemplateArgs);
|
|
|
static std::size_t sizeFor(const TemplateArgumentListInfo &List);
|
|
@@ -747,7 +787,7 @@ class DeclRefExpr : public Expr {
|
|
|
|
|
|
public:
|
|
|
DeclRefExpr(ValueDecl *D, QualType T, ExprValueKind VK, SourceLocation L)
|
|
|
- : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false),
|
|
|
+ : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false, false),
|
|
|
D(D), Loc(L) {
|
|
|
DeclRefExprBits.HasQualifier = 0;
|
|
|
DeclRefExprBits.HasExplicitTemplateArgs = 0;
|
|
@@ -936,6 +976,7 @@ public:
|
|
|
PredefinedExpr(SourceLocation l, QualType type, IdentType IT)
|
|
|
: Expr(PredefinedExprClass, type, VK_LValue, OK_Ordinary,
|
|
|
type->isDependentType(), type->isDependentType(),
|
|
|
+ type->isInstantiationDependentType(),
|
|
|
/*ContainsUnexpandedParameterPack=*/false),
|
|
|
Loc(l), Type(IT) {}
|
|
|
|
|
@@ -1023,7 +1064,7 @@ public:
|
|
|
IntegerLiteral(ASTContext &C, const llvm::APInt &V,
|
|
|
QualType type, SourceLocation 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) &&
|
|
@@ -1066,7 +1107,7 @@ public:
|
|
|
// type should be IntTy
|
|
|
CharacterLiteral(unsigned value, bool iswide, QualType type, SourceLocation l)
|
|
|
: Expr(CharacterLiteralClass, type, VK_RValue, OK_Ordinary, false, false,
|
|
|
- false),
|
|
|
+ false, false),
|
|
|
Value(value), Loc(l), IsWide(iswide) {
|
|
|
}
|
|
|
|
|
@@ -1101,7 +1142,7 @@ class FloatingLiteral : public Expr {
|
|
|
FloatingLiteral(ASTContext &C, const llvm::APFloat &V, bool isexact,
|
|
|
QualType Type, SourceLocation L)
|
|
|
: Expr(FloatingLiteralClass, Type, VK_RValue, OK_Ordinary, false, false,
|
|
|
- false),
|
|
|
+ false, false),
|
|
|
IsExact(isexact), Loc(L) {
|
|
|
setValue(C, V);
|
|
|
}
|
|
@@ -1152,7 +1193,7 @@ class ImaginaryLiteral : public Expr {
|
|
|
public:
|
|
|
ImaginaryLiteral(Expr *val, QualType Ty)
|
|
|
: Expr(ImaginaryLiteralClass, Ty, VK_RValue, OK_Ordinary, false, false,
|
|
|
- false),
|
|
|
+ false, false),
|
|
|
Val(val) {}
|
|
|
|
|
|
/// \brief Build an empty imaginary literal.
|
|
@@ -1200,7 +1241,8 @@ class StringLiteral : public Expr {
|
|
|
SourceLocation TokLocs[1];
|
|
|
|
|
|
StringLiteral(QualType Ty) :
|
|
|
- Expr(StringLiteralClass, Ty, VK_LValue, OK_Ordinary, false, false, false) {}
|
|
|
+ Expr(StringLiteralClass, Ty, VK_LValue, OK_Ordinary, false, false, false,
|
|
|
+ false) {}
|
|
|
|
|
|
public:
|
|
|
/// This is the "fully general" constructor that allows representation of
|
|
@@ -1287,6 +1329,7 @@ public:
|
|
|
: Expr(ParenExprClass, val->getType(),
|
|
|
val->getValueKind(), val->getObjectKind(),
|
|
|
val->isTypeDependent(), val->isValueDependent(),
|
|
|
+ val->isInstantiationDependent(),
|
|
|
val->containsUnexpandedParameterPack()),
|
|
|
L(l), R(r), Val(val) {}
|
|
|
|
|
@@ -1343,6 +1386,8 @@ public:
|
|
|
: Expr(UnaryOperatorClass, type, VK, OK,
|
|
|
input->isTypeDependent() || type->isDependentType(),
|
|
|
input->isValueDependent(),
|
|
|
+ (input->isInstantiationDependent() ||
|
|
|
+ type->isInstantiationDependentType()),
|
|
|
input->containsUnexpandedParameterPack()),
|
|
|
Opc(opc), Loc(l), Val(input) {}
|
|
|
|
|
@@ -1638,6 +1683,7 @@ public:
|
|
|
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()),
|
|
|
Kind(ExprKind), isType(true), OpLoc(op), RParenLoc(rp) {
|
|
|
Argument.Ty = TInfo;
|
|
@@ -1650,6 +1696,7 @@ public:
|
|
|
false, // Never type-dependent (C++ [temp.dep.expr]p3).
|
|
|
// Value-dependent if the argument is type-dependent.
|
|
|
E->isTypeDependent(),
|
|
|
+ E->isInstantiationDependent(),
|
|
|
E->containsUnexpandedParameterPack()),
|
|
|
Kind(ExprKind), isType(false), OpLoc(op), RParenLoc(rp) {
|
|
|
Argument.Ex = E;
|
|
@@ -1727,6 +1774,8 @@ public:
|
|
|
: Expr(ArraySubscriptExprClass, t, VK, OK,
|
|
|
lhs->isTypeDependent() || rhs->isTypeDependent(),
|
|
|
lhs->isValueDependent() || rhs->isValueDependent(),
|
|
|
+ (lhs->isInstantiationDependent() ||
|
|
|
+ rhs->isInstantiationDependent()),
|
|
|
(lhs->containsUnexpandedParameterPack() ||
|
|
|
rhs->containsUnexpandedParameterPack())),
|
|
|
RBracketLoc(rbracketloc) {
|
|
@@ -1984,7 +2033,9 @@ public:
|
|
|
const DeclarationNameInfo &NameInfo, QualType ty,
|
|
|
ExprValueKind VK, ExprObjectKind OK)
|
|
|
: Expr(MemberExprClass, ty, VK, OK,
|
|
|
- base->isTypeDependent(), base->isValueDependent(),
|
|
|
+ base->isTypeDependent(),
|
|
|
+ base->isValueDependent(),
|
|
|
+ base->isInstantiationDependent(),
|
|
|
base->containsUnexpandedParameterPack()),
|
|
|
Base(base), MemberDecl(memberdecl), MemberLoc(NameInfo.getLoc()),
|
|
|
MemberDNLoc(NameInfo.getInfo()), IsArrow(isarrow),
|
|
@@ -2001,6 +2052,7 @@ public:
|
|
|
ExprValueKind VK, ExprObjectKind OK)
|
|
|
: Expr(MemberExprClass, ty, VK, OK,
|
|
|
base->isTypeDependent(), base->isValueDependent(),
|
|
|
+ base->isInstantiationDependent(),
|
|
|
base->containsUnexpandedParameterPack()),
|
|
|
Base(base), MemberDecl(memberdecl), MemberLoc(l), MemberDNLoc(),
|
|
|
IsArrow(isarrow),
|
|
@@ -2186,6 +2238,8 @@ public:
|
|
|
: Expr(CompoundLiteralExprClass, T, VK, OK_Ordinary,
|
|
|
tinfo->getType()->isDependentType(),
|
|
|
init->isValueDependent(),
|
|
|
+ (init->isInstantiationDependent() ||
|
|
|
+ tinfo->getType()->isInstantiationDependentType()),
|
|
|
init->containsUnexpandedParameterPack()),
|
|
|
LParenLoc(lparenloc), TInfo(tinfo), Init(init), FileScope(fileScope) {}
|
|
|
|
|
@@ -2318,6 +2372,8 @@ protected:
|
|
|
// Cast expressions are value-dependent if the type is
|
|
|
// dependent or if the subexpression is value-dependent.
|
|
|
ty->isDependentType() || (op && op->isValueDependent()),
|
|
|
+ (ty->isInstantiationDependentType() ||
|
|
|
+ (op && op->isInstantiationDependent())),
|
|
|
(ty->containsUnexpandedParameterPack() ||
|
|
|
op->containsUnexpandedParameterPack())),
|
|
|
Op(op) {
|
|
@@ -2551,6 +2607,8 @@ public:
|
|
|
: Expr(BinaryOperatorClass, ResTy, VK, OK,
|
|
|
lhs->isTypeDependent() || rhs->isTypeDependent(),
|
|
|
lhs->isValueDependent() || rhs->isValueDependent(),
|
|
|
+ (lhs->isInstantiationDependent() ||
|
|
|
+ rhs->isInstantiationDependent()),
|
|
|
(lhs->containsUnexpandedParameterPack() ||
|
|
|
rhs->containsUnexpandedParameterPack())),
|
|
|
Opc(opc), OpLoc(opLoc) {
|
|
@@ -2653,6 +2711,8 @@ protected:
|
|
|
: Expr(CompoundAssignOperatorClass, ResTy, VK, OK,
|
|
|
lhs->isTypeDependent() || rhs->isTypeDependent(),
|
|
|
lhs->isValueDependent() || rhs->isValueDependent(),
|
|
|
+ (lhs->isInstantiationDependent() ||
|
|
|
+ rhs->isInstantiationDependent()),
|
|
|
(lhs->containsUnexpandedParameterPack() ||
|
|
|
rhs->containsUnexpandedParameterPack())),
|
|
|
Opc(opc), OpLoc(opLoc) {
|
|
@@ -2713,11 +2773,11 @@ class AbstractConditionalOperator : public Expr {
|
|
|
protected:
|
|
|
AbstractConditionalOperator(StmtClass SC, QualType T,
|
|
|
ExprValueKind VK, ExprObjectKind OK,
|
|
|
- bool TD, bool VD,
|
|
|
+ bool TD, bool VD, bool ID,
|
|
|
bool ContainsUnexpandedParameterPack,
|
|
|
SourceLocation qloc,
|
|
|
SourceLocation cloc)
|
|
|
- : Expr(SC, T, VK, OK, TD, VD, ContainsUnexpandedParameterPack),
|
|
|
+ : Expr(SC, T, VK, OK, TD, VD, ID, ContainsUnexpandedParameterPack),
|
|
|
QuestionLoc(qloc), ColonLoc(cloc) {}
|
|
|
|
|
|
AbstractConditionalOperator(StmtClass SC, EmptyShell Empty)
|
|
@@ -2765,6 +2825,9 @@ public:
|
|
|
(lhs->isTypeDependent() || rhs->isTypeDependent()),
|
|
|
(cond->isValueDependent() || lhs->isValueDependent() ||
|
|
|
rhs->isValueDependent()),
|
|
|
+ (cond->isInstantiationDependent() ||
|
|
|
+ lhs->isInstantiationDependent() ||
|
|
|
+ rhs->isInstantiationDependent()),
|
|
|
(cond->containsUnexpandedParameterPack() ||
|
|
|
lhs->containsUnexpandedParameterPack() ||
|
|
|
rhs->containsUnexpandedParameterPack()),
|
|
@@ -2833,6 +2896,8 @@ public:
|
|
|
: AbstractConditionalOperator(BinaryConditionalOperatorClass, t, VK, OK,
|
|
|
(common->isTypeDependent() || rhs->isTypeDependent()),
|
|
|
(common->isValueDependent() || rhs->isValueDependent()),
|
|
|
+ (common->isInstantiationDependent() ||
|
|
|
+ rhs->isInstantiationDependent()),
|
|
|
(common->containsUnexpandedParameterPack() ||
|
|
|
rhs->containsUnexpandedParameterPack()),
|
|
|
qloc, cloc),
|
|
@@ -2914,7 +2979,8 @@ class AddrLabelExpr : public Expr {
|
|
|
public:
|
|
|
AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelDecl *L,
|
|
|
QualType t)
|
|
|
- : Expr(AddrLabelExprClass, t, VK_RValue, OK_Ordinary, false, false, false),
|
|
|
+ : Expr(AddrLabelExprClass, t, VK_RValue, OK_Ordinary, false, false, false,
|
|
|
+ false),
|
|
|
AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {}
|
|
|
|
|
|
/// \brief Build an empty address of a label expression.
|
|
@@ -2953,10 +3019,12 @@ class StmtExpr : public Expr {
|
|
|
SourceLocation LParenLoc, RParenLoc;
|
|
|
public:
|
|
|
// 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),
|
|
|
+ T->isDependentType(), false, false, false),
|
|
|
SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) { }
|
|
|
|
|
|
/// \brief Build an empty statement expression.
|
|
@@ -3073,6 +3141,9 @@ public:
|
|
|
QualType t, ExprValueKind VK, ExprObjectKind OK,
|
|
|
SourceLocation RP, bool TypeDependent, bool ValueDependent)
|
|
|
: Expr(ChooseExprClass, t, VK, OK, TypeDependent, ValueDependent,
|
|
|
+ (cond->isInstantiationDependent() ||
|
|
|
+ lhs->isInstantiationDependent() ||
|
|
|
+ rhs->isInstantiationDependent()),
|
|
|
(cond->containsUnexpandedParameterPack() ||
|
|
|
lhs->containsUnexpandedParameterPack() ||
|
|
|
rhs->containsUnexpandedParameterPack())),
|
|
@@ -3134,7 +3205,8 @@ class GNUNullExpr : public Expr {
|
|
|
|
|
|
public:
|
|
|
GNUNullExpr(QualType Ty, SourceLocation Loc)
|
|
|
- : Expr(GNUNullExprClass, Ty, VK_RValue, OK_Ordinary, false, false, false),
|
|
|
+ : Expr(GNUNullExprClass, Ty, VK_RValue, OK_Ordinary, false, false, false,
|
|
|
+ false),
|
|
|
TokenLoc(Loc) { }
|
|
|
|
|
|
/// \brief Build an empty GNU __null expression.
|
|
@@ -3166,6 +3238,8 @@ public:
|
|
|
SourceLocation RPLoc, QualType t)
|
|
|
: Expr(VAArgExprClass, t, VK_RValue, OK_Ordinary,
|
|
|
t->isDependentType(), false,
|
|
|
+ (TInfo->getType()->isInstantiationDependentType() ||
|
|
|
+ e->isInstantiationDependent()),
|
|
|
(TInfo->getType()->containsUnexpandedParameterPack() ||
|
|
|
e->containsUnexpandedParameterPack())),
|
|
|
Val(e), TInfo(TInfo),
|
|
@@ -3723,7 +3797,7 @@ class ImplicitValueInitExpr : public Expr {
|
|
|
public:
|
|
|
explicit ImplicitValueInitExpr(QualType ty)
|
|
|
: Expr(ImplicitValueInitExprClass, ty, VK_RValue, OK_Ordinary,
|
|
|
- false, false, false) { }
|
|
|
+ false, false, ty->isInstantiationDependentType(), false) { }
|
|
|
|
|
|
/// \brief Construct an empty implicit value initialization.
|
|
|
explicit ImplicitValueInitExpr(EmptyShell Empty)
|
|
@@ -3924,6 +3998,7 @@ public:
|
|
|
: 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) {}
|
|
|
|
|
@@ -3978,7 +4053,10 @@ protected:
|
|
|
public:
|
|
|
BlockExpr(BlockDecl *BD, QualType ty)
|
|
|
: Expr(BlockExprClass, ty, VK_RValue, OK_Ordinary,
|
|
|
- ty->isDependentType(), false, false),
|
|
|
+ ty->isDependentType(), false,
|
|
|
+ // FIXME: Check for instantiate-dependence in the statement?
|
|
|
+ ty->isInstantiationDependentType(),
|
|
|
+ false),
|
|
|
TheBlock(BD) {}
|
|
|
|
|
|
/// \brief Build an empty block expression.
|
|
@@ -4062,7 +4140,13 @@ public:
|
|
|
AsTypeExpr(Expr* SrcExpr, QualType DstType,
|
|
|
ExprValueKind VK, ExprObjectKind OK,
|
|
|
SourceLocation BuiltinLoc, SourceLocation RParenLoc)
|
|
|
- : Expr(AsTypeExprClass, DstType, VK, OK, false, false, false),
|
|
|
+ : Expr(AsTypeExprClass, DstType, VK, OK,
|
|
|
+ DstType->isDependentType(),
|
|
|
+ DstType->isDependentType() || SrcExpr->isValueDependent(),
|
|
|
+ (DstType->isInstantiationDependentType() ||
|
|
|
+ SrcExpr->isInstantiationDependent()),
|
|
|
+ (DstType->containsUnexpandedParameterPack() ||
|
|
|
+ SrcExpr->containsUnexpandedParameterPack())),
|
|
|
SrcExpr(SrcExpr), DstType(DstType),
|
|
|
BuiltinLoc(BuiltinLoc), RParenLoc(RParenLoc) {}
|
|
|
|