Add fileid_iterator to SourceManager.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57878 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index 7d28db2..b41d708 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -454,6 +454,30 @@
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.
///