[Lldb-commits] [PATCH] D126668: LLDB: Fix resolving nested template parameters

Levon Ter-Grigoryan via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon May 30 10:14:20 PDT 2022


PatriosTheGreat created this revision.
PatriosTheGreat added a reviewer: teemperor.
Herald added a reviewer: shafik.
Herald added a project: All.
PatriosTheGreat requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Right now LLDB ignores nested template type:

echo "
template <typename T>
struct A {};
int main() {

  A<A<int>> s;

}
" > sample.cc

clang++ sample.cc -g -O0
lldb-15 a.out -o "breakpoint set -l 6 -f sample.cc" -o "run" -o "frame variable"

The result:
(A<A**<>**>) s = {}

This issue was introduced in LLDB 12 due to this CL: https://reviews.llvm.org/D92425
Before LLDB 12 this type was resolving correctly:
(A<A**<int>** >) s = {}

I discussed this issue with Raphael in discord:
https://discord.com/channels/636084430946959380/636732809708306432/980825811714191371

Apparently in this case Clang emits A<int> as a forward declaration:
0x000005b4:   DW_TAG_base_type

  DW_AT_name      ("int")
  DW_AT_encoding  (DW_ATE_signed)
  DW_AT_byte_size (0x04)

0x000005bb:   DW_TAG_structure_type

  DW_AT_calling_convention        (DW_CC_pass_by_value)
  DW_AT_name      ("A<A<int> >")
  DW_AT_byte_size (0x01)
  DW_AT_decl_file ("/home/teemperor/test/args.cpp")
  DW_AT_decl_line (2)

0x000005c4:     DW_TAG_template_type_parameter

  DW_AT_type    (0x000005ce "A<int>")
  DW_AT_name    ("T")

0x000005cd:     NULL

0x000005ce:   DW_TAG_structure_type

  DW_AT_name      ("A<int>")
  DW_AT_declaration       (true)

0x000005d3:   NULL

So for LLDB it looks the same as template with empty arguments.
Turning back the old logic is fixing this issue. Other tests from LLVM test suite on Linux seems to be green.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126668

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py


Index: lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
===================================================================
--- lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
+++ lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
@@ -47,7 +47,7 @@
         # Record types without a defining declaration are not complete.
         self.assertPointeeIncomplete("FwdClass *", "fwd_class")
         self.assertPointeeIncomplete("FwdClassTypedef *", "fwd_class_typedef")
-        self.assertPointeeIncomplete("FwdTemplateClass<> *", "fwd_template_class")
+        self.assertPointeeIncomplete("FwdTemplateClass<int> *", "fwd_template_class")
 
         # A pointer type is complete even when it points to an incomplete type.
         fwd_class_ptr = self.expect_expr("fwd_class", result_type="FwdClass *")
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2050,6 +2050,8 @@
       break;
     }
   }
+  if (template_param_infos.args.empty() && template_param_infos.names.empty())
+    return false;
   return template_param_infos.args.size() == template_param_infos.names.size();
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126668.432955.patch
Type: text/x-patch
Size: 1357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220530/194fef57/attachment-0001.bin>


More information about the lldb-commits mailing list