1919
2020#include " swift/Demangling/Demangler.h"
2121#include " swift/Demangling/NamespaceMacros.h"
22+ #include " llvm/ADT/PointerIntPair.h"
2223#include < unordered_map>
2324
2425using namespace swift ::Demangle;
@@ -37,14 +38,19 @@ SWIFT_BEGIN_INLINE_NAMESPACE
3738
3839// An entry in the remangler's substitution map.
3940class SubstitutionEntry {
40- Node *TheNode = nullptr ;
41+ llvm::PointerIntPair< Node *, 1 , bool > NodeAndTreatAsIdentifier ;
4142 size_t StoredHash = 0 ;
42- bool treatAsIdentifier = false ;
43+
44+ Node *getNode () const { return NodeAndTreatAsIdentifier.getPointer (); }
45+
46+ bool getTreatAsIdentifier () const {
47+ return NodeAndTreatAsIdentifier.getInt ();
48+ }
4349
4450public:
4551 void setNode (Node *node, bool treatAsIdentifier, size_t hash) {
46- this -> treatAsIdentifier = treatAsIdentifier ;
47- TheNode = node ;
52+ NodeAndTreatAsIdentifier. setPointer (node) ;
53+ NodeAndTreatAsIdentifier. setInt (treatAsIdentifier) ;
4854 StoredHash = hash;
4955 }
5056
@@ -54,10 +60,10 @@ class SubstitutionEntry {
5460 }
5561 };
5662
57- bool isEmpty () const { return !TheNode ; }
63+ bool isEmpty () const { return !getNode () ; }
5864
5965 bool matches (Node *node, bool treatAsIdentifier) const {
60- return node == TheNode && treatAsIdentifier == this -> treatAsIdentifier ;
66+ return node == getNode () && treatAsIdentifier == getTreatAsIdentifier () ;
6167 }
6268
6369 size_t hash () const { return StoredHash; }
@@ -67,12 +73,12 @@ class SubstitutionEntry {
6773 const SubstitutionEntry &rhs) {
6874 if (lhs.StoredHash != rhs.StoredHash )
6975 return false ;
70- if (lhs.treatAsIdentifier != rhs.treatAsIdentifier )
76+ if (lhs.getTreatAsIdentifier () != rhs.getTreatAsIdentifier () )
7177 return false ;
72- if (lhs.treatAsIdentifier ) {
73- return identifierEquals (lhs.TheNode , rhs.TheNode );
78+ if (lhs.getTreatAsIdentifier () ) {
79+ return identifierEquals (lhs.getNode () , rhs.getNode () );
7480 }
75- return lhs.deepEquals (lhs.TheNode , rhs.TheNode );
81+ return lhs.deepEquals (lhs.getNode () , rhs.getNode () );
7682 }
7783
7884 static bool identifierEquals (Node *lhs, Node *rhs);
0 commit comments