@@ -542,6 +542,9 @@ class LabelDecl : public NamedDecl {
542
542
class NamespaceDecl : public NamedDecl , public DeclContext ,
543
543
public Redeclarable<NamespaceDecl>
544
544
{
545
+
546
+ enum Flags : unsigned { F_Inline = 1 << 0 , F_Nested = 1 << 1 };
547
+
545
548
// / The starting location of the source range, pointing
546
549
// / to either the namespace or the inline keyword.
547
550
SourceLocation LocStart;
@@ -553,11 +556,12 @@ class NamespaceDecl : public NamedDecl, public DeclContext,
553
556
// / this namespace or to the first namespace in the chain (the latter case
554
557
// / only when this is not the first in the chain), along with a
555
558
// / boolean value indicating whether this is an inline namespace.
556
- llvm::PointerIntPair<NamespaceDecl *, 1 , bool > AnonOrFirstNamespaceAndInline;
559
+ llvm::PointerIntPair<NamespaceDecl *, 2 , unsigned >
560
+ AnonOrFirstNamespaceAndFlags;
557
561
558
562
NamespaceDecl (ASTContext &C, DeclContext *DC, bool Inline,
559
563
SourceLocation StartLoc, SourceLocation IdLoc,
560
- IdentifierInfo *Id, NamespaceDecl *PrevDecl);
564
+ IdentifierInfo *Id, NamespaceDecl *PrevDecl, bool Nested );
561
565
562
566
using redeclarable_base = Redeclarable<NamespaceDecl>;
563
567
@@ -569,10 +573,10 @@ class NamespaceDecl : public NamedDecl, public DeclContext,
569
573
friend class ASTDeclReader ;
570
574
friend class ASTDeclWriter ;
571
575
572
- static NamespaceDecl *Create (ASTContext &C, DeclContext *DC,
573
- bool Inline , SourceLocation StartLoc ,
574
- SourceLocation IdLoc, IdentifierInfo *Id ,
575
- NamespaceDecl *PrevDecl );
576
+ static NamespaceDecl *Create (ASTContext &C, DeclContext *DC, bool Inline,
577
+ SourceLocation StartLoc , SourceLocation IdLoc ,
578
+ IdentifierInfo *Id, NamespaceDecl *PrevDecl ,
579
+ bool Nested );
576
580
577
581
static NamespaceDecl *CreateDeserialized (ASTContext &C, unsigned ID);
578
582
@@ -601,12 +605,33 @@ class NamespaceDecl : public NamedDecl, public DeclContext,
601
605
602
606
// / Returns true if this is an inline namespace declaration.
603
607
bool isInline () const {
604
- return AnonOrFirstNamespaceAndInline .getInt ();
608
+ return AnonOrFirstNamespaceAndFlags .getInt () & F_Inline ;
605
609
}
606
610
607
611
// / Set whether this is an inline namespace declaration.
608
612
void setInline (bool Inline) {
609
- AnonOrFirstNamespaceAndInline.setInt (Inline);
613
+ unsigned F = AnonOrFirstNamespaceAndFlags.getInt ();
614
+ if (Inline)
615
+ AnonOrFirstNamespaceAndFlags.setInt (F | F_Inline);
616
+ else
617
+ AnonOrFirstNamespaceAndFlags.setInt (F & ~F_Inline);
618
+ }
619
+
620
+ // / Returns true if this is a nested namespace declaration.
621
+ // / \code
622
+ // / namespace outer::nested { }
623
+ // / \endcode
624
+ bool isNested () const {
625
+ return AnonOrFirstNamespaceAndFlags.getInt () & F_Nested;
626
+ }
627
+
628
+ // / Set whether this is a nested namespace declaration.
629
+ void setNested (bool Nested) {
630
+ unsigned F = AnonOrFirstNamespaceAndFlags.getInt ();
631
+ if (Nested)
632
+ AnonOrFirstNamespaceAndFlags.setInt (F | F_Nested);
633
+ else
634
+ AnonOrFirstNamespaceAndFlags.setInt (F & ~F_Nested);
610
635
}
611
636
612
637
// / Returns true if the inline qualifier for \c Name is redundant.
@@ -635,11 +660,11 @@ class NamespaceDecl : public NamedDecl, public DeclContext,
635
660
// / Retrieve the anonymous namespace nested inside this namespace,
636
661
// / if any.
637
662
NamespaceDecl *getAnonymousNamespace () const {
638
- return getOriginalNamespace ()->AnonOrFirstNamespaceAndInline .getPointer ();
663
+ return getOriginalNamespace ()->AnonOrFirstNamespaceAndFlags .getPointer ();
639
664
}
640
665
641
666
void setAnonymousNamespace (NamespaceDecl *D) {
642
- getOriginalNamespace ()->AnonOrFirstNamespaceAndInline .setPointer (D);
667
+ getOriginalNamespace ()->AnonOrFirstNamespaceAndFlags .setPointer (D);
643
668
}
644
669
645
670
// / Retrieves the canonical declaration of this namespace.
0 commit comments