<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jan 14, 2015 at 12:05 PM, victor <span dir="ltr"><<a href="mailto:pedretti_86@hotmail.com" target="_blank">pedretti_86@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div dir="ltr">Hi everyone,<br><br>I have something like this in my code:<br><br><blockquote>for(CXXRecordDecl::friend_iterator fi=c1->friend_begin(); fi != c1->friend_end(); fi++){<br> <b>QualType qt = (*fi)->getFriendType()->getType()</b>;<br> ...<br>}<br></blockquote><br>When using this code to analyze the following "friend": <br><br><blockquote>inline <b>friend</b> QDebug operator<< (QDebug s, const Cursor& cursor)<br></blockquote><br>I get this segmentation fault:<br><br><blockquote>Program received signal SIGSEGV, Segmentation fault.<br>clang::TypeSourceInfo::getType (this=0x0) at /usr/local/include/clang/AST/Decl.h:66<br>66 QualType getType() const { return Ty; }<br></blockquote><br>I have been searching for this issue and found this bug (<a href="http://llvm.org/bugs/show_bug.cgi?id=7190#attach_4928" target="_blank"></a><a href="http://llvm.org/bugs/show_bug.cgi?id=7190#attach_4928)" target="_blank"></a><a href="http://llvm.org/bugs/show_bug.cgi?id=7190#attach_4928)" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=7190#attach_4928)</a>, where is said:<blockquote><pre>"In the attached testcase, clang will attempt to instantiate the friend decl which is invalid because <br>Derived has not been declared."</pre></blockquote>I think that maybe this is my problem,</div></div></blockquote><div><br></div><div>No, it's not. You're calling 'getFriendType()' on a FriendDecl that represents a friend function, not a friend type, so it returns nullptr. You then try to call 'getType()' on a null pointer.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="ltr">I mean, that the friend decl is invalid because it has not been declared. But, how can I avoid the launch of this signal? I cannot prevent the appearance of this situation and I don't want the program to terminate.<br><br>I hope you can help me with this. Thanks in advance.<br> </div></div>
<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></blockquote></div><br></div></div>