Add CK_DerivedToBase and use it PerformObjectMemberConversion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77652 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index f7fce85..84d7211 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -194,7 +194,8 @@
/// 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);
@@ -217,7 +218,7 @@
ImpCast->setType(Ty);
ImpCast->setLvalueCast(isLvalue);
} else
- Expr = new (Context) ImplicitCastExpr(Ty, CastExpr::CK_Unknown, Expr,
+ Expr = new (Context) ImplicitCastExpr(Ty, Kind, Expr,
isLvalue);
}
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index fc70090..989dc76 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -2972,7 +2972,9 @@
/// 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).
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 6256872..e217299 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -348,7 +348,8 @@
// 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);
}
@@ -376,7 +377,8 @@
// 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);
}
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index b095eb7..eedbdce 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -2727,7 +2727,7 @@
// 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);
}
}
@@ -2786,7 +2786,7 @@
// 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;
@@ -2874,7 +2874,7 @@
} 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;
}
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index b311cf7..9c91eb1 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1045,7 +1045,8 @@
From->getSourceRange().getBegin(),
From->getSourceRange()))
return true;
- ImpCastExprToType(From, DestType, /*isLvalue=*/true);
+ ImpCastExprToType(From, DestType, CastExpr::CK_DerivedToBase,
+ /*isLvalue=*/true);
}
return false;
}
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 8ff2840..26449c1 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -875,6 +875,7 @@
// constructor or conversion operator, and then cope with the standard
// conversions.
ImpCastExprToType(From, ToType.getNonReferenceType(),
+ CastExpr::CK_Unknown,
ToType->isLValueReferenceType());
return false;
@@ -1008,6 +1009,7 @@
// FIXME: Not sure about lvalue vs rvalue here in the presence of rvalue
// references.
ImpCastExprToType(From, ToType.getNonReferenceType(),
+ CastExpr::CK_Unknown,
ToType->isLValueReferenceType());
break;
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index ff3b4ef..0880d10 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -2016,7 +2016,7 @@
From->getSourceRange()))
return true;
- ImpCastExprToType(From, DestType, /*isLvalue=*/true);
+ ImpCastExprToType(From, DestType, CastExpr::CK_Unknown, /*isLvalue=*/true);
return false;
}
@@ -4476,6 +4476,7 @@
// 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),