<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>I have to look into all these things and find the best way to do it as general as possible. Thanks, Richard.<br><br><div><hr id="stopSpelling">Date: Mon, 9 Nov 2015 16:37:11 -0800<br>Subject: Re: [cfe-dev] Strange type of an argument in CXXConstructExpr<br>From: richard@metafoo.co.uk<br>To: pedretti_86@hotmail.com<br>CC: cfe-dev@lists.llvm.org<br><br><div dir="ltr"><div class="ecxgmail_extra"><div class="ecxgmail_quote">On Mon, Nov 9, 2015 at 4:41 AM, victor <span dir="ltr"><<a href="mailto:pedretti_86@hotmail.com" target="_blank">pedretti_86@hotmail.com</a>></span> wrote:<br><blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex;">


<div><div dir="ltr">Thank you for your answer Richard. The goal is to know if there is another method (apart from the constructor) that could accept the same arguments provided in the calling. To that end, I was comparing the arguments in the calling with the parameters of other methods.<br><br>Is this the only case where the type obtained from the expression do not match with the type of the parameter? Maybe I should take the constructor declaration invoked instead of the constructor expression and compare the parameters of other methods directly with the constructor, but I can't remember if I opted for using the construction expression for any reason.</div></div></blockquote><div><br></div><div>There are lots of ways that another function could accept the same arguments but have different parameter types. If you want to check that, the right thing to do would be:</div><div>1) Strip off all the implicit conversions on the arguments (see Expr::IgnoreImplicit)</div><div>2) Try to build implicit conversion sequences from those stripped expressions to the type of each destination parameter (Sema::TryImplicitConversion)</div><div><br></div><div>Even that will not catch all cases. In particular, if you want to handle templates, you'll need to perform template argument deduction, and if you want to handle braced initializers as arguments, you'll need to convert various forms of initializer back to their syntactic forms (see TreeTransform::TransformInitializer for an idea of what's necessary there).</div><div><br></div><blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex;"><div><div dir="ltr"><div><div class="ecxhm ecxHOEnZb"><hr>Date: Sun, 8 Nov 2015 12:24:09 -0800<br>Subject: Re: [cfe-dev] Strange type of an argument in CXXConstructExpr<br>From: <a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a><br>To: <a href="mailto:pedretti_86@hotmail.com" target="_blank">pedretti_86@hotmail.com</a><br>CC: <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a></div><div><div class="h5"><br><br><p dir="ltr">Expressions in C++ never have reference type. You can use getValueKind() to find if the expression is an lvalue or an rvalue. What is the problem you're trying to solve here?</p>
<div>On Nov 8, 2015 6:30 AM, "victor via cfe-dev" <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br><blockquote style="border-left:1px #ccc solid;padding-left:1ex;">


<div><div dir="ltr">Hi everyone,<br><br>Today I noticed an unusual behavior when using 
Clang. I found that the type of one of the arguments in a 
CXXConstructExpr was different from the type that I expected.<br><br>This is the fragment of code:<br><br>void QDomAttrPrivate::setNodeValue(const QString& v)<br>{<br>    <b>QDomTextPrivate *t = new QDomTextPrivate(0, this, v);</b><br>    ....<br>}<br><br>The invoked constructor is:<br><i>QDomTextPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& val);</i><br><br>and this is the related AST:<br><br><font style="font-size:10pt;" size="2">|   |-DeclStmt 0x7f67b329cdb8 <line:4108:5, col:57></font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">|   | `-VarDecl 0x7f67b329c7f0 <col:5, col:56> t 'class QDomTextPrivate *'</font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">|   |   `-CXXNewExpr 0x7f67b329cd60 <col:26, col:56> 'class QDomTextPrivate *'</font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">|  
 |     `-CXXConstructExpr 0x7f67b329cd18 <col:30, col:56> 'class 
QDomTextPrivate' 'void (class QQDomDocumentPrivate *, class 
QDomNodePrivate *, const class QString &)'</font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">|   |       |-ImplicitCastExpr 0x7f67b329cce0 <col:46> 'class QQDomDocumentPrivate *' <NullToPointer></font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">|   |       | `-IntegerLiteral 0x7f67b329c848 <col:46> 'int' 0</font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">|   |       |-ImplicitCastExpr 0x7f67b329ccf8 <col:49> 'class QDomNodePrivate *' <DerivedToBase (QDomNodePrivate)></font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">|   |       | `-CXXThisExpr 0x7f67b329c868 <col:49> 'class QDomAttrPrivate *' this</font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">|   |       `-DeclRefExpr 0x7f67b329c880 <col:55> '<b>const class QString</b>' lvalue ParmVar 0x7f67b329c560 'v' '<b>const class QString &</b>'</font><font style="font-size:8pt;" size="1"><br></font><font style="font-size:8pt;" size="1"><br></font>What<span> I</span><span> find</span><span> strange</span>
 is that the type of the ParmVar 'v' loses the '&'. The problem is 
that, when I compare the "getType()" of the third argument in the 
CXXConstructExpr (1) and the "getType()" of the third parameter of the 
constructor (2), the types do not match:<br><br>(1) const class QString<br>(2) const class QString &<br><br>Why is this happening? And what's more important, how do I sort out this issue? <br><br>Thanks.                                         </div></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div></div></div></div>                                     </div></div>
</blockquote></div><br></div></div></div>                                     </div></body>
</html>