@@ -281,85 +281,86 @@ SourceLocation Expr::getExprLoc() const {
281
281
// Primary Expressions.
282
282
// ===----------------------------------------------------------------------===//
283
283
284
- static void AssertResultStorageKind (ConstantExpr::ResultStorageKind Kind) {
285
- assert ((Kind == ConstantExpr::RSK_APValue ||
286
- Kind == ConstantExpr::RSK_Int64 || Kind == ConstantExpr::RSK_None) &&
284
+ static void AssertResultStorageKind (ConstantResultStorageKind Kind) {
285
+ assert ((Kind == ConstantResultStorageKind::APValue ||
286
+ Kind == ConstantResultStorageKind::Int64 ||
287
+ Kind == ConstantResultStorageKind::None) &&
287
288
" Invalid StorageKind Value" );
288
289
(void )Kind;
289
290
}
290
291
291
- ConstantExpr::ResultStorageKind
292
- ConstantExpr::getStorageKind (const APValue &Value) {
292
+ ConstantResultStorageKind ConstantExpr::getStorageKind (const APValue &Value) {
293
293
switch (Value.getKind ()) {
294
294
case APValue::None:
295
295
case APValue::Indeterminate:
296
- return ConstantExpr::RSK_None ;
296
+ return ConstantResultStorageKind::None ;
297
297
case APValue::Int:
298
298
if (!Value.getInt ().needsCleanup ())
299
- return ConstantExpr::RSK_Int64 ;
299
+ return ConstantResultStorageKind::Int64 ;
300
300
[[fallthrough]];
301
301
default :
302
- return ConstantExpr::RSK_APValue ;
302
+ return ConstantResultStorageKind::APValue ;
303
303
}
304
304
}
305
305
306
- ConstantExpr::ResultStorageKind
306
+ ConstantResultStorageKind
307
307
ConstantExpr::getStorageKind (const Type *T, const ASTContext &Context) {
308
308
if (T->isIntegralOrEnumerationType () && Context.getTypeInfo (T).Width <= 64 )
309
- return ConstantExpr::RSK_Int64 ;
310
- return ConstantExpr::RSK_APValue ;
309
+ return ConstantResultStorageKind::Int64 ;
310
+ return ConstantResultStorageKind::APValue ;
311
311
}
312
312
313
- ConstantExpr::ConstantExpr (Expr *SubExpr, ResultStorageKind StorageKind,
313
+ ConstantExpr::ConstantExpr (Expr *SubExpr, ConstantResultStorageKind StorageKind,
314
314
bool IsImmediateInvocation)
315
315
: FullExpr(ConstantExprClass, SubExpr) {
316
- ConstantExprBits.ResultKind = StorageKind;
316
+ ConstantExprBits.ResultKind = llvm::to_underlying ( StorageKind) ;
317
317
ConstantExprBits.APValueKind = APValue::None;
318
318
ConstantExprBits.IsUnsigned = false ;
319
319
ConstantExprBits.BitWidth = 0 ;
320
320
ConstantExprBits.HasCleanup = false ;
321
321
ConstantExprBits.IsImmediateInvocation = IsImmediateInvocation;
322
322
323
- if (StorageKind == ConstantExpr::RSK_APValue )
323
+ if (StorageKind == ConstantResultStorageKind::APValue )
324
324
::new (getTrailingObjects<APValue>()) APValue ();
325
325
}
326
326
327
327
ConstantExpr *ConstantExpr::Create (const ASTContext &Context, Expr *E,
328
- ResultStorageKind StorageKind,
328
+ ConstantResultStorageKind StorageKind,
329
329
bool IsImmediateInvocation) {
330
330
assert (!isa<ConstantExpr>(E));
331
331
AssertResultStorageKind (StorageKind);
332
332
333
333
unsigned Size = totalSizeToAlloc<APValue, uint64_t >(
334
- StorageKind == ConstantExpr::RSK_APValue ,
335
- StorageKind == ConstantExpr::RSK_Int64 );
334
+ StorageKind == ConstantResultStorageKind::APValue ,
335
+ StorageKind == ConstantResultStorageKind::Int64 );
336
336
void *Mem = Context.Allocate (Size, alignof (ConstantExpr));
337
337
return new (Mem) ConstantExpr (E, StorageKind, IsImmediateInvocation);
338
338
}
339
339
340
340
ConstantExpr *ConstantExpr::Create (const ASTContext &Context, Expr *E,
341
341
const APValue &Result) {
342
- ResultStorageKind StorageKind = getStorageKind (Result);
342
+ ConstantResultStorageKind StorageKind = getStorageKind (Result);
343
343
ConstantExpr *Self = Create (Context, E, StorageKind);
344
344
Self->SetResult (Result, Context);
345
345
return Self;
346
346
}
347
347
348
- ConstantExpr::ConstantExpr (EmptyShell Empty, ResultStorageKind StorageKind)
348
+ ConstantExpr::ConstantExpr (EmptyShell Empty,
349
+ ConstantResultStorageKind StorageKind)
349
350
: FullExpr(ConstantExprClass, Empty) {
350
- ConstantExprBits.ResultKind = StorageKind;
351
+ ConstantExprBits.ResultKind = llvm::to_underlying ( StorageKind) ;
351
352
352
- if (StorageKind == ConstantExpr::RSK_APValue )
353
+ if (StorageKind == ConstantResultStorageKind::APValue )
353
354
::new (getTrailingObjects<APValue>()) APValue ();
354
355
}
355
356
356
357
ConstantExpr *ConstantExpr::CreateEmpty (const ASTContext &Context,
357
- ResultStorageKind StorageKind) {
358
+ ConstantResultStorageKind StorageKind) {
358
359
AssertResultStorageKind (StorageKind);
359
360
360
361
unsigned Size = totalSizeToAlloc<APValue, uint64_t >(
361
- StorageKind == ConstantExpr::RSK_APValue ,
362
- StorageKind == ConstantExpr::RSK_Int64 );
362
+ StorageKind == ConstantResultStorageKind::APValue ,
363
+ StorageKind == ConstantResultStorageKind::Int64 );
363
364
void *Mem = Context.Allocate (Size, alignof (ConstantExpr));
364
365
return new (Mem) ConstantExpr (EmptyShell (), StorageKind);
365
366
}
@@ -368,15 +369,15 @@ void ConstantExpr::MoveIntoResult(APValue &Value, const ASTContext &Context) {
368
369
assert ((unsigned )getStorageKind (Value) <= ConstantExprBits.ResultKind &&
369
370
" Invalid storage for this value kind" );
370
371
ConstantExprBits.APValueKind = Value.getKind ();
371
- switch (ConstantExprBits. ResultKind ) {
372
- case RSK_None :
372
+ switch (getResultStorageKind () ) {
373
+ case ConstantResultStorageKind::None :
373
374
return ;
374
- case RSK_Int64 :
375
+ case ConstantResultStorageKind::Int64 :
375
376
Int64Result () = *Value.getInt ().getRawData ();
376
377
ConstantExprBits.BitWidth = Value.getInt ().getBitWidth ();
377
378
ConstantExprBits.IsUnsigned = Value.getInt ().isUnsigned ();
378
379
return ;
379
- case RSK_APValue :
380
+ case ConstantResultStorageKind::APValue :
380
381
if (!ConstantExprBits.HasCleanup && Value.needsCleanup ()) {
381
382
ConstantExprBits.HasCleanup = true ;
382
383
Context.addDestruction (&APValueResult ());
@@ -388,10 +389,10 @@ void ConstantExpr::MoveIntoResult(APValue &Value, const ASTContext &Context) {
388
389
}
389
390
390
391
llvm::APSInt ConstantExpr::getResultAsAPSInt () const {
391
- switch (ConstantExprBits. ResultKind ) {
392
- case ConstantExpr::RSK_APValue :
392
+ switch (getResultStorageKind () ) {
393
+ case ConstantResultStorageKind::APValue :
393
394
return APValueResult ().getInt ();
394
- case ConstantExpr::RSK_Int64 :
395
+ case ConstantResultStorageKind::Int64 :
395
396
return llvm::APSInt (llvm::APInt (ConstantExprBits.BitWidth , Int64Result ()),
396
397
ConstantExprBits.IsUnsigned );
397
398
default :
@@ -401,14 +402,14 @@ llvm::APSInt ConstantExpr::getResultAsAPSInt() const {
401
402
402
403
APValue ConstantExpr::getAPValueResult () const {
403
404
404
- switch (ConstantExprBits. ResultKind ) {
405
- case ConstantExpr::RSK_APValue :
405
+ switch (getResultStorageKind () ) {
406
+ case ConstantResultStorageKind::APValue :
406
407
return APValueResult ();
407
- case ConstantExpr::RSK_Int64 :
408
+ case ConstantResultStorageKind::Int64 :
408
409
return APValue (
409
410
llvm::APSInt (llvm::APInt (ConstantExprBits.BitWidth , Int64Result ()),
410
411
ConstantExprBits.IsUnsigned ));
411
- case ConstantExpr::RSK_None :
412
+ case ConstantResultStorageKind::None :
412
413
if (ConstantExprBits.APValueKind == APValue::Indeterminate)
413
414
return APValue::IndeterminateValue ();
414
415
return APValue ();
0 commit comments