SourceManager invalid index error

   I am parsing a few files and using the following code to extract the
buffers for those files

*for (it = rewriter.buffer_begin(); it != rewriter.buffer_end(); it ++)
    const FileEntry* fileEntry =

   I keep getting the following error. Can you please explain what this
means and what might be causing this error. Thanks for your help.

*const clang::SrcMgr::SLocEntry&
clang::SourceManager::getLocalSLocEntry(unsigned int, bool*) const:
Assertion 'Index < LocalSLocEntryTable.size() && "Invalid Index"' failed.*

How did you create the rewriter? Is it using the same SourceManager as you're then using to get buffers? If not, keep in mind the FileIDs from one SourceManager don't mean anything to any other SourceManager.