@@ -402,9 +402,7 @@ class DeclName {
402
402
size_t NumArgs;
403
403
404
404
explicit CompoundDeclName (DeclBaseName BaseName, size_t NumArgs)
405
- : BaseName (BaseName), NumArgs (NumArgs) {
406
- assert (NumArgs > 0 && " Should use IdentifierAndCompound" );
407
- }
405
+ : BaseName (BaseName), NumArgs (NumArgs) { }
408
406
409
407
ArrayRef<Identifier> getArgumentNames () const {
410
408
return {getTrailingObjects<Identifier>(), NumArgs};
@@ -422,28 +420,24 @@ class DeclName {
422
420
}
423
421
};
424
422
425
- // A single stored identifier, along with a bit stating whether it is the
426
- // base name for a zero-argument compound name.
427
- typedef llvm::PointerIntPair<DeclBaseName, 1 , bool > BaseNameAndCompound;
428
-
429
- // Either a single identifier piece stored inline (with a bit to say whether
430
- // it is simple or compound), or a reference to a compound declaration name.
431
- llvm::PointerUnion<BaseNameAndCompound, CompoundDeclName *> SimpleOrCompound;
423
+ // / Either a single identifier piece stored inline, or a reference to a
424
+ // / compound declaration name.
425
+ llvm::PointerUnion<DeclBaseName, CompoundDeclName *> BaseNameOrCompound;
432
426
433
427
explicit DeclName (void *Opaque)
434
- : SimpleOrCompound (decltype (SimpleOrCompound )::getFromOpaqueValue(Opaque))
428
+ : BaseNameOrCompound (decltype (BaseNameOrCompound )::getFromOpaqueValue(Opaque))
435
429
{}
436
430
437
431
void initialize (ASTContext &C, DeclBaseName baseName,
438
432
ArrayRef<Identifier> argumentNames);
439
433
440
434
public:
441
435
// / Build a null name.
442
- DeclName () : SimpleOrCompound(BaseNameAndCompound ()) {}
436
+ DeclName () : BaseNameOrCompound(DeclBaseName ()) {}
443
437
444
438
// / Build a simple value name with one component.
445
439
/* implicit*/ DeclName(DeclBaseName simpleName)
446
- : SimpleOrCompound(BaseNameAndCompound( simpleName, false ) ) {}
440
+ : BaseNameOrCompound( simpleName) {}
447
441
448
442
/* implicit*/ DeclName(Identifier simpleName)
449
443
: DeclName(DeclBaseName(simpleName)) {}
@@ -462,10 +456,10 @@ class DeclName {
462
456
// / such as the 'foo' in 'func foo(x:Int, y:Int)' or the 'bar' in
463
457
// / 'var bar: Int'.
464
458
DeclBaseName getBaseName () const {
465
- if (auto compound = SimpleOrCompound .dyn_cast <CompoundDeclName*>())
459
+ if (auto compound = BaseNameOrCompound .dyn_cast <CompoundDeclName*>())
466
460
return compound->BaseName ;
467
461
468
- return SimpleOrCompound .get <BaseNameAndCompound>(). getPointer ();
462
+ return BaseNameOrCompound .get <DeclBaseName> ();
469
463
}
470
464
471
465
// / Assert that the base name is not special and return its identifier.
@@ -478,7 +472,7 @@ class DeclName {
478
472
479
473
// / Retrieve the names of the arguments, if there are any.
480
474
ArrayRef<Identifier> getArgumentNames () const {
481
- if (auto compound = SimpleOrCompound .dyn_cast <CompoundDeclName*>())
475
+ if (auto compound = BaseNameOrCompound .dyn_cast <CompoundDeclName*>())
482
476
return compound->getArgumentNames ();
483
477
484
478
return { };
@@ -487,25 +481,19 @@ class DeclName {
487
481
bool isSpecial () const { return getBaseName ().isSpecial (); }
488
482
489
483
explicit operator bool () const {
490
- if (SimpleOrCompound .dyn_cast <CompoundDeclName*>())
484
+ if (BaseNameOrCompound .dyn_cast <CompoundDeclName*>())
491
485
return true ;
492
- return !SimpleOrCompound .get <BaseNameAndCompound>(). getPointer ().empty ();
486
+ return !BaseNameOrCompound .get <DeclBaseName> ().empty ();
493
487
}
494
488
495
489
// / True if this is a simple one-component name.
496
490
bool isSimpleName () const {
497
- if (SimpleOrCompound.dyn_cast <CompoundDeclName*>())
498
- return false ;
499
-
500
- return !SimpleOrCompound.get <BaseNameAndCompound>().getInt ();
491
+ return BaseNameOrCompound.is <DeclBaseName>();
501
492
}
502
493
503
494
// / True if this is a compound name.
504
495
bool isCompoundName () const {
505
- if (SimpleOrCompound.dyn_cast <CompoundDeclName*>())
506
- return true ;
507
-
508
- return SimpleOrCompound.get <BaseNameAndCompound>().getInt ();
496
+ return !isSimpleName ();
509
497
}
510
498
511
499
// / True if this name is a simple one-component name identical to the
@@ -540,7 +528,7 @@ class DeclName {
540
528
// / matches a simple name lookup or when the full compound name matches.
541
529
bool matchesRef (DeclName refName) const {
542
530
// Identical names always match.
543
- if (SimpleOrCompound == refName.SimpleOrCompound )
531
+ if (BaseNameOrCompound == refName.BaseNameOrCompound )
544
532
return true ;
545
533
// If the reference is a simple name, try simple name matching.
546
534
if (refName.isSimpleName ())
@@ -594,7 +582,7 @@ class DeclName {
594
582
return lhs.compare (rhs) >= 0 ;
595
583
}
596
584
597
- void *getOpaqueValue () const { return SimpleOrCompound .getOpaqueValue (); }
585
+ void *getOpaqueValue () const { return BaseNameOrCompound .getOpaqueValue (); }
598
586
static DeclName getFromOpaqueValue (void *p) { return DeclName (p); }
599
587
600
588
// / Get a string representation of the name,
@@ -913,7 +901,7 @@ namespace llvm {
913
901
static inline swift::DeclName getFromVoidPointer (void *ptr) {
914
902
return swift::DeclName::getFromOpaqueValue (ptr);
915
903
}
916
- enum { NumLowBitsAvailable = PointerLikeTypeTraits<swift::DeclBaseName>::NumLowBitsAvailable - 2 };
904
+ enum { NumLowBitsAvailable = PointerLikeTypeTraits<swift::DeclBaseName>::NumLowBitsAvailable - 1 };
917
905
};
918
906
919
907
// DeclNames hash just like pointers.
0 commit comments