llvm-project
92f058a8 - [DebugInfo][CodeView] Resolve forward references to types without unique name (#203781)

Commit
153 days ago
[DebugInfo][CodeView] Resolve forward references to types without unique name (#203781) In the following code: ```cpp // header.h typedef struct lua_State lua_State; lua_State *getState(); // source.c #include "header.h" struct lua_State { int field; }; lua_State *getState() { static lua_State state = {.field=42}; // make sure the type is emitted return &state; } // main.cpp extern "C" { #include "header.h" } int main() { return getState() != 0; } ``` We'll get two forward references for `lua_State` when compiling with clang-cl. One with a unique name (from C++) and one without (from C). There's one complete definition for the type (from `source.c`). Since this is from C, it doesn't have a unique name. Before, we could only resolve the forward reference from C, not from C++. With this PR, we can resolve both references. I also tested that the VS debugger resolves the reference correctly. I'm not sure if this is a clang bug, because when compiling with MSVC, the C type also has a unique name. Clang omits the unique name, because C doesn't have ODR like C++.
Author
Parents
Loading