[cfe-dev] FullSourceLoc, getSpellingLineNumber segmentation fault

victor via cfe-dev cfe-dev at lists.llvm.org
Mon Feb 29 10:22:29 PST 2016


Hi,

Does somebody know what can make the method getSpellingLineNumber from FullSourceLoc to generate a segmentation fault?  I'm using clang 3.6.

http://clang.llvm.org/doxygen/classclang_1_1FullSourceLoc.html#a52927fcf23cf662c209e5e996bf59917

Before using this method, I have checked that the FullSourceLoc is valid. This is the code:

 if(loc.isValid()){
 
         if(!(loc.getFileID().isInvalid())){
 
            if(Context->getSourceManager().getFileEntryForID(loc.getFileID()) != NULL){

                   unsigned int = loc.getSpellingLineNumber();
            }
         }
  }

I can't find anything special in the code which I'm using to check if my program works:

    void DeleteNode( XMLNode* node )    {
        node->_parent->DeleteChild( node );
    }

And this is the tree:

| | |-CXXMethodDecl 0x26b4090 <line:1576:5, line:1578:5> line:1576:10 DeleteNode 'void (class tinyxml2::XMLNode *)'
| | | |-ParmVarDecl 0x26b4010 <col:22, col:31> col:31 used node 'class tinyxml2::XMLNode *'
| | | |-CompoundStmt 0x26c9500 <col:38, line:1578:5>
| | | | `-CXXMemberCallExpr 0x26c94b8 <line:1577:9, col:42> 'void'
| | | |   |-MemberExpr 0x26c9460 <col:9, col:24> '<bound member function type>' ->DeleteChild 0x2699420
| | | |   | `-ImplicitCastExpr 0x26c9448 <col:9, col:15> 'class tinyxml2::XMLNode *' <LValueToRValue>
| | | |   |   `-MemberExpr 0x26c9418 <col:9, col:15> 'class tinyxml2::XMLNode *' lvalue ->_parent 0x269a310
| | | |   |     `-ImplicitCastExpr 0x26c9400 <col:9> 'class tinyxml2::XMLNode *' <LValueToRValue>
| | | |   |       `-DeclRefExpr 0x26c93d8 <col:9> 'class tinyxml2::XMLNode *' lvalue ParmVar 0x26b4010 'node' 'class tinyxml2::XMLNode *'

The object "loc" contains the location of the MemberExpr "_parent". 

Thanks.
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160229/557cac62/attachment.html>


More information about the cfe-dev mailing list