akyrtzi added a comment.

Since the issue is specific to enumerators I would recommend against increasing 
the size of `DeclBase`, which would increase the size of every single `Decl` in 
the AST.

There are multiple ways to approach this:

- Consider whether bringing back the comma check just for enumerators would 
work.
- Check the enumerators from the parent `EnumDecl`. The number of enumerators 
inside an `EnumDecl` is usually relatively small, you can do measurements to 
see how the performance looks with actual code.
- If there is noticable performance regression:
  - Either add "previous enumerator" pointer in `EnumConstantDecl` (increases 
size of every `EnumConstantDecl` in the AST)
  - Or add "out-of-AST-decl" tracking via adding some `DenseMap` in 
`ASTContext` that is only populated when comments for enumerators of an 
`EnumDecl` are requested. There is much precedent for this, for example see 
these examples:

          /// A cache mapping from CXXRecordDecls to key functions.
          llvm::DenseMap<const CXXRecordDecl*, LazyDeclPtr> KeyFunctions;
  
          /// Mapping from ObjCContainers to their ObjCImplementations.
          llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*> ObjCImpls;
  
          /// Mapping from ObjCMethod to its duplicate declaration in the same
          /// interface.
          llvm::DenseMap<const ObjCMethodDecl*,const ObjCMethodDecl*> 
ObjCMethodRedecls;
  
          /// Mapping from __block VarDecls to BlockVarCopyInit.
          llvm::DenseMap<const VarDecl *, BlockVarCopyInit> BlockVarCopyInits;
          

The benefit of a separate map is that it only takes additional memory when a 
particular functionality is requested.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125061/new/

https://reviews.llvm.org/D125061

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to