diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-10-30 22:57:35 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-10-30 22:57:35 +0000 |
commit | 0d892d8bfddd4916cc4f3467e1184a623d0716da (patch) | |
tree | fe1592f2324642af2e6cba1f48b5f7067d50f4a2 /include/clang/Basic/SourceManager.h | |
parent | 7da36f642e907ff5a5ba4b18b5bfebfabf36ecc7 (diff) |
Updated some comments.
Disabled assignments for ContentCache.
Copy-ctor for ContentCache now has an assertion preventing it to
be copied from an object that already has an allocated buffer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43526 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r-- | include/clang/Basic/SourceManager.h | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 9c687c3e65..6392e899e3 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -58,6 +58,22 @@ namespace SrcMgr { : Entry(e), Buffer(NULL), SourceLineCache(NULL), NumLines(0) {} ~ContentCache(); + + /// The copy ctor does not allow copies where source object has either + /// a non-NULL Buffer or SourceLineCache. Ownership of allocated memory + /// is not transfered, so this is a logical error. + ContentCache(const ContentCache& RHS) : Buffer(NULL),SourceLineCache(NULL) { + Entry = RHS.Entry; + + assert (RHS.Buffer == NULL && RHS.SourceLineCache == NULL + && "Passed ContentCache object cannot own a buffer."); + + NumLines = RHS.NumLines; + } + + private: + // Disable assignments. + ContentCache& operator=(const ContentCache& RHS); }; /// FileIDInfo - Information about a FileID, basically just the logical file @@ -74,9 +90,9 @@ namespace SrcMgr { /// This information encodes the #include chain that a token was instantiated /// from. /// - /// FileIDInfos contain a "InfoRec *", describing the source file, and a Chunk - /// number, which allows a SourceLocation to index into very large files - /// (those which there are not enough FilePosBits to address). + /// FileIDInfos contain a "ContentCache *", describing the source file, + /// and a Chunk number, which allows a SourceLocation to index into very + /// large files (those which there are not enough FilePosBits to address). /// struct FileIDInfo { private: @@ -158,12 +174,15 @@ namespace clang { /// etc. class SourceManager { /// FileInfos - Memoized information about all of the files tracked by this - /// SourceManager. + /// SourceManager. This set allows us to merge ContentCache entries based + /// on their FileEntry*. All ContentCache objects will thus have unique, + /// non-null, FileEntry pointers. std::set<SrcMgr::ContentCache> FileInfos; /// MemBufferInfos - Information about various memory buffers that we have /// read in. This is a list, instead of a vector, because we need pointers to - /// the FileInfo objects to be stable. + /// the FileInfo objects to be stable. All FileEntry* within the + /// stored ContentCache objects are NULL, as they do not refer to a file. std::list<SrcMgr::ContentCache> MemBufferInfos; /// FileIDs - Information about each FileID. FileID #0 is not valid, so all |