[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 25 07:04:01 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>
----------------
cor3ntin 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?
I did think about that but I don't see how it would not massively penalize lookup.
(Note that there is an existing defect that we don't cache `__bitwise_copyable`, and maybe we'd want to use the same map for that)
> Also, do we typically do caching like this in ASTContext? I thought we did this in Sema more often.
I mean, the fact we have a type property depending on Sema is pretty novel (and I hate it!) - but yeah, all of the other cached properties are stored in ASTContext and that seem like the most logical to me
> Also-also: does this play well with deserialization?
Given the property is always on the definition, yes?
https://github.com/llvm/llvm-project/pull/127636
More information about the cfe-commits
mailing list