diff options
author | Chris Lattner <sabre@nondot.org> | 2010-11-23 09:19:42 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-11-23 09:19:42 +0000 |
commit | 26b5c190f86994c99e187fa2ee6c73d981dfd1ea (patch) | |
tree | 5e2e51a156a4a226123dcb4057ad45f0844a8246 /clang/lib/Basic/FileManager.cpp | |
parent | 7219a5db6ea402d19a959897bdecf6da58d2d3aa (diff) | |
download | bcm5719-llvm-26b5c190f86994c99e187fa2ee6c73d981dfd1ea.tar.gz bcm5719-llvm-26b5c190f86994c99e187fa2ee6c73d981dfd1ea.zip |
tidy up. Split FileManager::getBufferForFile into
two copies, since they are fundamentally different
operations and the StringRef one should go away
(it shouldn't be part of FileManager at least).
Remove some dead arguments.
llvm-svn: 120013
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 36b53850bcc..90663594f97 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -307,7 +307,7 @@ const FileEntry *FileManager::getFile(llvm::StringRef Filename) { struct stat StatBuf; //llvm::errs() << "STATING: " << Filename; if (stat_cached(InterndFileName, &StatBuf) || // Error stat'ing. - S_ISDIR(StatBuf.st_mode)) { // A directory? + S_ISDIR(StatBuf.st_mode)) { // A directory? // If this file doesn't exist, we leave a null in FileEntries for this path. //llvm::errs() << ": Not existing\n"; return 0; @@ -389,17 +389,25 @@ void FileManager::FixupRelativePath(llvm::sys::Path &path, path = NewPath; } - +llvm::MemoryBuffer *FileManager:: +getBufferForFile(const FileEntry *Entry, std::string *ErrorStr) { + llvm::StringRef Filename = Entry->getName(); + if (FileSystemOpts.WorkingDir.empty()) + return llvm::MemoryBuffer::getFile(Filename, ErrorStr); + + llvm::sys::Path FilePath(Filename); + FixupRelativePath(FilePath, FileSystemOpts); + return llvm::MemoryBuffer::getFile(FilePath.c_str(), ErrorStr); +} llvm::MemoryBuffer *FileManager:: -getBufferForFile(llvm::StringRef Filename, - std::string *ErrorStr, int64_t FileSize) { +getBufferForFile(llvm::StringRef Filename, std::string *ErrorStr) { if (FileSystemOpts.WorkingDir.empty()) - return llvm::MemoryBuffer::getFile(Filename, ErrorStr, FileSize); + return llvm::MemoryBuffer::getFile(Filename, ErrorStr); llvm::sys::Path FilePath(Filename); FixupRelativePath(FilePath, FileSystemOpts); - return llvm::MemoryBuffer::getFile(FilePath.c_str(), ErrorStr, FileSize); + return llvm::MemoryBuffer::getFile(FilePath.c_str(), ErrorStr); } int FileManager::stat_cached(const char *path, struct stat *buf) { |