<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Yes, use cast_or_null. Other AST getters do the same thing.</div><div class="gmail_quote"><br></div><div class="gmail_quote">On Thu, Aug 14, 2014 at 3:34 PM, Keno Fischer <span dir="ltr"><<a href="mailto:kfischer@college.harvard.edu" target="_blank">kfischer@college.harvard.edu</a>></span> wrote:<br>
</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">So, I believe the seg fault is actually it trying to dyn_cast a NULL<br>
expr inside getArg(N). Should I adjust getArg to return NULL in that<br>
case?<br>
<br>
On Thu, Aug 14, 2014 at 6:32 PM, Keno Fischer<br>
<div class="HOEnZb"><div class="h5"><<a href="mailto:kfischer@college.harvard.edu">kfischer@college.harvard.edu</a>> wrote:<br>
> Sounds good, I'll draft up a patch.<br>
><br>
> On Thu, Aug 14, 2014 at 6:31 PM, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br>
>> I vote for making getLocStart() / getLocEnd() check that getArg(N) is not<br>
>> null before pulling the location from it. If we have a setter that nulls out<br>
>> subexprs, then it seems like the class should tolerate null subexprs in<br>
>> other methods.<br>
>><br>
>><br>
>> On Thu, Aug 14, 2014 at 1:23 PM, Keno Fischer <<a href="mailto:kfischer@college.harvard.edu">kfischer@college.harvard.edu</a>><br>
>> wrote:<br>
>>><br>
>>> Hello,<br>
>>><br>
>>> when the CallExpr passed to Sema::ConvertArgumentsForCall has all<br>
>>> default parameters, and the number of actual arguments passed is zero,<br>
>>> this function will segfault in the call to Call->getLocStart() if the<br>
>>> Callee has an invalid getLocStart(), the reason being that since<br>
>>> ConvertArgumentsForCall has set the correct number of arguments, but<br>
>>> has not filled them in yet, getLocStart() will try to access the first<br>
>>> (not yet existent) argument and thus segfaults. One possible fix is to<br>
>>> move the call to Call->getLocStart() before the adjustment of the<br>
>>> number of function arguments. Does anybody see something better? It<br>
>>> seems to me that this shouldn't segfault even on an invalid location,<br>
>>> since getLocStart even explicitly checks for the 0 argument case.<br>
>>><br>
>>> Thanks,<br>
>>> Keno<br>
>>> _______________________________________________<br>
>>> cfe-dev mailing list<br>
>>> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
>>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
>><br>
>><br>
</div></div></blockquote></div><br></div></div>