[cfe-dev] Where is default constructor delete function in clang?

Yuseok Jeon via cfe-dev cfe-dev at lists.llvm.org
Mon Mar 23 19:45:43 PDT 2020


Dear all,

I checked that clang deletes (checked IR code) structure's constructor when a structure is declared with a structure pointer (e.g., structure "Item" in the below example code).

On the other hand, clang did not delete constructor when structure declared with variable (not a pointer) as structure "Item2" in the below example code.

[Example Code]
class DataSet
{
public:
   struct Item
   {
      int  info;
      Item() {};
   }* theitem;

   struct Item2
   {
     int  info;
     Item2() {};
   } theitem2;

   int themax;
};

int main() {
  DataSet T;
  return 0;
}

I can understand this clang's behavior (for optimization).
However, for research purposes, I need to keep constructor although structure declared with a structure pointer.

If you don't mind, could you please advise how I find this optimization function (remove constructor) in clang (I plan to update this code)?

  *   I tried to forcibly insert constructor using "DeclareImplicitDefaultConstructor or DefineImplicitDefaultConstructor" and check other possible functions such as "ShouldDeleteSpecialMember" (in SemaDeclCXX.cpp).
  *   However, I could not find an answer yet.

Thank you very much.

Best regards,
Y. Jeon.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200324/59b89d3b/attachment.html>


More information about the cfe-dev mailing list