[cfe-dev] Strange type of an argument in CXXConstructExpr

victor via cfe-dev cfe-dev at lists.llvm.org
Sun Nov 8 06:30:23 PST 2015


Hi everyone,

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.

This is the fragment of code:

void QDomAttrPrivate::setNodeValue(const QString& v)
{
    QDomTextPrivate *t = new QDomTextPrivate(0, this, v);
    ....
}

The invoked constructor is:
QDomTextPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& val);

and this is the related AST:

|   |-DeclStmt 0x7f67b329cdb8 <line:4108:5, col:57>
|   | `-VarDecl 0x7f67b329c7f0 <col:5, col:56> t 'class QDomTextPrivate *'
|   |   `-CXXNewExpr 0x7f67b329cd60 <col:26, col:56> 'class QDomTextPrivate *'
|  
 |     `-CXXConstructExpr 0x7f67b329cd18 <col:30, col:56> 'class 
QDomTextPrivate' 'void (class QQDomDocumentPrivate *, class 
QDomNodePrivate *, const class QString &)'
|   |       |-ImplicitCastExpr 0x7f67b329cce0 <col:46> 'class QQDomDocumentPrivate *' <NullToPointer>
|   |       | `-IntegerLiteral 0x7f67b329c848 <col:46> 'int' 0
|   |       |-ImplicitCastExpr 0x7f67b329ccf8 <col:49> 'class QDomNodePrivate *' <DerivedToBase (QDomNodePrivate)>
|   |       | `-CXXThisExpr 0x7f67b329c868 <col:49> 'class QDomAttrPrivate *' this
|   |       `-DeclRefExpr 0x7f67b329c880 <col:55> 'const class QString' lvalue ParmVar 0x7f67b329c560 'v' 'const class QString &'

What I find strange
 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:

(1) const class QString
(2) const class QString &

Why is this happening? And what's more important, how do I sort out this issue? 

Thanks. 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151108/d51ccfb8/attachment.html>


More information about the cfe-dev mailing list