Storing auto as well as actual data type for sub program

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Storing auto as well as actual data type for sub program

David Zarzycki via cfe-dev
Dear all,

I want to handle auto return type feature in the clang. The objective of this task is to store auto as the program return type in the declaration DIE and the actual return type in the definition DIE. Currently, clang only dumps actual return type in the declaration DIE. 
Based on my understanding I need two store two return types (auto for declaration and actual for definition). Is there any other way to tackle this scenario?

--
Thanking You
Awanish Pandey
PhD, CSE
IIT Kanpur

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Storing auto as well as actual data type for sub program

David Zarzycki via cfe-dev
Yep - given this source code:

struct foo {
  static auto f1();
};
auto foo::f1() {
  return 3;
}

The current LLVM IR generated is:
!7 = distinct !DISubprogram(name: "f1", linkageName: "_ZN3foo2f1Ev", scope: !8, file: !1, line: 4, type: !9, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !12, retainedNodes: !2)
!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", file: !1, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !2, identifier: "_ZTS3foo")
!9 = !DISubroutineType(types: !10)
!10 = !{!11}
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!12 = !DISubprogram(name: "f1", linkageName: "_ZN3foo2f1Ev", scope: !8, file: !1, line: 2, type: !9, scopeLine: 2, flags: DIFlagPrototyped | DIFlagStaticMember, spFlags: 0)

But instead of that, if we're going to support using DW_AT_unspecified_type for auto and emitting declarations of auto functions even if there's no definition available (which, again, I don't think is super important/necessary by any means), the DWARF should look like this:

!7 = distinct !DISubprogram(name: "f1", linkageName: "_ZN3foo2f1Ev", scope: !8, file: !1, line: 4, type: !9, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !12, retainedNodes: !2)
!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", file: !1, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !13, identifier: "_ZTS3foo")
!9 = !DISubroutineType(types: !10)
!10 = !{!11}
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!12 = !DISubprogram(name: "f1", linkageName: "_ZN3foo2f1Ev", scope: !8, file: !1, line: 2, type: !14, scopeLine: 2, flags: DIFlagPrototyped | DIFlagStaticMember, spFlags: 0)
!13 = !{!12}
!14 = !DISubroutineType(types: !15)
!15 = {!16}
!16 = DIBasicType(tag: DW_TAG_unspecified_type, name: "auto")

On Thu, Dec 26, 2019 at 10:11 PM Awanish Pandey via cfe-dev <[hidden email]> wrote:
Dear all,

I want to handle auto return type feature in the clang. The objective of this task is to store auto as the program return type in the declaration DIE and the actual return type in the definition DIE. Currently, clang only dumps actual return type in the declaration DIE. 
Based on my understanding I need two store two return types (auto for declaration and actual for definition). Is there any other way to tackle this scenario?

--
Thanking You
Awanish Pandey
PhD, CSE
IIT Kanpur
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev