summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Basic/FileManager.h9
-rw-r--r--clang/lib/Basic/FileManager.cpp17
2 files changed, 14 insertions, 12 deletions
diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h
index 0c9a9adedaf..b22afec54e4 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -311,8 +311,15 @@ public:
getBufferForFile(const FileEntry *Entry, bool isVolatile = false,
bool ShouldCloseOpenFile = true);
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
- getBufferForFile(StringRef Filename, bool isVolatile = false);
+ getBufferForFile(StringRef Filename, bool isVolatile = false) {
+ return getBufferForFileImpl(Filename, /*FileSize=*/-1, isVolatile);
+ }
+private:
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+ getBufferForFileImpl(StringRef Filename, int64_t FileSize, bool isVolatile);
+
+public:
/// Get the 'stat' information for the given \p Path.
///
/// If the path is relative, it will be resolved against the WorkingDir of the
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 3af27564b4c..7138f6677e3 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -447,27 +447,22 @@ FileManager::getBufferForFile(const FileEntry *Entry, bool isVolatile,
}
// Otherwise, open the file.
+ return getBufferForFileImpl(Filename, FileSize, isVolatile);
+}
+llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+FileManager::getBufferForFileImpl(StringRef Filename, int64_t FileSize,
+ bool isVolatile) {
if (FileSystemOpts.WorkingDir.empty())
return FS->getBufferForFile(Filename, FileSize,
/*RequiresNullTerminator=*/true, isVolatile);
- SmallString<128> FilePath(Entry->getName());
+ SmallString<128> FilePath(Filename);
FixupRelativePath(FilePath);
return FS->getBufferForFile(FilePath, FileSize,
/*RequiresNullTerminator=*/true, isVolatile);
}
-llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
-FileManager::getBufferForFile(StringRef Filename, bool isVolatile) {
- if (FileSystemOpts.WorkingDir.empty())
- return FS->getBufferForFile(Filename, -1, true, isVolatile);
-
- SmallString<128> FilePath(Filename);
- FixupRelativePath(FilePath);
- return FS->getBufferForFile(FilePath.c_str(), -1, true, isVolatile);
-}
-
/// getStatValue - Get the 'stat' information for the specified path,
/// using the cache to accelerate it if possible. This returns true
/// if the path points to a virtual file or does not exist, or returns
OpenPOWER on IntegriCloud