[Lldb-commits] [PATCH] D145803: [clang][DebugInfo] Emit DW_AT_type of preferred name if available

Michael Buch via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 23 10:54:07 PDT 2023


Michael137 added inline comments.


================
Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:2640
   if (!D || !D->isCompleteDefinition())
-    return FwdDecl;
+    return {FwdDecl, nullptr};
 
----------------
aprantl wrote:
> I'm curious if this works if we encounter a forward declaration, early exit here, then encounter a use of the type, and then the definition, since completeClass effectively also ignores the preferred name?
Good point. If we ever take this branch we won't end up emitting the preferred name. For my `-gmodules` test cases this works out fine because the modules that contain the instantiations would see the preferred name. But I can indeed construct a non-modules test case where we end up using a forward declared structure where the preferred name gets ignored here. Not sure we can do much here for such cases.

The alternative I considered where we create some sort of `PreferredNameCache[TagType*] => DIDerivedType` and use it when replacing forward declarations in `finalize()` doesn't work for the normal case because we don't have any forward declarations to replace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145803



More information about the lldb-commits mailing list