aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-07-31 01:23:52 +0000
committerAnders Carlsson <andersca@mac.com>2009-07-31 01:23:52 +0000
commit3503d041ca8a3535a1c1a30005a6b18ae7aed5db (patch)
tree23dfe3ea8c117f6ddbdf642ea1305153f593d236
parent87a05f1fe8ae14044f182b015b279e0a6f4cbdd1 (diff)
Add CK_DerivedToBase and use it PerformObjectMemberConversion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77652 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Expr.h5
-rw-r--r--lib/Sema/Sema.cpp5
-rw-r--r--lib/Sema/Sema.h4
-rw-r--r--lib/Sema/SemaChecking.cpp6
-rw-r--r--lib/Sema/SemaDeclCXX.cpp6
-rw-r--r--lib/Sema/SemaExpr.cpp3
-rw-r--r--lib/Sema/SemaExprCXX.cpp2
-rw-r--r--lib/Sema/SemaOverload.cpp3
8 files changed, 23 insertions, 11 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 33450866ae..29c2386a2f 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -1167,7 +1167,10 @@ public:
CK_BitCast,
/// CK_NoOp - Used for const_cast.
- CK_NoOp
+ CK_NoOp,
+
+ /// CK_DerivedToBase - Derived to base class casts.
+ CK_DerivedToBase
};
private:
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index f7fce8527a..84d7211555 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -194,7 +194,8 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
/// 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 @@ void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty, bool isLvalue) {
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 fc70090906..989dc76a70 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -2972,7 +2972,9 @@ public:
/// 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 6256872b5e..e217299451 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -348,7 +348,8 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
// 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 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
// 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 b095eb7f0a..eedbdcefc6 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -2727,7 +2727,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
// 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 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
// 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 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
} 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 b311cf7438..9c91eb11cb 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1045,7 +1045,8 @@ Sema::PerformObjectMemberConversion(Expr *&From, NamedDecl *Member) {
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 8ff28405e8..26449c1260 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -875,6 +875,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
// 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 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
// 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 ff3b4efe99..0880d1073d 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -2016,7 +2016,7 @@ Sema::PerformObjectArgumentInitialization(Expr *&From, CXXMethodDecl *Method) {
From->getSourceRange()))
return true;
- ImpCastExprToType(From, DestType, /*isLvalue=*/true);
+ ImpCastExprToType(From, DestType, CastExpr::CK_Unknown, /*isLvalue=*/true);
return false;
}
@@ -4476,6 +4476,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
// 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),