[cfe-dev] Invalid FriendDecl

victor pedretti_86 at hotmail.com
Wed Jan 14 12:05:28 PST 2015


Hi everyone,

I have something like this in my code:

for(CXXRecordDecl::friend_iterator fi=c1->friend_begin(); fi != c1->friend_end(); fi++){
   QualType qt = (*fi)->getFriendType()->getType();
   ...
}

When using this code to analyze the following "friend": 

inline friend QDebug operator<< (QDebug s, const Cursor& cursor)

I get this segmentation fault:

Program received signal SIGSEGV, Segmentation fault.
clang::TypeSourceInfo::getType (this=0x0) at /usr/local/include/clang/AST/Decl.h:66
66        QualType getType() const { return Ty; }

I have been searching for this issue and found this bug (http://llvm.org/bugs/show_bug.cgi?id=7190#attach_4928), where is said:"In the attached testcase, clang will attempt to instantiate the friend decl which is invalid because 
Derived has not been declared."I think that maybe this is my problem, 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.

I hope you can help me with this. Thanks in advance.
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150114/77840a6c/attachment.html>


More information about the cfe-dev mailing list