[cfe-dev] Assertion `Index < LocalSLocEntryTable.size() && "Invalid index"' failed.

Aditya Kumar hiraditya at msn.com
Mon Feb 27 11:29:07 PST 2012


What I am trying to do is print only those macros which are defined in the current file.So whenever the PPCallback function MacroDefined is called, I test if the presumed file name is same asthe file currently being processed. If it is then print macro identifier etc...
Relevant code is as follows...
    void MacroDefined(const Token &MacroNameTok, const MacroInfo* MI)    {      if(MacroIsLocal(MI->getDefinitionLoc())) {       //  if(MacroNameTok.getName()){         std::cout<<"Macro "<<MacroNameTok.getIdentifierInfo()->getNameStart()<<" is defined here\n\t";         //std::cout<<"Macro "<<tok::getTokenName(MacroNameTok.getKind())<<" is defined here\n\t";         if(MI->isFunctionLike())           std::cout<<"The macro is function like\n";         if(MI->isObjectLike())           std::cout<<"The macro is object like\n";       }     }         ///if the macro is local to the current file being processed     bool MacroIsLocal(SourceLocation loc)     {       /// the source manager can decode the SourceLocation information       PresumedLoc presumed = sm->getPresumedLoc(loc);//sm is the SourceManager for the current file       if(file_name == presumed.getFilename())         return true;       return false;     } 
When I do not call     `bool MacroIsLocal(SourceLocation loc)' It prints all the macros(including the predefined macros) without any errors. What could be the problem... or is there any other way to find out which macros are local to the file being processed.  
Thanks for the help.Aditya 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120227/ac787372/attachment.html>


More information about the cfe-dev mailing list