[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 25 06:33:16 PST 2025


================
@@ -624,6 +624,20 @@ class ASTContext : public RefCountedBase<ASTContext> {
   using ParameterIndexTable = llvm::DenseMap<const VarDecl *, unsigned>;
   ParameterIndexTable ParamIndices;
 
+public:
+  struct CXXRecordDeclRelocationInfo {
+    unsigned IsRelocatable;
+    unsigned IsReplaceable;
+  };
+  std::optional<CXXRecordDeclRelocationInfo>
+  getRelocationInfoForCXXRecord(const CXXRecordDecl *) const;
+  void setRelocationInfoForCXXRecord(const CXXRecordDecl *,
+                                     CXXRecordDeclRelocationInfo);
+
+private:
+  llvm::DenseMap<const CXXRecordDecl *, CXXRecordDeclRelocationInfo>
----------------
erichkeane wrote:

With the 'value' here only being 2 bits of information, I find myself wondering if we could switch `CXXRecordDeclRelocationInfo` to an enum-as-flags, and do something with `PointerIntPair` here.  Then store these either as a sorted vector, or a 'set' in some way?  Perhaps have a look around? 

Also, do we typically do caching like this in ASTContext? I thought we did this in Sema more often.  

Also-also: does this play well with deserialization? 

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


More information about the cfe-commits mailing list