summaryrefslogtreecommitdiffstats
path: root/include/clang/Basic/SourceManager.h
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2009-12-15 18:49:47 +0000
committerrdivacky <rdivacky@FreeBSD.org>2009-12-15 18:49:47 +0000
commit77212133072dc40f070a280af8217032f55a9eb4 (patch)
tree2fd5819f49caecc5f520219b6b9254fe94ebb138 /include/clang/Basic/SourceManager.h
parent4b08eb6308ca90a6c08e2fc79d100821b1b1f6aa (diff)
downloadFreeBSD-src-77212133072dc40f070a280af8217032f55a9eb4.zip
FreeBSD-src-77212133072dc40f070a280af8217032f55a9eb4.tar.gz
Update clang to 91430.
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r--include/clang/Basic/SourceManager.h75
1 files changed, 32 insertions, 43 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index 7e9ac53..b4cf959 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -54,9 +54,6 @@ namespace SrcMgr {
/// file. This is owned by the ContentCache object.
mutable const llvm::MemoryBuffer *Buffer;
- /// The line and column at which we should truncate the file.
- unsigned TruncateAtLine, TruncateAtColumn;
-
public:
/// Reference to the file entry. This reference does not own
/// the FileEntry object. It is possible for this to be NULL if
@@ -72,13 +69,10 @@ namespace SrcMgr {
/// if SourceLineCache is non-null.
unsigned NumLines;
- /// FirstFID - First FileID that was created for this ContentCache.
- /// Represents the first source inclusion of the file associated with this
- /// ContentCache.
- mutable FileID FirstFID;
-
- /// getBuffer - Returns the memory buffer for the associated content.
- const llvm::MemoryBuffer *getBuffer() const;
+ /// getBuffer - Returns the memory buffer for the associated content. If
+ /// there is an error opening this buffer the first time, this manufactures
+ /// a temporary buffer and returns a non-empty error string.
+ const llvm::MemoryBuffer *getBuffer(std::string *ErrorStr = 0) const;
/// getSize - Returns the size of the content encapsulated by this
/// ContentCache. This can be the size of the source file or the size of an
@@ -96,28 +90,19 @@ namespace SrcMgr {
Buffer = B;
}
- /// \brief Truncate this file at the given line and column.
- ///
- /// \param Line the line on which to truncate the current file (1-based).
- /// \param Column the column at which to truncate the current file.
- /// (1-based).
- void truncateAt(unsigned Line, unsigned Column);
-
- /// \brief Determines whether the file was artificially truncated with
- /// truncateAt().
- bool isTruncated() const { return TruncateAtLine && TruncateAtColumn; }
-
+ /// \brief Replace the existing buffer (which will be deleted)
+ /// with the given buffer.
+ void replaceBuffer(const llvm::MemoryBuffer *B);
+
ContentCache(const FileEntry *Ent = 0)
- : Buffer(0), TruncateAtLine(0), TruncateAtColumn(0), Entry(Ent),
- SourceLineCache(0), NumLines(0) {}
+ : Buffer(0), Entry(Ent), SourceLineCache(0), 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(0), TruncateAtLine(0), TruncateAtColumn(0), SourceLineCache(0) {
+ ContentCache(const ContentCache &RHS) : Buffer(0), SourceLineCache(0) {
Entry = RHS.Entry;
assert (RHS.Buffer == 0 && RHS.SourceLineCache == 0
@@ -347,19 +332,13 @@ class SourceManager {
mutable FileID LastRFIDForBeforeTUCheck;
mutable bool LastResForBeforeTUCheck;
- // Keep track of the file/line/column that we should truncate.
- const FileEntry *TruncateFile;
- unsigned TruncateAtLine;
- unsigned TruncateAtColumn;
-
// SourceManager doesn't support copy construction.
explicit SourceManager(const SourceManager&);
void operator=(const SourceManager&);
public:
SourceManager()
- : ExternalSLocEntries(0), LineTable(0), NumLinearScans(0),
- NumBinaryProbes(0), TruncateFile(0), TruncateAtLine(0),
- TruncateAtColumn(0) {
+ : ExternalSLocEntries(0), LineTable(0), NumLinearScans(0),
+ NumBinaryProbes(0) {
clearIDTables();
}
~SourceManager();
@@ -428,14 +407,30 @@ public:
unsigned PreallocatedID = 0,
unsigned Offset = 0);
+ /// \brief Retrieve the memory buffer associated with the given file.
+ const llvm::MemoryBuffer *getMemoryBufferForFile(const FileEntry *File);
+
+ /// \brief Override the contents of the given source file by providing an
+ /// already-allocated buffer.
+ ///
+ /// \param SourceFile the source file whose contents will be override.
+ ///
+ /// \param Buffer the memory buffer whose contents will be used as the
+ /// data in the given source file.
+ ///
+ /// \returns true if an error occurred, false otherwise.
+ bool overrideFileContents(const FileEntry *SourceFile,
+ const llvm::MemoryBuffer *Buffer);
+
//===--------------------------------------------------------------------===//
// FileID manipulation methods.
//===--------------------------------------------------------------------===//
- /// getBuffer - Return the buffer for the specified FileID.
- ///
- const llvm::MemoryBuffer *getBuffer(FileID FID) const {
- return getSLocEntry(FID).getFile().getContentCache()->getBuffer();
+ /// getBuffer - Return the buffer for the specified FileID. If there is an
+ /// error opening this buffer the first time, this manufactures a temporary
+ /// buffer and returns a non-empty error string.
+ const llvm::MemoryBuffer *getBuffer(FileID FID, std::string *Error = 0) const{
+ return getSLocEntry(FID).getFile().getContentCache()->getBuffer(Error);
}
/// getFileEntryForID - Returns the FileEntry record for the provided FileID.
@@ -669,12 +664,6 @@ public:
/// \returns true if LHS source location comes before RHS, false otherwise.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const;
- /// \brief Truncate the given file at the specified line/column.
- void truncateFileAt(const FileEntry *Entry, unsigned Line, unsigned Column);
-
- /// \brief Determine whether this file was truncated.
- bool isTruncatedFile(FileID FID) const;
-
// Iterators over FileInfos.
typedef llvm::DenseMap<const FileEntry*, SrcMgr::ContentCache*>
::const_iterator fileinfo_iterator;
OpenPOWER on IntegriCloud