[cfe-commits] r57878 - /cfe/trunk/include/clang/Basic/SourceManager.h
Ted Kremenek
kremenek at apple.com
Mon Oct 20 20:32:32 PDT 2008
Author: kremenek
Date: Mon Oct 20 22:32:32 2008
New Revision: 57878
URL: http://llvm.org/viewvc/llvm-project?rev=57878&view=rev
Log:
Add fileid_iterator to SourceManager.
Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=57878&r1=57877&r2=57878&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Mon Oct 20 22:32:32 2008
@@ -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.
///
More information about the cfe-commits
mailing list