diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-12-19 23:48:45 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-12-19 23:48:45 +0000 |
commit | 1036b68525f39cb69ac22c679ed440acd8392a16 (patch) | |
tree | 442e9694a74daa29099d3907807f6443f97dcadf /include/clang/Basic/SourceManager.h | |
parent | 95041a2029a069386ee67439f6d0fb524a9d184f (diff) |
Added methods createMainFileID() and createMainFileIDForMemBuffer() to
SourceManager to allow SourceManager to directly intern the MainFileID
when it is created. Removed setMainFileID().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45231 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r-- | include/clang/Basic/SourceManager.h | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 311bea1d3c..2d60404ee9 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -237,9 +237,6 @@ public: /// getMainFileID - Returns the FileID of the main source file. unsigned getMainFileID() const { return MainFileID; } - /// setMainFileID - Set the FileID of the main source file. - void setMainFileID(unsigned ID) { MainFileID = ID; } - /// createFileID - Create a new FileID that represents the specified file /// being #included from the specified IncludePosition. This returns 0 on /// error and translates NULL into standard input. @@ -249,6 +246,15 @@ public: return createFileID(IR, IncludePos); } + /// createMainFileID - Create the FileID for the main source file. + unsigned createMainFileID(const FileEntry *SourceFile, + SourceLocation IncludePos) { + + assert (MainFileID == 0 && "MainFileID already set!"); + MainFileID = createFileID(SourceFile,IncludePos); + return MainFileID; + } + /// createFileIDForMemBuffer - Create a new FileID that represents the /// specified memory buffer. This does no caching of the buffer and takes /// ownership of the MemoryBuffer, so only pass a MemoryBuffer to this once. @@ -256,6 +262,15 @@ public: return createFileID(createMemBufferContentCache(Buffer), SourceLocation()); } + /// createMainFileIDForMembuffer - Create the FileID for a memory buffer + /// that will represent the FileID for the main source. One example + /// of when this would be used is when the main source is read from STDIN. + unsigned createMainFileIDForMemBuffer(const llvm::MemoryBuffer *Buffer) { + assert (MainFileID == 0 && "MainFileID already set!"); + MainFileID = createMainFileIDForMemBuffer(Buffer); + return MainFileID; + } + /// getInstantiationLoc - Return a new SourceLocation that encodes the fact /// that a token at Loc should actually be referenced from InstantiationLoc. SourceLocation getInstantiationLoc(SourceLocation Loc, |