<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div>Dear all,</div>
<div><br>
</div>
<div></div>
<span>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).</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span><span>On the other hand, clang did not delete constructor when structure declared with variable (not a pointer) as structure "Item2" in the
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255); display: inline !important">
below</span> example code.</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
<div></div>
<div><u>[Example Code]</u></div>
<div>
<div style="margin: 0px">
<table width="" style="border-collapse: collapse">
<tbody>
<tr style="background-color: rgb(255, 255, 255)">
<td style="width: 519px; border-width: 1px; border-style: solid; border-color: rgb(171, 171, 171)">
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
class DataSet<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
{<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
public:<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
struct Item<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
{<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
int info;<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
Item() {};</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
}* theitem;<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
struct Item2<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
{<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
int info; <span style="margin: 0px"> </span><br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
Item2() {};<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
} theitem2; <br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
int themax;<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
};<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"> </span><br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
int main() {<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
DataSet T;<br>
</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
return 0;</div>
<div style="margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
}</div>
</td>
</tr>
</tbody>
</table>
<br>
</div>
<div style="margin: 0px"></div>
</div>
<span>I can understand this clang's behavior (for optimization).<br>
</span>
<div>However, for research purposes, I need to keep constructor although structure declared with a structure pointer.<br>
</div>
<div><br>
</div>
<span>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)?</span>
<div></div>
<div>
<ul>
<li>I tried to forcibly insert constructor using "DeclareImplicitDefaultConstructor or DefineImplicitDefaultConstructor" and check other possible functions such as "ShouldDeleteSpecialMember" (in SemaDeclCXX.cpp). </li><li>However, I could not find an answer yet.</li></ul>
<div>Thank you very much.<br>
</div>
<div><br>
</div>
<div>Best regards,</div>
<div>Y. Jeon.</div>
</div>
</div>
</body>
</html>