More incremental progress towards not including Expr.h in Sema.h.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112044 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 6143492..120035c 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -191,8 +191,7 @@
/// If there is already an implicit cast, merge into the existing one.
/// The result is of the given category.
void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty,
- CastExpr::CastKind Kind,
- ImplicitCastExpr::ResultCategory Category,
+ CastKind Kind, ExprValueKind VK,
const CXXCastPath *BasePath) {
QualType ExprTy = Context.getCanonicalType(Expr->getType());
QualType TypeTy = Context.getCanonicalType(Ty);
@@ -224,21 +223,18 @@
if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(Expr)) {
if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
ImpCast->setType(Ty);
- ImpCast->setCategory(Category);
+ ImpCast->setValueKind(VK);
return;
}
}
- Expr = ImplicitCastExpr::Create(Context, Ty, Kind, Expr, BasePath, Category);
+ Expr = ImplicitCastExpr::Create(Context, Ty, Kind, Expr, BasePath, VK);
}
-ImplicitCastExpr::ResultCategory Sema::CastCategory(Expr *E) {
+ExprValueKind Sema::CastCategory(Expr *E) {
Expr::Classification Classification = E->Classify(Context);
- return Classification.isRValue() ?
- ImplicitCastExpr::RValue :
- (Classification.isLValue() ?
- ImplicitCastExpr::LValue :
- ImplicitCastExpr::XValue);
+ return Classification.isRValue() ? VK_RValue :
+ (Classification.isLValue() ? VK_LValue : VK_XValue);
}
void Sema::DeleteExpr(ExprTy *E) {
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 7ea96f4..271a02d 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -555,7 +555,7 @@
// 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, Kind, ImplicitCastExpr::RValue, &BasePath);
+ ImpCastExprToType(Arg, ValType, Kind, VK_RValue, &BasePath);
TheCall->setArg(i+1, Arg);
}
@@ -1966,7 +1966,7 @@
switch (E->getStmtClass()) {
case Stmt::ImplicitCastExprClass: {
ImplicitCastExpr *IE = cast<ImplicitCastExpr>(E);
- if (IE->getCategory() == ImplicitCastExpr::LValue) {
+ if (IE->getValueKind() == VK_LValue) {
E = IE->getSubExpr();
continue;
}
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 659c0d1..9b6680f 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -7085,7 +7085,7 @@
CastExpr::CK_IntegralCast,
ECD->getInitExpr(),
/*base paths*/ 0,
- ImplicitCastExpr::RValue));
+ VK_RValue));
if (getLangOptions().CPlusPlus)
// C++ [dcl.enum]p4: Following the closing brace of an
// enum-specifier, each enumerator has the type of its
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 7761ac9..dbf22eb 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -1540,7 +1540,7 @@
BasePath.push_back(BaseSpec);
SemaRef.ImpCastExprToType(CopyCtorArg, ArgTy,
CastExpr::CK_UncheckedDerivedToBase,
- ImplicitCastExpr::LValue, &BasePath);
+ VK_LValue, &BasePath);
InitializationKind InitKind
= InitializationKind::CreateDirect(Constructor->getLocation(),
@@ -4979,25 +4979,25 @@
// appropriately-qualified base type.
Expr *From = OtherRef->Retain();
ImpCastExprToType(From, Context.getQualifiedType(BaseType, OtherQuals),
- CastExpr::CK_UncheckedDerivedToBase,
- ImplicitCastExpr::LValue, &BasePath);
+ CK_UncheckedDerivedToBase,
+ VK_LValue, &BasePath);
// Dereference "this".
- ExprResult To = CreateBuiltinUnaryOp(Loc, UnaryOperator::Deref, This);
+ ExprResult To = CreateBuiltinUnaryOp(Loc, UO_Deref, This);
// Implicitly cast "this" to the appropriately-qualified base type.
Expr *ToE = To.takeAs<Expr>();
ImpCastExprToType(ToE,
Context.getCVRQualifiedType(BaseType,
CopyAssignOperator->getTypeQualifiers()),
- CastExpr::CK_UncheckedDerivedToBase,
- ImplicitCastExpr::LValue, &BasePath);
+ CK_UncheckedDerivedToBase,
+ VK_LValue, &BasePath);
To = Owned(ToE);
// Build the copy.
StmtResult Copy = BuildSingleCopyAssign(*this, Loc, BaseType,
- To.get(), From,
- /*CopyingBaseSubobject=*/true);
+ To.get(), From,
+ /*CopyingBaseSubobject=*/true);
if (Copy.isInvalid()) {
Diag(CurrentLocation, diag::note_member_synthesized_at)
<< CXXCopyAssignment << Context.getTagDeclType(ClassDecl);
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 197c44d..c8e8ecd 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1480,7 +1480,7 @@
SourceRange FromRange = From->getSourceRange();
SourceLocation FromLoc = FromRange.getBegin();
- ImplicitCastExpr::ResultCategory Category = CastCategory(From);
+ ExprValueKind VK = CastCategory(From);
// C++ [class.member.lookup]p8:
// [...] Ambiguities can often be resolved by qualifying a name with its
@@ -1518,8 +1518,8 @@
if (PointerConversions)
QType = Context.getPointerType(QType);
- ImpCastExprToType(From, QType, CastExpr::CK_UncheckedDerivedToBase,
- Category, &BasePath);
+ ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase,
+ VK, &BasePath);
FromType = QType;
FromRecordType = QRecordType;
@@ -1556,7 +1556,7 @@
if (PointerConversions)
UType = Context.getPointerType(UType);
ImpCastExprToType(From, UType, CastExpr::CK_UncheckedDerivedToBase,
- Category, &BasePath);
+ VK, &BasePath);
FromType = UType;
FromRecordType = URecordType;
}
@@ -1573,7 +1573,7 @@
return true;
ImpCastExprToType(From, DestType, CastExpr::CK_UncheckedDerivedToBase,
- Category, &BasePath);
+ VK, &BasePath);
return false;
}
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index afca7dc..6b54e2e 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -1841,7 +1841,7 @@
CXXCastPath BasePath;
if (CheckPointerConversion(From, ToType, Kind, BasePath, IgnoreBaseAccess))
return true;
- ImpCastExprToType(From, ToType, Kind, ImplicitCastExpr::RValue, &BasePath);
+ ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath);
break;
}
@@ -1853,7 +1853,7 @@
return true;
if (CheckExceptionSpecCompatibility(From, ToType))
return true;
- ImpCastExprToType(From, ToType, Kind, ImplicitCastExpr::RValue, &BasePath);
+ ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath);
break;
}
case ICK_Boolean_Conversion: {
@@ -1910,10 +1910,10 @@
case ICK_Qualification: {
// The qualification keeps the category of the inner expression, unless the
// target type isn't a reference.
- ImplicitCastExpr::ResultCategory Category = ToType->isReferenceType() ?
- CastCategory(From) : ImplicitCastExpr::RValue;
+ ExprValueKind VK = ToType->isReferenceType() ?
+ CastCategory(From) : VK_RValue;
ImpCastExprToType(From, ToType.getNonLValueExprType(Context),
- CastExpr::CK_NoOp, Category);
+ CastExpr::CK_NoOp, VK);
if (SCS.DeprecatedStringLiteralToCharPtr)
Diag(From->getLocStart(), diag::warn_deprecated_string_literal_conversion)
@@ -2007,13 +2007,12 @@
}
// Cast LHS to type of use.
QualType UseType = isIndirect ? Context.getPointerType(Class) : Class;
- ImplicitCastExpr::ResultCategory Category =
- isIndirect ? ImplicitCastExpr::RValue : CastCategory(lex);
+ ExprValueKind VK =
+ isIndirect ? VK_RValue : CastCategory(lex);
CXXCastPath BasePath;
BuildBasePathArray(Paths, BasePath);
- ImpCastExprToType(lex, UseType, CastExpr::CK_DerivedToBase, Category,
- &BasePath);
+ ImpCastExprToType(lex, UseType, CK_DerivedToBase, VK, &BasePath);
}
if (isa<CXXScalarValueInitExpr>(rex->IgnoreParens())) {
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 034099e..57a1874 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -2095,12 +2095,12 @@
}
void InitializationSequence::AddDerivedToBaseCastStep(QualType BaseType,
- ImplicitCastExpr::ResultCategory Category) {
+ ExprValueKind VK) {
Step S;
- switch (Category) {
- case ImplicitCastExpr::RValue: S.Kind = SK_CastDerivedToBaseRValue; break;
- case ImplicitCastExpr::XValue: S.Kind = SK_CastDerivedToBaseXValue; break;
- case ImplicitCastExpr::LValue: S.Kind = SK_CastDerivedToBaseLValue; break;
+ switch (VK) {
+ case VK_RValue: S.Kind = SK_CastDerivedToBaseRValue; break;
+ case VK_XValue: S.Kind = SK_CastDerivedToBaseXValue; break;
+ case VK_LValue: S.Kind = SK_CastDerivedToBaseLValue; break;
default: llvm_unreachable("No such category");
}
S.Type = BaseType;
@@ -2134,19 +2134,18 @@
}
void InitializationSequence::AddQualificationConversionStep(QualType Ty,
- ImplicitCastExpr::ResultCategory Category) {
+ ExprValueKind VK) {
Step S;
- switch (Category) {
- case ImplicitCastExpr::RValue:
+ switch (VK) {
+ case VK_RValue:
S.Kind = SK_QualificationConversionRValue;
break;
- case ImplicitCastExpr::XValue:
+ case VK_XValue:
S.Kind = SK_QualificationConversionXValue;
break;
- case ImplicitCastExpr::LValue:
+ case VK_LValue:
S.Kind = SK_QualificationConversionLValue;
break;
- default: llvm_unreachable("No such category");
}
S.Type = Ty;
Steps.push_back(S);
@@ -2409,12 +2408,11 @@
// Determine whether we need to perform derived-to-base or
// cv-qualification adjustments.
- ImplicitCastExpr::ResultCategory Category = ImplicitCastExpr::RValue;
+ ExprValueKind VK = VK_RValue;
if (T2->isLValueReferenceType())
- Category = ImplicitCastExpr::LValue;
+ VK = VK_LValue;
else if (const RValueReferenceType *RRef = T2->getAs<RValueReferenceType>())
- Category = RRef->getPointeeType()->isFunctionType() ?
- ImplicitCastExpr::LValue : ImplicitCastExpr::XValue;
+ VK = RRef->getPointeeType()->isFunctionType() ? VK_LValue : VK_XValue;
bool NewDerivedToBase = false;
bool NewObjCConversion = false;
@@ -2436,14 +2434,14 @@
Sequence.AddDerivedToBaseCastStep(
S.Context.getQualifiedType(T1,
T2.getNonReferenceType().getQualifiers()),
- Category);
+ VK);
else if (NewObjCConversion)
Sequence.AddObjCObjectConversionStep(
S.Context.getQualifiedType(T1,
T2.getNonReferenceType().getQualifiers()));
if (cv1T1.getQualifiers() != T2.getNonReferenceType().getQualifiers())
- Sequence.AddQualificationConversionStep(cv1T1, Category);
+ Sequence.AddQualificationConversionStep(cv1T1, VK);
Sequence.AddReferenceBindingStep(cv1T1, !T2->isReferenceType());
return OR_Success;
@@ -2520,13 +2518,13 @@
if (DerivedToBase)
Sequence.AddDerivedToBaseCastStep(
S.Context.getQualifiedType(T1, T2Quals),
- ImplicitCastExpr::LValue);
+ VK_LValue);
else if (ObjCConversion)
Sequence.AddObjCObjectConversionStep(
S.Context.getQualifiedType(T1, T2Quals));
if (T1Quals != T2Quals)
- Sequence.AddQualificationConversionStep(cv1T1,ImplicitCastExpr::LValue);
+ Sequence.AddQualificationConversionStep(cv1T1, VK_LValue);
bool BindingTemporary = T1Quals.hasConst() && !T1Quals.hasVolatile() &&
(Initializer->getBitField() || Initializer->refersToVectorElement());
Sequence.AddReferenceBindingStep(cv1T1, BindingTemporary);
@@ -2603,16 +2601,14 @@
if (DerivedToBase)
Sequence.AddDerivedToBaseCastStep(
S.Context.getQualifiedType(T1, T2Quals),
- isXValue ? ImplicitCastExpr::XValue
- : ImplicitCastExpr::RValue);
+ isXValue ? VK_XValue : VK_RValue);
else if (ObjCConversion)
Sequence.AddObjCObjectConversionStep(
S.Context.getQualifiedType(T1, T2Quals));
if (T1Quals != T2Quals)
Sequence.AddQualificationConversionStep(cv1T1,
- isXValue ? ImplicitCastExpr::XValue
- : ImplicitCastExpr::RValue);
+ isXValue ? VK_XValue : VK_RValue);
Sequence.AddReferenceBindingStep(cv1T1, /*bindingTemporary=*/!isXValue);
return;
}
@@ -3617,17 +3613,17 @@
cast<CXXRecordDecl>(RecordTy->getDecl()));
}
- ImplicitCastExpr::ResultCategory Category =
+ ExprValueKind VK =
Step->Kind == SK_CastDerivedToBaseLValue ?
- ImplicitCastExpr::LValue :
+ VK_LValue :
(Step->Kind == SK_CastDerivedToBaseXValue ?
- ImplicitCastExpr::XValue :
- ImplicitCastExpr::RValue);
+ VK_XValue :
+ VK_RValue);
CurInit = S.Owned(ImplicitCastExpr::Create(S.Context,
Step->Type,
CastExpr::CK_DerivedToBase,
- (Expr*)CurInit.release(),
- &BasePath, Category));
+ CurInit.get(),
+ &BasePath, VK));
break;
}
@@ -3765,7 +3761,7 @@
CurInit = S.Owned(ImplicitCastExpr::Create(S.Context,
CurInitExpr->getType(),
CastKind, CurInitExpr, 0,
- IsLvalue ? ImplicitCastExpr::LValue : ImplicitCastExpr::RValue));
+ IsLvalue ? VK_LValue : VK_RValue));
if (RequiresCopy)
CurInit = CopyObject(S, Entity.getType().getNonReferenceType(), Entity,
@@ -3778,13 +3774,13 @@
case SK_QualificationConversionXValue:
case SK_QualificationConversionRValue: {
// Perform a qualification conversion; these can never go wrong.
- ImplicitCastExpr::ResultCategory Category =
+ ExprValueKind VK =
Step->Kind == SK_QualificationConversionLValue ?
- ImplicitCastExpr::LValue :
+ VK_LValue :
(Step->Kind == SK_QualificationConversionXValue ?
- ImplicitCastExpr::XValue :
- ImplicitCastExpr::RValue);
- S.ImpCastExprToType(CurInitExpr, Step->Type, CastExpr::CK_NoOp, Category);
+ VK_XValue :
+ VK_RValue);
+ S.ImpCastExprToType(CurInitExpr, Step->Type, CastExpr::CK_NoOp, VK);
CurInit.release();
CurInit = S.Owned(CurInitExpr);
break;
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index bb291bb..0645d97 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -3161,8 +3161,7 @@
if (!Context.hasSameType(From->getType(), DestType))
ImpCastExprToType(From, DestType, CastExpr::CK_NoOp,
- From->getType()->isPointerType() ?
- ImplicitCastExpr::RValue : ImplicitCastExpr::LValue);
+ From->getType()->isPointerType() ? VK_RValue : VK_LValue);
return false;
}
@@ -3848,7 +3847,7 @@
ImplicitCastExpr ConversionFn(ImplicitCastExpr::OnStack,
Context.getPointerType(Conversion->getType()),
CastExpr::CK_FunctionToPointerDecay,
- &ConversionRef, ImplicitCastExpr::RValue);
+ &ConversionRef, VK_RValue);
// Note that it is safe to allocate CallExpr on the stack here because
// there are 0 arguments (i.e., nothing is allocated using ASTContext's
@@ -7790,7 +7789,7 @@
return ImplicitCastExpr::Create(Context, ICE->getType(),
ICE->getCastKind(),
SubExpr, 0,
- ICE->getCategory());
+ ICE->getValueKind());
}
if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(E)) {