krisb added a comment. In D109703#2998155 <https://reviews.llvm.org/D109703#2998155>, @ellis wrote:
> I've added this to the added test case. > > !18 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !4, > entity: !19, line: 122) > !19 = !DIGlobalVariable(name: "imported_static_var", scope: !6, file: !5, > line: 3, type: !10, isLocal: false, isDefinition: true) Thank you for pointing to this! Just in case, do you have a C++ example, that reproduces the issue with imported static local declaration? I'm asking, cause in your example `DW_TAG_imported_declaration` has CU as a scope, while `DIGlobalVariable` is function-scoped. This looks a bit strange. I mean, `constructImportedEntityDIE()` called from `DwarfDebug::beginModule()` skips all local-scoped entities, and unless I'm missing something static locals shouldn't go here. Another call for `constructImportedEntityDIE()` is from `DwarfCompileUnit::createScopeChildrenDIE` where I'd not expect any issue with parents. But it seems imported declarations are broken not just for static locals, but for all inlined entities, for example namespace ns { inline __attribute__((always_inline)) int foo() { int a = 42; return a; } } int main() { using ns::foo; return foo(); } produces (with or w/o this patch) imported declaration for `foo()` that refers to an empty subprogram: x0000002a: DW_TAG_namespace DW_AT_name ("ns") 0x0000002f: DW_TAG_subprogram DW_AT_name ("foo") DW_AT_inline (DW_INL_inlined) 0x0000003f: DW_TAG_variable DW_AT_name ("a") 0x0000004a: NULL 0x0000004b: DW_TAG_subprogram 0x0000004c: NULL 0x00000054: DW_TAG_subprogram DW_AT_name ("main") 0x0000006d: DW_TAG_imported_declaration DW_AT_import (0x0000004b) while it should point to `0x0000002f`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D109703/new/ https://reviews.llvm.org/D109703 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits