#include "clang/Basic/SourceManager.h"
#include "clang/Basic/SourceManagerInternals.h"
#include "clang/Basic/FileManager.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/System/Path.h"
#include "llvm/Support/Streams.h"
#include <algorithm>
#include <iostream>
using namespace clang;
using namespace SrcMgr;
using llvm::MemoryBuffer;
ContentCache::~ContentCache() {
delete Buffer;
}
unsigned ContentCache::getSizeBytesMapped() const {
return Buffer ? Buffer->getBufferSize() : 0;
}
unsigned ContentCache::getSize() const {
return Entry ? Entry->getSize() : Buffer->getBufferSize();
}
const llvm::MemoryBuffer *ContentCache::getBuffer() const {
if (!Buffer && Entry) {
Buffer = MemoryBuffer::getFile(Entry->getName(), 0, Entry->getSize());
}
return Buffer;
}
unsigned LineTableInfo::getLineTableFilenameID(const char *Ptr, unsigned Len) {
llvm::StringMapEntry<unsigned> &Entry =
FilenameIDs.GetOrCreateValue(Ptr, Ptr+Len, ~0U);
if (Entry.getValue() != ~0U)
return Entry.getValue();
Entry.setValue(FilenamesByID.size());
FilenamesByID.push_back(&Entry);
return FilenamesByID.size()-1;
}
void LineTableInfo::AddLineNote(unsigned FID, unsigned Offset,
unsigned LineNo, int FilenameID) {
std::vector<LineEntry> &Entries = LineEntries[FID];
assert((Entries.empty() || Entries.back().FileOffset < Offset) &&
"Adding line entries out of order!");
SrcMgr::CharacteristicKind Kind = SrcMgr::C_User;
unsigned IncludeOffset = 0;
if (!Entries.empty()) {
if (FilenameID == -1)
FilenameID = Entries.back().FilenameID;
Kind = Entries.back().FileKind;
IncludeOffset = Entries.back().IncludeOffset;
}
Entries.push_back(LineEntry::get(Offset, LineNo, FilenameID, Kind,
IncludeOffset));
}
void LineTableInfo::AddLineNote(unsigned FID, unsigned Offset,
unsigned LineNo, int FilenameID,
unsigned EntryExit,
SrcMgr::CharacteristicKind FileKind) {
assert(FilenameID != -1 && "Unspecified filename should use other accessor");
std::vector<LineEntry> &Entries = LineEntries[FID];
assert((Entries.empty() || Entries.back().FileOffset < Offset) &&
"Adding line entries out of order!");
unsigned IncludeOffset = 0;
if (EntryExit == 0) { IncludeOffset = Entries.empty() ? 0 : Entries.back().IncludeOffset;
} else if (EntryExit == 1) {
IncludeOffset = Offset-1;
} else if (EntryExit == 2) {
assert(!Entries.empty() && Entries.back().IncludeOffset &&
"PPDirectives should have caught case when popping empty include stack");
IncludeOffset = 0;
if (const LineEntry *PrevEntry =
FindNearestLineEntry(FID, Entries.back().IncludeOffset))
IncludeOffset = PrevEntry->IncludeOffset;
}
Entries.push_back(LineEntry::get(Offset, LineNo, FilenameID, FileKind,
IncludeOffset));
}
const LineEntry *LineTableInfo::FindNearestLineEntry(unsigned FID,
unsigned Offset) {
const std::vector<LineEntry> &Entries = LineEntries[FID];
assert(!Entries.empty() && "No #line entries for this FID after all!");
if (Entries.back().FileOffset <= Offset)
return &Entries.back();
std::vector<LineEntry>::const_iterator I =
std::upper_bound(Entries.begin(), Entries.end(), Offset);
if (I == Entries.begin()) return 0;
return &*--I;
}
void LineTableInfo::AddEntry(unsigned FID,
const std::vector<LineEntry> &Entries) {
LineEntries[FID] = Entries;
}
unsigned SourceManager::getLineTableFilenameID(const char *Ptr, unsigned Len) {
if (LineTable == 0)
LineTable = new LineTableInfo();
return LineTable->getLineTableFilenameID(Ptr, Len);
}
void SourceManager::AddLineNote(SourceLocation Loc, unsigned LineNo,
int FilenameID) {
std::pair<FileID, unsigned> LocInfo = getDecomposedInstantiationLoc(Loc);
const SrcMgr::FileInfo &FileInfo = getSLocEntry(LocInfo.first).getFile();
const_cast<SrcMgr::FileInfo&>(FileInfo).setHasLineDirectives();
if (LineTable == 0)
LineTable = new LineTableInfo();
LineTable->AddLineNote(LocInfo.first.ID, LocInfo.second, LineNo, FilenameID);
}
void SourceManager::AddLineNote(SourceLocation Loc, unsigned LineNo,
int FilenameID, bool IsFileEntry,
bool IsFileExit, bool IsSystemHeader,
bool IsExternCHeader) {
if (FilenameID == -1) {
assert(!IsFileEntry && !IsFileExit && !IsSystemHeader && !IsExternCHeader &&
"Can't set flags without setting the filename!");
return AddLineNote(Loc, LineNo, FilenameID);
}
std::pair<FileID, unsigned> LocInfo = getDecomposedInstantiationLoc(Loc);
const SrcMgr::FileInfo &FileInfo = getSLocEntry(LocInfo.first).getFile();
const_cast<SrcMgr::FileInfo&>(FileInfo).setHasLineDirectives();
if (LineTable == 0)
LineTable = new LineTableInfo();
SrcMgr::CharacteristicKind FileKind;
if (IsExternCHeader)
FileKind = SrcMgr::C_ExternCSystem;
else if (IsSystemHeader)
FileKind = SrcMgr::C_System;
else
FileKind = SrcMgr::C_User;
unsigned EntryExit = 0;
if (IsFileEntry)
EntryExit = 1;
else if (IsFileExit)
EntryExit = 2;
LineTable->AddLineNote(LocInfo.first.ID, LocInfo.second, LineNo, FilenameID,
EntryExit, FileKind);
}
LineTableInfo &SourceManager::getLineTable() {
if (LineTable == 0)
LineTable = new LineTableInfo();
return *LineTable;
}
SourceManager::~SourceManager() {
delete LineTable;
for (unsigned i = 0, e = MemBufferInfos.size(); i != e; ++i) {
MemBufferInfos[i]->~ContentCache();
ContentCacheAlloc.Deallocate(MemBufferInfos[i]);
}
for (llvm::DenseMap<const FileEntry*, SrcMgr::ContentCache*>::iterator
I = FileInfos.begin(), E = FileInfos.end(); I != E; ++I) {
I->second->~ContentCache();
ContentCacheAlloc.Deallocate(I->second);
}
}
void SourceManager::clearIDTables() {
MainFileID = FileID();
SLocEntryTable.clear();
LastLineNoFileIDQuery = FileID();
LastLineNoContentCache = 0;
LastFileIDLookup = FileID();
if (LineTable)
LineTable->clear();
NextOffset = 0;
createInstantiationLoc(SourceLocation(),SourceLocation(),SourceLocation(), 1);
}
const ContentCache *
SourceManager::getOrCreateContentCache(const FileEntry *FileEnt) {
assert(FileEnt && "Didn't specify a file entry to use?");
ContentCache *&Entry = FileInfos[FileEnt];
if (Entry) return Entry;
unsigned EntryAlign = llvm::AlignOf<ContentCache>::Alignment;
EntryAlign = std::max(8U, EntryAlign);
Entry = ContentCacheAlloc.Allocate<ContentCache>(1, EntryAlign);
new (Entry) ContentCache(FileEnt);
return Entry;
}
const ContentCache*
SourceManager::createMemBufferContentCache(const MemoryBuffer *Buffer) {
unsigned EntryAlign = llvm::AlignOf<ContentCache>::Alignment;
EntryAlign = std::max(8U, EntryAlign);
ContentCache *Entry = ContentCacheAlloc.Allocate<ContentCache>(1, EntryAlign);
new (Entry) ContentCache();
MemBufferInfos.push_back(Entry);
Entry->setBuffer(Buffer);
return Entry;
}
void SourceManager::PreallocateSLocEntries(ExternalSLocEntrySource *Source,
unsigned NumSLocEntries,
unsigned NextOffset) {
ExternalSLocEntries = Source;
this->NextOffset = NextOffset;
SLocEntryLoaded.resize(NumSLocEntries + 1);
SLocEntryLoaded[0] = true;
SLocEntryTable.resize(SLocEntryTable.size() + NumSLocEntries);
}
void SourceManager::ClearPreallocatedSLocEntries() {
unsigned I = 0;
for (unsigned N = SLocEntryLoaded.size(); I != N; ++I)
if (!SLocEntryLoaded[I])
break;
if (I == SLocEntryLoaded.size())
return;
SLocEntryTable.resize(I);
SLocEntryLoaded.clear();
ExternalSLocEntries = 0;
}
FileID SourceManager::createFileID(const ContentCache *File,
SourceLocation IncludePos,
SrcMgr::CharacteristicKind FileCharacter,
unsigned PreallocatedID,
unsigned Offset) {
SLocEntry NewEntry = SLocEntry::get(NextOffset,
FileInfo::get(IncludePos, File,
FileCharacter));
if (PreallocatedID) {
assert(PreallocatedID < SLocEntryLoaded.size() &&
"Preallocate ID out-of-range");
assert(!SLocEntryLoaded[PreallocatedID] &&
"Source location entry already loaded");
assert(Offset && "Preallocate source location cannot have zero offset");
SLocEntryTable[PreallocatedID]
= SLocEntry::get(Offset, FileInfo::get(IncludePos, File, FileCharacter));
SLocEntryLoaded[PreallocatedID] = true;
return LastFileIDLookup = FileID::get(PreallocatedID);
}
SLocEntryTable.push_back(SLocEntry::get(NextOffset,
FileInfo::get(IncludePos, File,
FileCharacter)));
unsigned FileSize = File->getSize();
assert(NextOffset+FileSize+1 > NextOffset && "Ran out of source locations!");
NextOffset += FileSize+1;
return LastFileIDLookup = FileID::get(SLocEntryTable.size()-1);
}
SourceLocation SourceManager::createInstantiationLoc(SourceLocation SpellingLoc,
SourceLocation ILocStart,
SourceLocation ILocEnd,
unsigned TokLength,
unsigned PreallocatedID,
unsigned Offset) {
InstantiationInfo II = InstantiationInfo::get(ILocStart,ILocEnd, SpellingLoc);
if (PreallocatedID) {
assert(PreallocatedID < SLocEntryLoaded.size() &&
"Preallocate ID out-of-range");
assert(!SLocEntryLoaded[PreallocatedID] &&
"Source location entry already loaded");
assert(Offset && "Preallocate source location cannot have zero offset");
SLocEntryTable[PreallocatedID] = SLocEntry::get(Offset, II);
SLocEntryLoaded[PreallocatedID] = true;
return SourceLocation::getMacroLoc(Offset);
}
SLocEntryTable.push_back(SLocEntry::get(NextOffset, II));
assert(NextOffset+TokLength+1 > NextOffset && "Ran out of source locations!");
NextOffset += TokLength+1;
return SourceLocation::getMacroLoc(NextOffset-(TokLength+1));
}
std::pair<const char*, const char*>
SourceManager::getBufferData(FileID FID) const {
const llvm::MemoryBuffer *Buf = getBuffer(FID);
return std::make_pair(Buf->getBufferStart(), Buf->getBufferEnd());
}
FileID SourceManager::getFileIDSlow(unsigned SLocOffset) const {
assert(SLocOffset && "Invalid FileID");
std::vector<SrcMgr::SLocEntry>::const_iterator I;
if (SLocEntryTable[LastFileIDLookup.ID].getOffset() < SLocOffset) {
I = SLocEntryTable.end();
} else {
I = SLocEntryTable.begin()+LastFileIDLookup.ID;
}
unsigned NumProbes = 0;
while (1) {
--I;
if (ExternalSLocEntries)
getSLocEntry(FileID::get(I - SLocEntryTable.begin()));
if (I->getOffset() <= SLocOffset) {
#if 0
printf("lin %d -> %d [%s] %d %d\n", SLocOffset,
I-SLocEntryTable.begin(),
I->isInstantiation() ? "inst" : "file",
LastFileIDLookup.ID, int(SLocEntryTable.end()-I));
#endif
FileID Res = FileID::get(I-SLocEntryTable.begin());
if (!I->isInstantiation())
LastFileIDLookup = Res;
NumLinearScans += NumProbes+1;
return Res;
}
if (++NumProbes == 8)
break;
}
unsigned GreaterIndex = I-SLocEntryTable.begin();
unsigned LessIndex = 0;
NumProbes = 0;
while (1) {
unsigned MiddleIndex = (GreaterIndex-LessIndex)/2+LessIndex;
unsigned MidOffset = getSLocEntry(FileID::get(MiddleIndex)).getOffset();
++NumProbes;
if (MidOffset > SLocOffset) {
GreaterIndex = MiddleIndex;
continue;
}
if (isOffsetInFileID(FileID::get(MiddleIndex), SLocOffset)) {
#if 0
printf("bin %d -> %d [%s] %d %d\n", SLocOffset,
I-SLocEntryTable.begin(),
I->isInstantiation() ? "inst" : "file",
LastFileIDLookup.ID, int(SLocEntryTable.end()-I));
#endif
FileID Res = FileID::get(MiddleIndex);
if (!I->isInstantiation())
LastFileIDLookup = Res;
NumBinaryProbes += NumProbes;
return Res;
}
LessIndex = MiddleIndex;
}
}
SourceLocation SourceManager::
getInstantiationLocSlowCase(SourceLocation Loc) const {
do {
std::pair<FileID, unsigned> LocInfo = getDecomposedLoc(Loc);
Loc = getSLocEntry(LocInfo.first).getInstantiation()
.getInstantiationLocStart();
Loc = Loc.getFileLocWithOffset(LocInfo.second);
} while (!Loc.isFileID());
return Loc;
}
SourceLocation SourceManager::getSpellingLocSlowCase(SourceLocation Loc) const {
do {
std::pair<FileID, unsigned> LocInfo = getDecomposedLoc(Loc);
Loc = getSLocEntry(LocInfo.first).getInstantiation().getSpellingLoc();
Loc = Loc.getFileLocWithOffset(LocInfo.second);
} while (!Loc.isFileID());
return Loc;
}
std::pair<FileID, unsigned>
SourceManager::getDecomposedInstantiationLocSlowCase(const SrcMgr::SLocEntry *E,
unsigned Offset) const {
FileID FID;
SourceLocation Loc;
do {
Loc = E->getInstantiation().getInstantiationLocStart();
FID = getFileID(Loc);
E = &getSLocEntry(FID);
Offset += Loc.getOffset()-E->getOffset();
} while (!Loc.isFileID());
return std::make_pair(FID, Offset);
}
std::pair<FileID, unsigned>
SourceManager::getDecomposedSpellingLocSlowCase(const SrcMgr::SLocEntry *E,
unsigned Offset) const {
FileID FID;
SourceLocation Loc;
do {
Loc = E->getInstantiation().getSpellingLoc();
FID = getFileID(Loc);
E = &getSLocEntry(FID);
Offset += Loc.getOffset()-E->getOffset();
} while (!Loc.isFileID());
return std::make_pair(FID, Offset);
}
SourceLocation SourceManager::getImmediateSpellingLoc(SourceLocation Loc) const{
if (Loc.isFileID()) return Loc;
std::pair<FileID, unsigned> LocInfo = getDecomposedLoc(Loc);
Loc = getSLocEntry(LocInfo.first).getInstantiation().getSpellingLoc();
return Loc.getFileLocWithOffset(LocInfo.second);
}
std::pair<SourceLocation,SourceLocation>
SourceManager::getImmediateInstantiationRange(SourceLocation Loc) const {
assert(Loc.isMacroID() && "Not an instantiation loc!");
const InstantiationInfo &II = getSLocEntry(getFileID(Loc)).getInstantiation();
return II.getInstantiationLocRange();
}
std::pair<SourceLocation,SourceLocation>
SourceManager::getInstantiationRange(SourceLocation Loc) const {
if (Loc.isFileID()) return std::make_pair(Loc, Loc);
std::pair<SourceLocation,SourceLocation> Res =
getImmediateInstantiationRange(Loc);
while (!Res.first.isFileID())
Res.first = getImmediateInstantiationRange(Res.first).first;
while (!Res.second.isFileID())
Res.second = getImmediateInstantiationRange(Res.second).second;
return Res;
}
const char *SourceManager::getCharacterData(SourceLocation SL) const {
std::pair<FileID, unsigned> LocInfo = getDecomposedSpellingLoc(SL);
return getSLocEntry(LocInfo.first).getFile().getContentCache()
->getBuffer()->getBufferStart() + LocInfo.second;
}
unsigned SourceManager::getColumnNumber(FileID FID, unsigned FilePos) const {
const char *Buf = getBuffer(FID)->getBufferStart();
unsigned LineStart = FilePos;
while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r')
--LineStart;
return FilePos-LineStart+1;
}
unsigned SourceManager::getSpellingColumnNumber(SourceLocation Loc) const {
if (Loc.isInvalid()) return 0;
std::pair<FileID, unsigned> LocInfo = getDecomposedSpellingLoc(Loc);
return getColumnNumber(LocInfo.first, LocInfo.second);
}
unsigned SourceManager::getInstantiationColumnNumber(SourceLocation Loc) const {
if (Loc.isInvalid()) return 0;
std::pair<FileID, unsigned> LocInfo = getDecomposedInstantiationLoc(Loc);
return getColumnNumber(LocInfo.first, LocInfo.second);
}
static void ComputeLineNumbers(ContentCache* FI,
llvm::BumpPtrAllocator &Alloc) DISABLE_INLINE;
static void ComputeLineNumbers(ContentCache* FI, llvm::BumpPtrAllocator &Alloc){
const MemoryBuffer *Buffer = FI->getBuffer();
std::vector<unsigned> LineOffsets;
LineOffsets.push_back(0);
const unsigned char *Buf = (const unsigned char *)Buffer->getBufferStart();
const unsigned char *End = (const unsigned char *)Buffer->getBufferEnd();
unsigned Offs = 0;
while (1) {
const unsigned char *NextBuf = (const unsigned char *)Buf;
while (*NextBuf != '\n' && *NextBuf != '\r' && *NextBuf != '\0')
++NextBuf;
Offs += NextBuf-Buf;
Buf = NextBuf;
if (Buf[0] == '\n' || Buf[0] == '\r') {
if ((Buf[1] == '\n' || Buf[1] == '\r') && Buf[0] != Buf[1])
++Offs, ++Buf;
++Offs, ++Buf;
LineOffsets.push_back(Offs);
} else {
if (Buf == End) break;
++Offs, ++Buf;
}
}
FI->NumLines = LineOffsets.size();
FI->SourceLineCache = Alloc.Allocate<unsigned>(LineOffsets.size());
std::copy(LineOffsets.begin(), LineOffsets.end(), FI->SourceLineCache);
}
unsigned SourceManager::getLineNumber(FileID FID, unsigned FilePos) const {
ContentCache *Content;
if (LastLineNoFileIDQuery == FID)
Content = LastLineNoContentCache;
else
Content = const_cast<ContentCache*>(getSLocEntry(FID)
.getFile().getContentCache());
if (Content->SourceLineCache == 0)
ComputeLineNumbers(Content, ContentCacheAlloc);
unsigned *SourceLineCache = Content->SourceLineCache;
unsigned *SourceLineCacheStart = SourceLineCache;
unsigned *SourceLineCacheEnd = SourceLineCache + Content->NumLines;
unsigned QueriedFilePos = FilePos+1;
if (LastLineNoFileIDQuery == FID) {
if (QueriedFilePos >= LastLineNoFilePos) {
SourceLineCache = SourceLineCache+LastLineNoResult-1;
if (SourceLineCache+5 < SourceLineCacheEnd) {
if (SourceLineCache[5] > QueriedFilePos)
SourceLineCacheEnd = SourceLineCache+5;
else if (SourceLineCache+10 < SourceLineCacheEnd) {
if (SourceLineCache[10] > QueriedFilePos)
SourceLineCacheEnd = SourceLineCache+10;
else if (SourceLineCache+20 < SourceLineCacheEnd) {
if (SourceLineCache[20] > QueriedFilePos)
SourceLineCacheEnd = SourceLineCache+20;
}
}
}
} else {
SourceLineCacheEnd = SourceLineCache+LastLineNoResult+1;
}
}
if (0 && SourceLineCacheEnd-SourceLineCache > 20) {
unsigned FileLen = Content->SourceLineCache[Content->NumLines-1];
unsigned ApproxPos = Content->NumLines*QueriedFilePos / FileLen;
unsigned LowerBound = std::max(int(ApproxPos-10), 0);
unsigned UpperBound = std::min(ApproxPos+10, FileLen);
if (SourceLineCache < SourceLineCacheStart+LowerBound &&
SourceLineCacheStart[LowerBound] < QueriedFilePos)
SourceLineCache = SourceLineCacheStart+LowerBound;
if (SourceLineCacheEnd > SourceLineCacheStart+UpperBound &&
SourceLineCacheStart[UpperBound] >= QueriedFilePos)
SourceLineCacheEnd = SourceLineCacheStart+UpperBound;
}
unsigned *Pos
= std::lower_bound(SourceLineCache, SourceLineCacheEnd, QueriedFilePos);
unsigned LineNo = Pos-SourceLineCacheStart;
LastLineNoFileIDQuery = FID;
LastLineNoContentCache = Content;
LastLineNoFilePos = QueriedFilePos;
LastLineNoResult = LineNo;
return LineNo;
}
unsigned SourceManager::getInstantiationLineNumber(SourceLocation Loc) const {
if (Loc.isInvalid()) return 0;
std::pair<FileID, unsigned> LocInfo = getDecomposedInstantiationLoc(Loc);
return getLineNumber(LocInfo.first, LocInfo.second);
}
unsigned SourceManager::getSpellingLineNumber(SourceLocation Loc) const {
if (Loc.isInvalid()) return 0;
std::pair<FileID, unsigned> LocInfo = getDecomposedSpellingLoc(Loc);
return getLineNumber(LocInfo.first, LocInfo.second);
}
SrcMgr::CharacteristicKind
SourceManager::getFileCharacteristic(SourceLocation Loc) const {
assert(!Loc.isInvalid() && "Can't get file characteristic of invalid loc!");
std::pair<FileID, unsigned> LocInfo = getDecomposedInstantiationLoc(Loc);
const SrcMgr::FileInfo &FI = getSLocEntry(LocInfo.first).getFile();
if (!FI.hasLineDirectives())
return FI.getFileCharacteristic();
assert(LineTable && "Can't have linetable entries without a LineTable!");
const LineEntry *Entry =
LineTable->FindNearestLineEntry(LocInfo.first.ID, LocInfo.second);
if (!Entry)
return FI.getFileCharacteristic();
return Entry->FileKind;
}
const char *SourceManager::getBufferName(SourceLocation Loc) const {
if (Loc.isInvalid()) return "<invalid loc>";
return getBuffer(getFileID(Loc))->getBufferIdentifier();
}
PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc) const {
if (Loc.isInvalid()) return PresumedLoc();
std::pair<FileID, unsigned> LocInfo = getDecomposedInstantiationLoc(Loc);
const SrcMgr::FileInfo &FI = getSLocEntry(LocInfo.first).getFile();
const SrcMgr::ContentCache *C = FI.getContentCache();
const char *Filename =
C->Entry ? C->Entry->getName() : C->getBuffer()->getBufferIdentifier();
unsigned LineNo = getLineNumber(LocInfo.first, LocInfo.second);
unsigned ColNo = getColumnNumber(LocInfo.first, LocInfo.second);
SourceLocation IncludeLoc = FI.getIncludeLoc();
if (FI.hasLineDirectives()) {
assert(LineTable && "Can't have linetable entries without a LineTable!");
if (const LineEntry *Entry =
LineTable->FindNearestLineEntry(LocInfo.first.ID, LocInfo.second)) {
if (Entry->FilenameID != -1)
Filename = LineTable->getFilename(Entry->FilenameID);
unsigned MarkerLineNo = getLineNumber(LocInfo.first, Entry->FileOffset);
LineNo = Entry->LineNo + (LineNo-MarkerLineNo-1);
if (Entry->IncludeOffset) {
IncludeLoc = getLocForStartOfFile(LocInfo.first);
IncludeLoc = IncludeLoc.getFileLocWithOffset(Entry->IncludeOffset);
}
}
}
return PresumedLoc(Filename, LineNo, ColNo, IncludeLoc);
}
void SourceManager::PrintStats() const {
llvm::cerr << "\n*** Source Manager Stats:\n";
llvm::cerr << FileInfos.size() << " files mapped, " << MemBufferInfos.size()
<< " mem buffers mapped.\n";
llvm::cerr << SLocEntryTable.size() << " SLocEntry's allocated, "
<< NextOffset << "B of Sloc address space used.\n";
unsigned NumLineNumsComputed = 0;
unsigned NumFileBytesMapped = 0;
for (fileinfo_iterator I = fileinfo_begin(), E = fileinfo_end(); I != E; ++I){
NumLineNumsComputed += I->second->SourceLineCache != 0;
NumFileBytesMapped += I->second->getSizeBytesMapped();
}
llvm::cerr << NumFileBytesMapped << " bytes of files mapped, "
<< NumLineNumsComputed << " files with line #'s computed.\n";
llvm::cerr << "FileID scans: " << NumLinearScans << " linear, "
<< NumBinaryProbes << " binary.\n";
}
ExternalSLocEntrySource::~ExternalSLocEntrySource() { }