aboutsummaryrefslogtreecommitdiff
path: root/clang
diff options
context:
space:
mode:
authorAbhina Sreeskantharajan <Abhina.Sreeskantharajan@ibm.com>2021-03-25 09:47:25 -0400
committerAbhina Sreeskantharajan <Abhina.Sreeskantharajan@ibm.com>2021-03-25 09:47:49 -0400
commitc83cd8feef7eb8319131d968bb8c94fdc8dbb6a6 (patch)
treed05e472da6cc9f329ec6c51095012818f6847333 /clang
parent0becc4d721d0036e2e38d581bc487e27f78eb8a9 (diff)
downloadllvm-c83cd8feef7eb8319131d968bb8c94fdc8dbb6a6.zip
llvm-c83cd8feef7eb8319131d968bb8c94fdc8dbb6a6.tar.gz
llvm-c83cd8feef7eb8319131d968bb8c94fdc8dbb6a6.tar.bz2
[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
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Tooling/JSONCompilationDatabase.cpp2
-rw-r--r--clang/tools/arcmt-test/arcmt-test.cpp14
2 files changed, 6 insertions, 10 deletions
diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp b/clang/lib/Tooling/JSONCompilationDatabase.cpp
index 2d8847a..97ba7e4 100644
--- a/clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -198,7 +198,7 @@ JSONCompilationDatabase::loadFromFile(StringRef FilePath,
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/clang/tools/arcmt-test/arcmt-test.cpp b/clang/tools/arcmt-test/arcmt-test.cpp
index 778587d..26e123c 100644
--- a/clang/tools/arcmt-test/arcmt-test.cpp
+++ b/clang/tools/arcmt-test/arcmt-test.cpp
@@ -207,15 +207,13 @@ static bool performTransformations(StringRef resourcesPath,
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 @@ static bool verifyTransformedFiles(ArrayRef<std::string> resultFiles) {
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;