[PATCH] D126883: [Debuginfo][DWARF][NFC] Refactor DwarfStringPoolEntryRef.
Jonas Devlieghere via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 14 09:22:01 PDT 2022
JDevlieghere added a comment.
In D126883#3571202 <https://reviews.llvm.org/D126883#3571202>, @avl wrote:
> In D126883#3568729 <https://reviews.llvm.org/D126883#3568729>, @JDevlieghere wrote:
>
>> I missed the original discussion about templating the class. It seems like that issue can be solved with the same solution we have form something like SmallVector where we pass the generic base class `SmallVectorImpl` around. I think we should be able to do something similar here?
>
> I.e. something like this:
>
> template <typename T>
> DwarfStringPoolEntryRef (
> MCSymbol *getSymbol() const;
> uint64_t getOffset() const;
> unsigned getIndex() const;
> StringRef getString() const;
> const DwarfStringPoolEntry &getEntry() const;
> )
>
>
> OwningDwarfStringPoolEntryRef : public DwarfStringPoolEntryRef<DwarfStringPoolEntry> (
> )
>
> NonOwningDwarfStringPoolEntryRef : public DwarfStringPoolEntryRef<DwarfStringPoolEntry*> (
> )
>
>
> template <typename DataT> class AccelTable : public AccelTableBase {
> public:
> template <typename EntryT, typename... Types>
> void addName(DwarfStringPoolEntryRef<EntryT>& Name, Types &&... Args);
> };
>
> template<typename T>
> class DIEString {
> DwarfStringPoolEntryRef<T>& S;
>
> }
>
> ?
Almost, what I had in mind was this:
DwarfStringPoolEntry {
...
}
DwarfStringPoolEntryRefImpl {
// Everything that *doesn't* depend on whether it's backed by a DwarfStringPoolEntry or DwarfStringPoolEntry*. This should be able to cover your entire public interface.
}
template<typename T>
DwarfStringPoolEntryRef : public DwarfStringPoolEntryRefImpl {
// Everything that *does* depend on the type of T.
}
// The (Non)OwningDwarfStringPoolEntryRef are now just typedefs.
typedef OwningDwarfStringPoolEntryRef = DwarfStringPoolEntryRef<DwarfStringPoolEntry*>;
typedef NonOwningDwarfStringPoolEntryRef = DwarfStringPoolEntryRef<DwarfStringPoolEntry*>;
// The accelerator table can remain non-templated by only interacting with the DwarfStringPoolEntryRefImpl:
template class AccelTable : public AccelTableBase {
public:
template <typename EntryT, typename... Types>
void addName(DwarfStringPoolEntryRefImpl& Name, Types &&... Args);
};
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126883/new/
https://reviews.llvm.org/D126883
More information about the llvm-commits
mailing list