[clang] [llvm] [clang][DebugInfo] Add virtual call-site target information in DWARF. (PR #167666)

Carlos Alberto Enciso via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 9 01:07:42 PST 2026


CarlosAlbertoEnciso wrote:

For the given test:
```
struct CBase {
  virtual void f1();
  virtual void f2();
  virtual void f3() {}
  virtual void f4();
};

void CBase::f1() {}

void bar(CBase *Base) {
  Base->f1();  // seen declaration and definition.
  Base->f2();  // seen declaration, not seen definition.
  Base->f3();  // seen declaration and definition.
  Base->f4();  // seen declaration, missing definition.
}

void CBase::f2() {}
```
**Note**: 'f4' does not have a definition.

A simplified DWARF for the current patch, looks like:
```
// Structure 'CBase'
0x00000035:   DW_TAG_structure_type ("CBase")

// Declarations for 'f1', 'f2', 'f3' and 'f4'.
0x00000046:     DW_TAG_subprogram ("f1")
0x00000059:     DW_TAG_subprogram ("f2")
0x0000006c:     DW_TAG_subprogram ("f3")
0x0000007f:     DW_TAG_subprogram ("f4")

// Definitions for 'f1', 'f2' and 'f3'.
0x000000b4:   DW_TAG_subprogram
                DW_AT_specification (0x00000046 "_ZN5CBase2f1Ev")
0x00000113:   DW_TAG_subprogram
                DW_AT_specification (0x00000059 "_ZN5CBase2f2Ev")
0x0000012e:   DW_TAG_subprogram
                DW_AT_specification (0x0000006c "_ZN5CBase2f3Ev")

// Subprogram 'bar'
DW_TAG_subprogram ("bar")

  DW_TAG_call_site
    DW_AT_LLVM_virtual_call_origin (0x000000b4 "_ZN5CBase2f1Ev")

  DW_TAG_call_site
    DW_AT_LLVM_virtual_call_origin (0x00000113 "_ZN5CBase2f2Ev")

  DW_TAG_call_site
    DW_AT_LLVM_virtual_call_origin (0x0000012e "_ZN5CBase2f3Ev")

  DW_TAG_call_site
    DW_AT_LLVM_virtual_call_origin (0x0000007f "_ZN5CBase2f4Ev")
```
The 'DW_AT_LLVM_virtual_call_origin' are pointing to the **method definition or to the method declaration** if its definition is missing.


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


More information about the cfe-commits mailing list