This implements the DWARF 5 feature described at
http://www.dwarfstd.org/ShowIssue.php?issue=141215.1
This allows a consumer to understand whether a composite data type is
trivially copyable and thus should be passed by value instead of by
reference. The canonical example is being able to distinguish the
following two types:
// S is not trivially copyable because of the explicit destructor. struct S { ~S() {} }; // T is a POD type. struct T { ~T() = default; };
To avoid bloating the debug info with calling convention attributes,
this patch only adds them were the calling convention is not obvious
from the context.
Implicitly by value is everything that clearly looks like a C struct, i.e.:
- Non-C++ record types.
- Types that define none of destructor, copy/move constructor, copy/move assignment operator.
Implicitly by reference is everything clearly looks like a non-pod type:
- Types that define a destructor, a copy constructor, and a copy assignment operator.
I do not believe this is sufficient. Consider:
Now, A is passed indirectly, because it has a non-trivial copy constructor (A::A(A&)). But B is passed directly, because it only has a trivial copy constructor, despite having an A subobject.
I would not expect debuggers to get intricacies like this right. (In general, determining how to pass a class like B can require performing template instantiation, which it's clearly not reasonable to expect a debugger to do.)
If you want to give the debugger a hint for any type that's non-POD (as the comment says), then use CXXRecordDecl::isPOD to determine that. I think it is reasonable to believe that a debugger will figure out that objects of POD types are passed direct.