Michael137 added a comment.

So one of the problems with constructing a more accurate AST is that we don't 
have enough information in DWARF to construct a unspecialised 
FunctionProtoType, i.e., `FunctionProtoType 0x1282fe870 'bool (T)'` as opposed 
to the current `FunctionProtoType 0x1282fe870 '_Bool (struct A::B)' cdecl`.

This was also noted in https://reviews.llvm.org/D61044

> creating the correct templated signature is just impossible. DWARF contains 
> the template parameter, but not their mapping to the actual function 
> signature. In the above example I know that foo has been parametrized by the 
> type ‘int’ (and that T was the template argument name), but I don’t know 
> whether the return type or the first argument were templated or plain ints…

E.g., here is an example DWARF entry for a template function:

  0x000001f8:     DW_TAG_subprogram
                    DW_AT_low_pc  (0x0000000100003f00)
                    DW_AT_high_pc (0x0000000100003f18)
                    DW_AT_APPLE_omit_frame_ptr    (true)
                    DW_AT_frame_base      (DW_OP_reg31 WSP)
                    DW_AT_linkage_name    
("_ZN1A10multiParamINS_1BEiEEbT_T0_S1_")
                    DW_AT_name    ("multiParam<A::B, int>")
                    DW_AT_decl_file       ("adl.cpp")
                    DW_AT_decl_line       (34)
                    DW_AT_type    (0x000000000000007d "bool")
                    DW_AT_external        (true)
  
  0x00000215:       DW_TAG_formal_parameter
                      DW_AT_location      (DW_OP_fbreg +15)
                      DW_AT_name  ("p1")
                      DW_AT_decl_file     ("adl.cpp")
                      DW_AT_decl_line     (34)
                      DW_AT_type  (0x0000000000000089 "A::B")
  
  0x00000223:       DW_TAG_formal_parameter
                      DW_AT_location      (DW_OP_fbreg +8)
                      DW_AT_name  ("p2")
                      DW_AT_decl_file     ("adl.cpp")
                      DW_AT_decl_line     (34)
                      DW_AT_type  (0x0000000000000317 "int")
  
  0x00000231:       DW_TAG_formal_parameter
                      DW_AT_location      (DW_OP_fbreg +14)
                      DW_AT_name  ("p3")
                      DW_AT_decl_file     ("adl.cpp")
                      DW_AT_decl_line     (34)
                      DW_AT_type  (0x0000000000000089 "A::B")
  
  0x0000023f:       DW_TAG_template_type_parameter
                      DW_AT_type  (0x0000000000000089 "A::B")
                      DW_AT_name  ("First")
  
  0x00000248:       DW_TAG_template_type_parameter
                      DW_AT_type  (0x0000000000000317 "int")
                      DW_AT_name  ("Second")

Just from this we wouldn't be able to reconstruct the function prototype (which 
we need to create a more accurate `FunctionTemplateDecl`). Mainly we don't know 
whether the formal parameters are of a template parameter type or a concrete 
type. Maybe someone has an idea of how to get the function prototype through 
other means at the point where we need to create the `FunctionTemplateDecl`, 
but I didn't manage to yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131335

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

Reply via email to