[Lldb-commits] [lldb] [llvm] [CodeView] Resolve all forward referenced types from TPI stream (PR #193064)

Alexandre Ganea via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 27 16:49:35 PDT 2026


aganea wrote:

> > I wonder in which case lldb would use wrong type index in the example of #187883. Will type index 0x1006 (the one without ptr) ever be referenced somewhere after uncommenting it? If no, lldb shouldn't even try to create type using that index (it should just create the type from the variable symbol record that refers to the correct type 0x1008). Maybe something else happens I'm not aware of.
> 
> Okay I understand the problem by reproing it. Found that f points to the correct non-forwarding type index but p points to 0x1003 -> 0x1002 -> 0x1006 (because of choosing the first matching type):
> 
> ```
> Symbol:
>      228 | S_REGREL32 [size = 16] `f`
>            type = 0x1008 (Foo), register = RSP, offset = 40
>      244 | S_REGREL32 [size = 16] `p`
>            type = 0x1003 (Foo*), register = RSP, offset = 32
> Types:
>   0x1002 | LF_STRUCTURE [size = 36] `Foo`
>            unique name: `.?AUFoo@@`
>            vtable: <no type>, base list: <no type>, field list: <no type>
>            options: forward ref (-> 0x1006) | has unique name, sizeof 0
>   0x1003 | LF_POINTER [size = 12]
>            referent = 0x1002, mode = pointer, opts = None, kind = ptr64
> ...
>   0x1005 | LF_FIELDLIST [size = 28]
>            - LF_MEMBER [name = `a`, Type = 0x0074 (int), offset = 0, attrs = public]
>            - LF_ONEMETHOD [name = `Foo`]
>              type = 0x1004, vftable offset = -1, attrs = public compiler-generated
>   0x1006 | LF_STRUCTURE [size = 36] `Foo`
>            unique name: `.?AUFoo@@`
>            vtable: <no type>, base list: <no type>, field list: 0x1005
>            options: has ctor / dtor | has unique name, sizeof 4
> ```
> 
> I think that's also what happens inside lldb. With this fix, when creating types for `p`, `findFullDeclForForwardRef` will return both 0x1006 and 0x1008. But how the users know which one is the correct type, maybe by finding the other direct reference to non-forwarding type (e.g. 0x1008) in symbol record stream.

Yes, that’s what I was hinting at in this comment: https://github.com/llvm/llvm-project/pull/193064#issuecomment-4284737639

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


More information about the lldb-commits mailing list