jankratochvil added inline comments.

================
Comment at: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:268
+          if (decl_ctx)
+            LinkDeclContextToDIE(decl_ctx, die);
+          return type_sp;
----------------
I have added these 4 lines - `decl_ctx` copy - which fixes the 
`-fdebug-types-section` regression [[ https://reviews.llvm.org/D51578#1294416 | 
described before ]] as:

There is a `_dwarf` -> `_dwarf_type_units` regression for: `-f 
TestCppTypeLookup.test_namespace_only_dwarf_type_units`
```
./bin/clang -o 1 
../llvm-git/tools/lldb/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp
 -g -fdebug-types-section;./bin/lldb -o 'settings set 
target.experimental.inject-local-vars false' -o 'target create "./1"' -o 'b 66' 
-o r -o 'p *((in_contains_type *)&i)'
```
Expected:
```(lldb) p *((in_contains_type *)&i)
error: use of undeclared identifier 'in_contains_type'
error: expected expression
```
Actual:
```(lldb) p *((in_contains_type *)&i)
(in_contains_type) $0 = (aaa = 123)
```

The regression was due to `DWARFASTParserClang::GetClangDeclContextForDIE` 
calling `ResolveType` but then still `GetCachedClangDeclContextForDIE` was 
returning NULL `decl_ctx`.  That was because in this code above the recursive 
`ParseTypeFromDWARF` call properly did set `LinkDeclContextToDIE` but only for 
the referenced DIE, not for the referring DIE.  But then the caller asked for 
DeclContext of the referring DIE which has not been found.

```
  Compilation Unit @ offset 0x84:
   Signature:     0x368b3ff5e79ee8d1
 <0><9b>: Abbrev Number: 1 (DW_TAG_type_unit)
 <1><a2>: Abbrev Number: 2 (DW_TAG_namespace)
    <a3>   DW_AT_name        : (indirect string, offset: 0x149): nsp_a
 <2><a7>: Abbrev Number: 6 (DW_TAG_structure_type)
HERE: Referenced DIE.
    <a9>   DW_AT_name        : (indirect string, offset: 0x169): contains_type
  Compilation Unit @ offset 0xb2:
   Signature:     0xb27591880ea58868
 <0><c9>: Abbrev Number: 1 (DW_TAG_type_unit)
 <1><d0>: Abbrev Number: 2 (DW_TAG_namespace)
    <d1>   DW_AT_name        : (indirect string, offset: 0x149): nsp_a
 <2><d5>: Abbrev Number: 7 (DW_TAG_structure_type)
HERE: Referring DIE.
    <d6>   DW_AT_declaration : 1
    <d6>   DW_AT_signature   : signature: 0x368b3ff5e79ee8d1
 <3><de>: Abbrev Number: 3 (DW_TAG_structure_type)
    <e0>   DW_AT_name        : (indirect string, offset: 0x166): 
in_contains_type
 <4><e7>: Abbrev Number: 4 (DW_TAG_member)
    <e8>   DW_AT_name        : (indirect string, offset: 0x177): aaa
```


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D54670



_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to