CK_BitCast,
/// CK_NoOp - Used for const_cast.
- CK_NoOp
+ CK_NoOp,
+
+ /// CK_DerivedToBase - Derived to base class casts.
+ CK_DerivedToBase
};
private:
/// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
/// If there is already an implicit cast, merge into the existing one.
/// If isLvalue, the result of the cast is an lvalue.
-void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty, bool isLvalue) {
+void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty,
+ CastExpr::CastKind Kind, bool isLvalue) {
QualType ExprTy = Context.getCanonicalType(Expr->getType());
QualType TypeTy = Context.getCanonicalType(Ty);
ImpCast->setType(Ty);
ImpCast->setLvalueCast(isLvalue);
} else
- Expr = new (Context) ImplicitCastExpr(Ty, CastExpr::CK_Unknown, Expr,
+ Expr = new (Context) ImplicitCastExpr(Ty, Kind, Expr,
isLvalue);
}
/// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
/// cast. If there is already an implicit cast, merge into the existing one.
/// If isLvalue, the result of the cast is an lvalue.
- void ImpCastExprToType(Expr *&Expr, QualType Type, bool isLvalue = false);
+ void ImpCastExprToType(Expr *&Expr, QualType Type,
+ CastExpr::CastKind Kind = CastExpr::CK_Unknown,
+ bool isLvalue = false);
// UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
// functions and arrays to their respective pointers (C99 6.3.2.1).
// If the first type needs to be converted (e.g. void** -> int*), do it now.
if (BuiltinFT->getArgType(0) != FirstArg->getType()) {
- ImpCastExprToType(FirstArg, BuiltinFT->getArgType(0), false);
+ ImpCastExprToType(FirstArg, BuiltinFT->getArgType(0), CastExpr::CK_Unknown,
+ /*isLvalue=*/false);
TheCall->setArg(0, FirstArg);
}
// pass in 42. The 42 gets converted to char. This is even more strange
// for things like 45.123 -> char, etc.
// FIXME: Do this check.
- ImpCastExprToType(Arg, ValType, false);
+ ImpCastExprToType(Arg, ValType, CastExpr::CK_Unknown,
+ /*isLvalue=*/false);
TheCall->setArg(i+1, Arg);
}
// Perform the conversion.
// FIXME: Binding to a subobject of the lvalue is going to require more
// AST annotation than this.
- ImpCastExprToType(Init, T1, /*isLvalue=*/true);
+ ImpCastExprToType(Init, T1, CastExpr::CK_Unknown, /*isLvalue=*/true);
}
}
// Perform the conversion.
// FIXME: Binding to a subobject of the lvalue is going to require more
// AST annotation than this.
- ImpCastExprToType(Init, T1, /*isLvalue=*/true);
+ ImpCastExprToType(Init, T1, CastExpr::CK_Unknown, /*isLvalue=*/true);
}
break;
} else {
// FIXME: Binding to a subobject of the rvalue is going to require more
// AST annotation than this.
- ImpCastExprToType(Init, T1, /*isLvalue=*/false);
+ ImpCastExprToType(Init, T1, CastExpr::CK_Unknown, /*isLvalue=*/false);
}
return false;
}
From->getSourceRange().getBegin(),
From->getSourceRange()))
return true;
- ImpCastExprToType(From, DestType, /*isLvalue=*/true);
+ ImpCastExprToType(From, DestType, CastExpr::CK_DerivedToBase,
+ /*isLvalue=*/true);
}
return false;
}
// constructor or conversion operator, and then cope with the standard
// conversions.
ImpCastExprToType(From, ToType.getNonReferenceType(),
+ CastExpr::CK_Unknown,
ToType->isLValueReferenceType());
return false;
// FIXME: Not sure about lvalue vs rvalue here in the presence of rvalue
// references.
ImpCastExprToType(From, ToType.getNonReferenceType(),
+ CastExpr::CK_Unknown,
ToType->isLValueReferenceType());
break;
From->getSourceRange()))
return true;
- ImpCastExprToType(From, DestType, /*isLvalue=*/true);
+ ImpCastExprToType(From, DestType, CastExpr::CK_Unknown, /*isLvalue=*/true);
return false;
}
// FIXME: Represent the user-defined conversion in the AST!
ImpCastExprToType(Object,
Conv->getConversionType().getNonReferenceType(),
+ CastExpr::CK_Unknown,
Conv->getConversionType()->isLValueReferenceType());
return ActOnCallExpr(S, ExprArg(*this, Object), LParenLoc,
MultiExprArg(*this, (ExprTy**)Args, NumArgs),