[cfe-dev] Expression type unexpected

Daniel Dilts via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 25 09:41:36 PST 2015


I have an AST matcher that is matching calls to a variadic function.  The
types of the expressions are really confusing me, though.

The call expression that is matched is:
log.Log<DebugLevel::error>("Some string", static_cast<const MyType>(5))

The argument expression that is matched is:
static_cast<const MyType>(5)

MyType is a typedef.  Depending on what MyType is I get odd results.

If MyType is int, then I get callExpr->getArg(1)->getType().getAsString()
is "MyType", and
callExpr->getArg(1)->getType().getCanonicalType().getAsString() is "int".
I will express this as "int->MyType->int".

So, what I am getting is:
int->MyType->int
bool->int->int
float->double->double
char->int->int

It makes sense to me that int->MyType->int occurs.  Could someone explain
what I am missing, why I get these results, and how to get what I would
expect (X->MyType->X)?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151125/457c4e3c/attachment.html>


More information about the cfe-dev mailing list