[PATCH] D68466: [DebugInfo] Allow <Symbol, Offset> pairs in AddressPool [NFC]

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 09:54:52 PDT 2019


aprantl added inline comments.


================
Comment at: llvm/lib/CodeGen/AsmPrinter/AddressPool.h:21
+/// Pair of a symbol and an offset in number of bytes.
+typedef std::pair<const MCSymbol *, int> SymbolWithOffset;
+
----------------
dstenb wrote:
> aprantl wrote:
> > I usually recommend defining a struct instead, so the members can have descriptive names for better readability. Since you still want the DenseMap to work, a trick I used elsewhere is to inherit from std::pair and provide accessors. Maybe that's excessive here.
> Thanks for the suggestion! I have probably overlooked something, but when I inherited from std::pair I still had to implement DenseMapInfo for the inherited class, so all-in-all the code was about as large as implementing a normal struct, so I went with the latter (using the std::pair's `DenseMapInfo::getHashValue()` implementation though).
The idea is to use a DenseMap<std::pair<>> for the automatic DenseMapInfo and cast to the struct as needed.


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

https://reviews.llvm.org/D68466





More information about the llvm-commits mailing list