[llvm] [XCOFF][OBJECT] get symbol size by calling XCOFF interfaces (PR #67304)

Chen Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 00:52:18 PDT 2023


================
@@ -822,11 +833,29 @@ class XCOFFSymbolRef {
   Expected<XCOFFCsectAuxRef> getXCOFFCsectAuxRef() const;
 
 private:
-  const XCOFFObjectFile *OwningObjectPtr;
+  const XCOFFObjectFile *getObject() const {
+    return cast<XCOFFObjectFile>(BasicSymbolRef::getObject());
+  }
+
   const XCOFFSymbolEntry32 *Entry32 = nullptr;
----------------
chenzheng1030 wrote:

Thanks for comment Digger. But I politely disagree with the proposal here. I think we should let `XCOFFSymbolRef` derive from `SymbolRef`, that would make high level code does not need to differentiate lower symbol type, we can just use SymbolRef to stand for all lower symbol types, right?

> the value of Entry32(Entry64) maybe not be initiated , it will caused getValue() of XCOFFSymbolRef crashed.

Sorry, I don't quite understand. The `XCOFFSymbolRef` only has one constructor and inside the constructor, the entry is always initialized, so why Entry32(Entry64) may be not initialized when we are using a `XCOFFSymbolRef` object?

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


More information about the llvm-commits mailing list