@@ -155,7 +155,7 @@ namespace {
155
155
Self.CheckCastAlign (SrcExpr.get (), DestType, OpRange);
156
156
}
157
157
158
- void checkObjCConversion (Sema:: CheckedConversionKind CCK) {
158
+ void checkObjCConversion (CheckedConversionKind CCK) {
159
159
assert (Self.getLangOpts ().allowsNonTrivialObjCLifetimeQualifiers ());
160
160
161
161
Expr *src = SrcExpr.get ();
@@ -248,18 +248,14 @@ static TryCastResult TryStaticMemberPointerUpcast(Sema &Self, ExprResult &SrcExp
248
248
CastKind &Kind,
249
249
CXXCastPath &BasePath);
250
250
251
- static TryCastResult TryStaticImplicitCast (Sema &Self, ExprResult &SrcExpr,
252
- QualType DestType,
253
- Sema::CheckedConversionKind CCK,
254
- SourceRange OpRange,
255
- unsigned &msg, CastKind &Kind,
256
- bool ListInitialization);
251
+ static TryCastResult
252
+ TryStaticImplicitCast (Sema &Self, ExprResult &SrcExpr, QualType DestType,
253
+ CheckedConversionKind CCK, SourceRange OpRange,
254
+ unsigned &msg, CastKind &Kind, bool ListInitialization);
257
255
static TryCastResult TryStaticCast (Sema &Self, ExprResult &SrcExpr,
258
- QualType DestType,
259
- Sema::CheckedConversionKind CCK,
260
- SourceRange OpRange,
261
- unsigned &msg, CastKind &Kind,
262
- CXXCastPath &BasePath,
256
+ QualType DestType, CheckedConversionKind CCK,
257
+ SourceRange OpRange, unsigned &msg,
258
+ CastKind &Kind, CXXCastPath &BasePath,
263
259
bool ListInitialization);
264
260
static TryCastResult TryConstCast (Sema &Self, ExprResult &SrcExpr,
265
261
QualType DestType, bool CStyle,
@@ -1223,7 +1219,7 @@ void CastOperation::CheckReinterpretCast() {
1223
1219
1224
1220
if (isValidCast (tcr)) {
1225
1221
if (Self.getLangOpts ().allowsNonTrivialObjCLifetimeQualifiers ())
1226
- checkObjCConversion (Sema::CCK_OtherCast );
1222
+ checkObjCConversion (CheckedConversionKind::OtherCast );
1227
1223
DiagnoseReinterpretUpDownCast (Self, SrcExpr.get (), DestType, OpRange);
1228
1224
1229
1225
if (unsigned DiagID = checkCastFunctionType (Self, SrcExpr, DestType))
@@ -1274,9 +1270,9 @@ void CastOperation::CheckStaticCast() {
1274
1270
}
1275
1271
1276
1272
unsigned msg = diag::err_bad_cxx_cast_generic;
1277
- TryCastResult tcr
1278
- = TryStaticCast (Self, SrcExpr, DestType, Sema::CCK_OtherCast, OpRange, msg ,
1279
- Kind, BasePath, /* ListInitialization=*/ false );
1273
+ TryCastResult tcr =
1274
+ TryStaticCast (Self, SrcExpr, DestType, CheckedConversionKind::OtherCast ,
1275
+ OpRange, msg, Kind, BasePath, /* ListInitialization=*/ false );
1280
1276
if (tcr != TC_Success && msg != 0 ) {
1281
1277
if (SrcExpr.isInvalid ())
1282
1278
return ;
@@ -1296,7 +1292,7 @@ void CastOperation::CheckStaticCast() {
1296
1292
if (Kind == CK_BitCast)
1297
1293
checkCastAlign ();
1298
1294
if (Self.getLangOpts ().allowsNonTrivialObjCLifetimeQualifiers ())
1299
- checkObjCConversion (Sema::CCK_OtherCast );
1295
+ checkObjCConversion (CheckedConversionKind::OtherCast );
1300
1296
} else {
1301
1297
SrcExpr = ExprError ();
1302
1298
}
@@ -1317,14 +1313,13 @@ static bool IsAddressSpaceConversion(QualType SrcType, QualType DestType) {
1317
1313
// / possible. If @p CStyle, ignore access restrictions on hierarchy casting
1318
1314
// / and casting away constness.
1319
1315
static TryCastResult TryStaticCast (Sema &Self, ExprResult &SrcExpr,
1320
- QualType DestType,
1321
- Sema::CheckedConversionKind CCK,
1316
+ QualType DestType, CheckedConversionKind CCK,
1322
1317
SourceRange OpRange, unsigned &msg,
1323
1318
CastKind &Kind, CXXCastPath &BasePath,
1324
1319
bool ListInitialization) {
1325
1320
// Determine whether we have the semantics of a C-style cast.
1326
- bool CStyle
1327
- = (CCK == Sema::CCK_CStyleCast || CCK == Sema::CCK_FunctionalCast );
1321
+ bool CStyle = (CCK == CheckedConversionKind::CStyleCast ||
1322
+ CCK == CheckedConversionKind::FunctionalCast );
1328
1323
1329
1324
// The order the tests is not entirely arbitrary. There is one conversion
1330
1325
// that can be handled in two different ways. Given:
@@ -1884,11 +1879,11 @@ TryStaticMemberPointerUpcast(Sema &Self, ExprResult &SrcExpr, QualType SrcType,
1884
1879
// /
1885
1880
// / An expression e can be explicitly converted to a type T using a
1886
1881
// / @c static_cast if the declaration "T t(e);" is well-formed [...].
1887
- TryCastResult
1888
- TryStaticImplicitCast (Sema &Self, ExprResult &SrcExpr, QualType DestType,
1889
- Sema:: CheckedConversionKind CCK,
1890
- SourceRange OpRange, unsigned &msg,
1891
- CastKind &Kind, bool ListInitialization) {
1882
+ TryCastResult TryStaticImplicitCast (Sema &Self, ExprResult &SrcExpr,
1883
+ QualType DestType,
1884
+ CheckedConversionKind CCK,
1885
+ SourceRange OpRange, unsigned &msg,
1886
+ CastKind &Kind, bool ListInitialization) {
1892
1887
if (DestType->isRecordType ()) {
1893
1888
if (Self.RequireCompleteType (OpRange.getBegin (), DestType,
1894
1889
diag::err_bad_cast_incomplete) ||
@@ -1900,13 +1895,14 @@ TryStaticImplicitCast(Sema &Self, ExprResult &SrcExpr, QualType DestType,
1900
1895
}
1901
1896
1902
1897
InitializedEntity Entity = InitializedEntity::InitializeTemporary (DestType);
1903
- InitializationKind InitKind
1904
- = (CCK == Sema::CCK_CStyleCast)
1905
- ? InitializationKind::CreateCStyleCast (OpRange.getBegin (), OpRange,
1906
- ListInitialization)
1907
- : (CCK == Sema::CCK_FunctionalCast)
1908
- ? InitializationKind::CreateFunctionalCast (OpRange, ListInitialization)
1909
- : InitializationKind::CreateCast (OpRange);
1898
+ InitializationKind InitKind =
1899
+ (CCK == CheckedConversionKind::CStyleCast)
1900
+ ? InitializationKind::CreateCStyleCast (OpRange.getBegin (), OpRange,
1901
+ ListInitialization)
1902
+ : (CCK == CheckedConversionKind::FunctionalCast)
1903
+ ? InitializationKind::CreateFunctionalCast (OpRange,
1904
+ ListInitialization)
1905
+ : InitializationKind::CreateCast (OpRange);
1910
1906
Expr *SrcExprRaw = SrcExpr.get ();
1911
1907
// FIXME: Per DR242, we should check for an implicit conversion sequence
1912
1908
// or for a constructor that could be invoked by direct-initialization
@@ -1918,8 +1914,8 @@ TryStaticImplicitCast(Sema &Self, ExprResult &SrcExpr, QualType DestType,
1918
1914
// There is no other way that works.
1919
1915
// On the other hand, if we're checking a C-style cast, we've still got
1920
1916
// the reinterpret_cast way.
1921
- bool CStyle
1922
- = (CCK == Sema::CCK_CStyleCast || CCK == Sema::CCK_FunctionalCast );
1917
+ bool CStyle = (CCK == CheckedConversionKind::CStyleCast ||
1918
+ CCK == CheckedConversionKind::FunctionalCast );
1923
1919
if (InitSeq.Failed () && (CStyle || !DestType->isReferenceType ()))
1924
1920
return TC_NotApplicable;
1925
1921
@@ -2814,8 +2810,9 @@ void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle,
2814
2810
if (isValidCast (tcr))
2815
2811
Kind = CK_NoOp;
2816
2812
2817
- Sema::CheckedConversionKind CCK =
2818
- FunctionalStyle ? Sema::CCK_FunctionalCast : Sema::CCK_CStyleCast;
2813
+ CheckedConversionKind CCK = FunctionalStyle
2814
+ ? CheckedConversionKind::FunctionalCast
2815
+ : CheckedConversionKind::CStyleCast;
2819
2816
if (tcr == TC_NotApplicable) {
2820
2817
tcr = TryAddressSpaceCast (Self, SrcExpr, DestType, /* CStyle*/ true , msg,
2821
2818
Kind);
@@ -3201,7 +3198,7 @@ void CastOperation::CheckCStyleCast() {
3201
3198
3202
3199
// ARC imposes extra restrictions on casts.
3203
3200
if (Self.getLangOpts ().allowsNonTrivialObjCLifetimeQualifiers ()) {
3204
- checkObjCConversion (Sema::CCK_CStyleCast );
3201
+ checkObjCConversion (CheckedConversionKind::CStyleCast );
3205
3202
if (SrcExpr.isInvalid ())
3206
3203
return ;
3207
3204
0 commit comments