Add fileid_iterator to SourceManager.

llvm-svn: 57878
This commit is contained in:
Ted Kremenek 2008-10-21 03:32:32 +00:00
parent 4e0f205145
commit d346dfe881
1 changed files with 24 additions and 0 deletions

View File

@ -454,6 +454,30 @@ public:
return getFIDInfo(getPhysicalLoc(Loc).getFileID())->getFileCharacteristic();
}
// Iterators over FileIDs.
class fileid_iterator {
std::vector<SrcMgr::FileIDInfo>::iterator I;
unsigned fid;
public:
fileid_iterator(std::vector<SrcMgr::FileIDInfo>::iterator i, unsigned f)
: I(i), fid(f) {}
bool operator==(const fileid_iterator& X) const { return X.fid == fid; }
bool operator!=(const fileid_iterator& X) const { return X.fid != fid; }
fileid_iterator& operator++() { ++fid; ++I; return *this; }
unsigned getFileID() const { return fid; }
SrcMgr::FileIDInfo& getFileIDInfo() { return *I; }
};
fileid_iterator fileid_begin() {
return fileid_iterator(FileIDs.begin(), 1);
}
fileid_iterator fileid_end() {
return fileid_iterator(FileIDs.end(), FileIDs.size()+1);
}
/// PrintStats - Print statistics to stderr.
///