summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-23 09:19:42 +0000
committerChris Lattner <sabre@nondot.org>2010-11-23 09:19:42 +0000
commit26b5c190f86994c99e187fa2ee6c73d981dfd1ea (patch)
tree5e2e51a156a4a226123dcb4057ad45f0844a8246
parent7219a5db6ea402d19a959897bdecf6da58d2d3aa (diff)
downloadbcm5719-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
-rw-r--r--clang/include/clang/Basic/FileManager.h9
-rw-r--r--clang/include/clang/Frontend/ASTUnit.h3
-rw-r--r--clang/lib/Basic/FileManager.cpp20
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp5
-rw-r--r--clang/lib/Serialization/ASTReader.cpp5
5 files changed, 22 insertions, 20 deletions
diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h
index 5a143e94417..12e9e3f227c 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -171,7 +171,7 @@ class FileManager {
// Caching.
llvm::OwningPtr<StatSysCallCache> StatCache;
- int stat_cached(const char* path, struct stat* buf);
+ int stat_cached(const char *path, struct stat *buf);
public:
FileManager(const FileSystemOptions &FileSystemOpts);
@@ -212,12 +212,9 @@ public:
/// \brief Open the specified file as a MemoryBuffer, returning a new
/// MemoryBuffer if successful, otherwise returning null.
llvm::MemoryBuffer *getBufferForFile(const FileEntry *Entry,
- std::string *ErrorStr = 0) {
- return getBufferForFile(Entry->getName(), ErrorStr, Entry->getSize());
- }
+ std::string *ErrorStr = 0);
llvm::MemoryBuffer *getBufferForFile(llvm::StringRef Filename,
- std::string *ErrorStr = 0,
- int64_t FileSize = -1);
+ std::string *ErrorStr = 0);
/// \brief If path is not absolute and FileSystemOptions set the working
/// directory, the path is modified to be relative to the given
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h
index b6398f7926e..6d584d4b07b 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -462,8 +462,7 @@ public:
}
llvm::MemoryBuffer *getBufferForFile(llvm::StringRef Filename,
- std::string *ErrorStr = 0,
- int64_t FileSize = -1);
+ std::string *ErrorStr = 0);
/// \brief Whether this AST represents a complete translation unit.
///
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) {
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 34d2fec3cba..b55001e2b1b 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -456,10 +456,9 @@ const std::string &ASTUnit::getASTFileName() {
}
llvm::MemoryBuffer *ASTUnit::getBufferForFile(llvm::StringRef Filename,
- std::string *ErrorStr,
- int64_t FileSize) {
+ std::string *ErrorStr) {
assert(FileMgr);
- return FileMgr->getBufferForFile(Filename, ErrorStr, FileSize);
+ return FileMgr->getBufferForFile(Filename, ErrorStr);
}
/// \brief Configure the diagnostics object for use with ASTUnit.
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 9673081f0a6..81907d022e5 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -1262,9 +1262,8 @@ ASTReader::ASTReadResult ASTReader::ReadSLocEntryRecord(unsigned ID) {
return Failure;
}
- FileID FID = SourceMgr.createFileID(File,
- ReadSourceLocation(*F, Record[1]),
- (SrcMgr::CharacteristicKind)Record[2],
+ FileID FID = SourceMgr.createFileID(File, ReadSourceLocation(*F, Record[1]),
+ (SrcMgr::CharacteristicKind)Record[2],
ID, Record[0]);
if (Record[3])
const_cast<SrcMgr::FileInfo&>(SourceMgr.getSLocEntry(FID).getFile())
OpenPOWER on IntegriCloud