[clang] [Clang] Reduce the size of Decl and classes derived from it (PR #87361)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 8 19:27:52 PDT 2024


================
@@ -268,17 +268,34 @@ class alignas(8) Decl {
   ///   }
   ///   void A::f(); // SemanticDC == namespace 'A'
   ///                // LexicalDC == global namespace
-  llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx;
+  llvm::PointerIntPair<
----------------
ChuanqiXu9 wrote:

+1 for more comments. I spent more time to understand the structure here. Also maybe we can make the code self explained by:

```suggestion
using DeclCtxTy = llvm::PointerUnion<DeclContext*, MultipleDC*>;
using DeclCtxAndHasAttrTy = llvm::PointerIntPair<llvm::PointerUnion<DeclContext *, MultipleDC *>, 1,
                           bool>;
using DeclCtxAndHasAttrTyOrInvalidDeclTy = ...
```

https://github.com/llvm/llvm-project/pull/87361


More information about the cfe-commits mailing list