<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi again,<br><br>I have carried out what I told you about taking the CXXMemberCallExpr node before calling "getSpellingLineNumber" (in case there is a parent of the MemberExpr object of this type). That worked, but I'm in doubt because I don't know wether this "patch" scales or not for other programs. Furthermore, I don't know if I should take care of other similar situations... <br><br><div><hr id="stopSpelling">From: mikhail.ramalho@gmail.com<br>Date: Mon, 29 Feb 2016 19:16:28 +0000<br>Subject: Re: [cfe-dev] FullSourceLoc, getSpellingLineNumber segmentation fault<br>To: pedretti_86@hotmail.com<br>CC: cfe-dev@lists.llvm.org<br><br><div dir="ltr">Hi,<div><br></div><div>I used to face a lot of crashes on this method, it would usually explode at some #__SSE2__ code in a static method called ComputeLineNumbers inside clang.</div><div><br></div><div>Are you using virtual files? Are you generating the AST more than once (I mean, calling Tool.BuildAST() more than once)?</div><div><br></div><div>I don't quite remember how I fixed, but I _think_ those two might have something to do with the problem.</div><div><br></div><div>Cheers,</div><div><br></div></div><div class="ecxgmail_extra"><br><div class="ecxgmail_quote">2016-02-29 18:22 GMT+00:00 victor via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span>:<br><blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex;">


<div><div dir="ltr">Hi,<br><br>Does somebody know what can make the method getSpellingLineNumber from FullSourceLoc to generate a segmentation fault?  <font style="font-size:12pt;" size="3">I'm using clang 3.6.</font><font style="font-size:12pt;" size="3"></font><br><br><a href="http://clang.llvm.org/doxygen/classclang_1_1FullSourceLoc.html#a52927fcf23cf662c209e5e996bf59917" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1FullSourceLoc.html#a52927fcf23cf662c209e5e996bf59917</a><br><br>Before using this method, I have checked that the FullSourceLoc is valid. This is the code:<br><br> if(loc.isValid()){
<br> <br>         if(!(loc.getFileID().isInvalid())){<br> <br>            if(Context->getSourceManager().getFileEntryForID(loc.getFileID()) != NULL){<br><br>                   unsigned int = loc.getSpellingLineNumber();<br>            }<br>         }<br>  }<br><br>I can't find anything special in the code which I'm using to check if my program works:<br><br>    void DeleteNode( XMLNode* node )    {<br>        node->_parent->DeleteChild( node );<br>    }<br><br>And this is the tree:<br><br><font style="font-size:10pt;" size="2">| | |-CXXMethodDecl 0x26b4090 <line:1576:5, line:1578:5> line:1576:10 DeleteNode 'void (class tinyxml2::XMLNode *)'</font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">| | | |-ParmVarDecl 0x26b4010 <col:22, col:31> col:31 used node 'class tinyxml2::XMLNode *'</font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">| | | |-CompoundStmt 0x26c9500 <col:38, line:1578:5></font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">| | | | `-CXXMemberCallExpr 0x26c94b8 <line:1577:9, col:42> 'void'</font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">| | | |   |-MemberExpr 0x26c9460 <col:9, col:24> '<bound member function type>' ->DeleteChild 0x2699420</font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">| | | |   | `-ImplicitCastExpr 0x26c9448 <col:9, col:15> 'class tinyxml2::XMLNode *' <LValueToRValue></font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">| | | |   |   `-MemberExpr 0x26c9418 <col:9, col:15> 'class tinyxml2::XMLNode *' lvalue ->_parent 0x269a310</font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">| | | |   |     `-ImplicitCastExpr 0x26c9400 <col:9> 'class tinyxml2::XMLNode *' <LValueToRValue></font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:10pt;" size="2">| | | |   |       `-DeclRefExpr 0x26c93d8 <col:9> 'class tinyxml2::XMLNode *' lvalue ParmVar 0x26b4010 'node' 'class tinyxml2::XMLNode *'</font><font style="font-size:10pt;" size="2"><br></font><font style="font-size:12pt;" size="3"><br></font><font style="font-size:12pt;" size="3">The object "loc" contains the location of the MemberExpr "_parent". </font><br><font style="font-size:12pt;" size="3"></font><br>Thanks.<br>                                         </div></div>
<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" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="ecxgmail_signature"><div dir="ltr"><div><br></div><div>Mikhail Ramalho.</div></div></div>
</div></div>                                          </div></body>
</html>