[NFC] Reordering parameters in getFile and getFileOrSTDIN
In future patches I will be setting the IsText parameter frequently so I will refactor the args to be in the following order. I have removed the FileSize parameter because it is never used.
```
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getFile(const Twine &Filename, bool IsText = false,
bool RequiresNullTerminator = true, bool IsVolatile = false);
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getFileOrSTDIN(const Twine &Filename, bool IsText = false,
bool RequiresNullTerminator = true);
static ErrorOr<std::unique_ptr<MB>>
getFileAux(const Twine &Filename, uint64_t MapSize, uint64_t Offset,
bool IsText, bool RequiresNullTerminator, bool IsVolatile);
static ErrorOr<std::unique_ptr<WritableMemoryBuffer>>
getFile(const Twine &Filename, bool IsVolatile = false);
```
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D99182
GitOrigin-RevId: c83cd8feef7eb8319131d968bb8c94fdc8dbb6a6
diff --git a/lib/Tooling/JSONCompilationDatabase.cpp b/lib/Tooling/JSONCompilationDatabase.cpp
index 2d8847a..97ba7e4 100644
--- a/lib/Tooling/JSONCompilationDatabase.cpp
+++ b/lib/Tooling/JSONCompilationDatabase.cpp
@@ -198,7 +198,7 @@
JSONCommandLineSyntax Syntax) {
// Don't mmap: if we're a long-lived process, the build system may overwrite.
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> DatabaseBuffer =
- llvm::MemoryBuffer::getFile(FilePath, /*FileSize=*/-1,
+ llvm::MemoryBuffer::getFile(FilePath, /*IsText=*/false,
/*RequiresNullTerminator=*/true,
/*IsVolatile=*/true);
if (std::error_code Result = DatabaseBuffer.getError()) {
diff --git a/tools/arcmt-test/arcmt-test.cpp b/tools/arcmt-test/arcmt-test.cpp
index 778587d..26e123c 100644
--- a/tools/arcmt-test/arcmt-test.cpp
+++ b/tools/arcmt-test/arcmt-test.cpp
@@ -207,15 +207,13 @@
static bool filesCompareEqual(StringRef fname1, StringRef fname2) {
using namespace llvm;
- ErrorOr<std::unique_ptr<MemoryBuffer>> file1 = MemoryBuffer::getFile(
- fname1, /*FileSize=*/-1, /*RequiresNullTerminator=*/true,
- /*IsVolatile=*/false, /*IsText=*/true);
+ ErrorOr<std::unique_ptr<MemoryBuffer>> file1 =
+ MemoryBuffer::getFile(fname1, /*IsText=*/true);
if (!file1)
return false;
- ErrorOr<std::unique_ptr<MemoryBuffer>> file2 = MemoryBuffer::getFile(
- fname2, /*FileSize=*/-1, /*RequiresNullTerminator=*/true,
- /*IsVolatile=*/false, /*IsText=*/true);
+ ErrorOr<std::unique_ptr<MemoryBuffer>> file2 =
+ MemoryBuffer::getFile(fname2, /*IsText=*/true);
if (!file2)
return false;
@@ -244,9 +242,7 @@
if (RemappingsFile.empty())
inputBuf = MemoryBuffer::getSTDIN();
else
- inputBuf = MemoryBuffer::getFile(RemappingsFile, /*FileSize=*/-1,
- /*RequiresNullTerminator=*/true,
- /*IsVolatile=*/false, /*IsText=*/true);
+ inputBuf = MemoryBuffer::getFile(RemappingsFile, /*IsText=*/true);
if (!inputBuf) {
errs() << "error: could not read remappings input\n";
return true;