diff options
author | Eric Christopher <echristo@apple.com> | 2011-09-08 23:28:19 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2011-09-08 23:28:19 +0000 |
commit | 5330ee071743b8a896aa46979b020e6c3ca9b1cc (patch) | |
tree | d24d5ed4b036952ad13c0d505d77b08fec96cff9 /include/clang/Basic/SourceManager.h | |
parent | e02e5e2b055dbb3c18229b5cf6b831270c51dd4c (diff) |
Rearrange comment slightly for Bill.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139333 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r-- | include/clang/Basic/SourceManager.h | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index d1d2a91681..7ddc887edc 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -37,7 +37,7 @@ class LineTableInfo; class LangOptions; class ASTWriter; class ASTReader; - + /// There are three different types of locations in a file: a spelling /// location, an expansion location, and a presumed location. /// @@ -45,8 +45,8 @@ class ASTReader; /// #define min(x, y) x < y ? x : y /// /// and then later on a use of min: -/// return min(a, b); /// #line 17 +/// return min(a, b); /// /// The expansion location is the line in the source code where the macro /// was expanded (the return statement), the spelling location is the @@ -77,7 +77,7 @@ namespace SrcMgr { /// \brief Whether the buffer should not be freed on destruction. DoNotFreeFlag = 0x02 }; - + /// Buffer - The actual buffer containing the characters from the input /// file. This is owned by the ContentCache object. /// The bits indicate indicates whether the buffer is invalid. @@ -113,7 +113,7 @@ namespace SrcMgr { /// /// \param Diag Object through which diagnostics will be emitted if the /// buffer cannot be retrieved. - /// + /// /// \param Loc If specified, is the location that invalid file diagnostics /// will be emitted at. /// @@ -133,7 +133,7 @@ namespace SrcMgr { /// this ContentCache. This can be 0 if the MemBuffer was not actually /// expanded. unsigned getSizeBytesMapped() const; - + /// Returns the kind of memory used to back the memory buffer for /// this content cache. This is used for performance analysis. llvm::MemoryBuffer::BufferKind getMemoryBufferKind() const; @@ -143,7 +143,7 @@ namespace SrcMgr { Buffer.setPointer(B); Buffer.setInt(false); } - + /// \brief Get the underlying buffer, returning NULL if the buffer is not /// yet available. const llvm::MemoryBuffer *getRawBuffer() const { @@ -158,12 +158,12 @@ namespace SrcMgr { bool isBufferInvalid() const { return Buffer.getInt() & InvalidFlag; } - + /// \brief Determine whether the buffer should be freed. bool shouldFreeBuffer() const { return (Buffer.getInt() & DoNotFreeFlag) == 0; } - + ContentCache(const FileEntry *Ent = 0) : Buffer(0, false), OrigEntry(Ent), ContentsEntry(Ent), SourceLineCache(0), NumLines(0), MacroArgsCache(0) {} @@ -177,7 +177,7 @@ namespace SrcMgr { /// The copy ctor does not allow copies where source object has either /// a non-NULL Buffer or SourceLineCache. Ownership of allocated memory /// is not transferred, so this is a logical error. - ContentCache(const ContentCache &RHS) + ContentCache(const ContentCache &RHS) : Buffer(0, false), SourceLineCache(0), MacroArgsCache(0) { OrigEntry = RHS.OrigEntry; @@ -393,7 +393,7 @@ public: /// entry from being loaded. virtual bool ReadSLocEntry(int ID) = 0; }; - + /// IsBeforeInTranslationUnitCache - This class holds the cache used by /// isBeforeInTranslationUnit. The cache structure is complex enough to be @@ -410,20 +410,20 @@ class IsBeforeInTranslationUnitCache { /// CommonFID - This is the file found in common between the two #include /// traces. It is the nearest common ancestor of the #include tree. FileID CommonFID; - + /// L/R CommonOffset - This is the offset of the previous query in CommonFID. /// Usually, this represents the location of the #include for QueryFID, but if /// LQueryFID is a parent of RQueryFID (or vise versa) then these can be a /// random token in the parent. unsigned LCommonOffset, RCommonOffset; public: - + /// isCacheValid - Return true if the currently cached values match up with /// the specified LHS/RHS query. If not, we can't use the cache. bool isCacheValid(FileID LHS, FileID RHS) const { return LQueryFID == LHS && RQueryFID == RHS; } - + /// getCachedResult - If the cache is valid, compute the result given the /// specified offsets in the LHS/RHS FID's. bool getCachedResult(unsigned LOffset, unsigned ROffset) const { @@ -440,7 +440,7 @@ public: return LOffset < ROffset; } - + // Set up a new query. void setQueryFIDs(FileID LHS, FileID RHS, bool isLFIDBeforeRFID) { assert(LHS != RHS); @@ -453,14 +453,14 @@ public: LQueryFID = RQueryFID = FileID(); IsLQFIDBeforeRQFID = false; } - + void setCommonLoc(FileID commonFID, unsigned lCommonOffset, unsigned rCommonOffset) { CommonFID = commonFID; LCommonOffset = lCommonOffset; RCommonOffset = rCommonOffset; } - + }; /// \brief This class handles loading and caching of source files into memory. @@ -564,7 +564,7 @@ class SourceManager : public llvm::RefCountedBase<SourceManager> { // Cache for the "fake" buffer used for error-recovery purposes. mutable llvm::MemoryBuffer *FakeBufferForRecovery; - + // SourceManager doesn't support copy construction. explicit SourceManager(const SourceManager&); void operator=(const SourceManager&); @@ -613,7 +613,7 @@ public: assert(MainFileID.isInvalid() && "MainFileID already set!"); MainFileID = Preamble; } - + //===--------------------------------------------------------------------===// // Methods to create new FileID's and macro expansions. //===--------------------------------------------------------------------===// @@ -700,11 +700,11 @@ public: if (MyInvalid || !Entry.isFile()) { if (Invalid) *Invalid = true; - + return getFakeBufferForRecovery(); } - - return Entry.getFile().getContentCache()->getBuffer(Diag, *this, Loc, + + return Entry.getFile().getContentCache()->getBuffer(Diag, *this, Loc, Invalid); } @@ -714,22 +714,22 @@ public: if (MyInvalid || !Entry.isFile()) { if (Invalid) *Invalid = true; - + return getFakeBufferForRecovery(); } - return Entry.getFile().getContentCache()->getBuffer(Diag, *this, - SourceLocation(), + return Entry.getFile().getContentCache()->getBuffer(Diag, *this, + SourceLocation(), Invalid); } - + /// getFileEntryForID - Returns the FileEntry record for the provided FileID. const FileEntry *getFileEntryForID(FileID FID) const { bool MyInvalid = false; const SrcMgr::SLocEntry &Entry = getSLocEntry(FID, &MyInvalid); if (MyInvalid || !Entry.isFile()) return 0; - + return Entry.getFile().getContentCache()->OrigEntry; } @@ -795,7 +795,7 @@ public: const SrcMgr::SLocEntry &Entry = getSLocEntry(FID, &Invalid); if (Invalid || !Entry.isFile()) return SourceLocation(); - + unsigned FileOffset = Entry.getOffset(); return SourceLocation::getFileLoc(FileOffset); } @@ -807,7 +807,7 @@ public: const SrcMgr::SLocEntry &Entry = getSLocEntry(FID, &Invalid); if (Invalid || !Entry.isFile()) return SourceLocation(); - + return Entry.getFile().getIncludeLoc(); } @@ -956,7 +956,7 @@ public: /// returns zero if the column number isn't known. This may only be called /// on a file sloc, so you must choose a spelling or expansion location /// before calling this method. - unsigned getColumnNumber(FileID FID, unsigned FilePos, + unsigned getColumnNumber(FileID FID, unsigned FilePos, bool *Invalid = 0) const; unsigned getSpellingColumnNumber(SourceLocation Loc, bool *Invalid = 0) const; unsigned getExpansionColumnNumber(SourceLocation Loc, @@ -1074,11 +1074,11 @@ public: size_t getContentCacheSize() const { return ContentCacheAlloc.getTotalMemory(); } - + struct MemoryBufferSizes { const size_t malloc_bytes; const size_t mmap_bytes; - + MemoryBufferSizes(size_t malloc_bytes, size_t mmap_bytes) : malloc_bytes(malloc_bytes), mmap_bytes(mmap_bytes) {} }; @@ -1086,7 +1086,7 @@ public: /// Return the amount of memory used by memory buffers, breaking down /// by heap-backed versus mmap'ed memory. MemoryBufferSizes getMemoryBufferSizes() const; - + // Return the amount of memory used for various side tables and // data structures in the SourceManager. size_t getDataStructureSizes() const; @@ -1108,7 +1108,7 @@ public: SourceLocation Loc = translateFileLineCol(SourceFile, Line, Col); return getMacroArgExpandedLocation(Loc); } - + /// \brief Get the source location for the given file:line:col triplet. /// /// If the source file is included multiple times, the source location will @@ -1154,14 +1154,14 @@ public: /// \brief Determines the order of a source location and a source location /// offset in the "source location address space". /// - /// Note that we always consider source locations loaded from + /// Note that we always consider source locations loaded from bool isBeforeInSLocAddrSpace(SourceLocation LHS, unsigned RHS) const { unsigned LHSOffset = LHS.getOffset(); bool LHSLoaded = LHSOffset >= CurrentLoadedOffset; bool RHSLoaded = RHS >= CurrentLoadedOffset; if (LHSLoaded == RHSLoaded) return LHSOffset < RHS; - + return LHSLoaded; } @@ -1180,17 +1180,17 @@ public: /// \brief Get the number of local SLocEntries we have. unsigned local_sloc_entry_size() const { return LocalSLocEntryTable.size(); } - + /// \brief Get a local SLocEntry. This is exposed for indexing. - const SrcMgr::SLocEntry &getLocalSLocEntry(unsigned Index, + const SrcMgr::SLocEntry &getLocalSLocEntry(unsigned Index, bool *Invalid = 0) const { assert(Index < LocalSLocEntryTable.size() && "Invalid index"); return LocalSLocEntryTable[Index]; } - + /// \brief Get the number of loaded SLocEntries we have. unsigned loaded_sloc_entry_size() const { return LoadedSLocEntryTable.size();} - + /// \brief Get a loaded SLocEntry. This is exposed for indexing. const SrcMgr::SLocEntry &getLoadedSLocEntry(unsigned Index, bool *Invalid=0) const { assert(Index < LoadedSLocEntryTable.size() && "Invalid index"); @@ -1198,19 +1198,19 @@ public: ExternalSLocEntries->ReadSLocEntry(-(static_cast<int>(Index) + 2)); return LoadedSLocEntryTable[Index]; } - + const SrcMgr::SLocEntry &getSLocEntry(FileID FID, bool *Invalid = 0) const { return getSLocEntryByID(FID.ID); } unsigned getNextLocalOffset() const { return NextLocalOffset; } - + void setExternalSLocEntrySource(ExternalSLocEntrySource *Source) { assert(LoadedSLocEntryTable.empty() && "Invalidating existing loaded entries"); ExternalSLocEntries = Source; } - + /// \brief Allocate a number of loaded SLocEntries, which will be actually /// loaded on demand from the external source. /// @@ -1219,7 +1219,7 @@ public: /// entries will be returned. std::pair<int, unsigned> AllocateLoadedSLocEntries(unsigned NumSLocEntries, unsigned TotalSize); - + private: const llvm::MemoryBuffer *getFakeBufferForRecovery() const; @@ -1230,11 +1230,11 @@ private: return getLoadedSLocEntryByID(ID); return getLocalSLocEntry(static_cast<unsigned>(ID)); } - + const SrcMgr::SLocEntry &getLoadedSLocEntryByID(int ID) const { return getLoadedSLocEntry(static_cast<unsigned>(-ID - 2)); } - + /// createExpansionLoc - Implements the common elements of storing an /// expansion info struct into the SLocEntry table and producing a source /// location that refers to it. |