<p dir="ltr">On Nov 25, 2015 9:41 AM, "Daniel Dilts via cfe-dev" <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
> I have an AST matcher that is matching calls to a variadic function.  The types of the expressions are really confusing me, though.<br>
><br>
> The call expression that is matched is:<br>
> log.Log<DebugLevel::error>("Some string", static_cast<const MyType>(5))<br>
><br>
> The argument expression that is matched is:<br>
> static_cast<const MyType>(5)<br>
><br>
> MyType is a typedef.  Depending on what MyType is I get odd results.<br>
><br>
> 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".<br>
><br>
> So, what I am getting is:<br>
> int->MyType->int<br>
> bool->int->int<br>
> float->double->double<br>
> char->int->int<br>
><br>
> 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)?</p>
<p dir="ltr">What you're seeing is the type of the argument after conversation to the parameter type. Try</p>
<p dir="ltr">  callExpr->getArg(1)->IgnoreImplicit()->getType().getAsString()<br>
 _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
><br>
</p>