aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ARCMigrate/FileRemapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ARCMigrate/FileRemapper.cpp')
-rw-r--r--lib/ARCMigrate/FileRemapper.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/ARCMigrate/FileRemapper.cpp b/lib/ARCMigrate/FileRemapper.cpp
index 1a4862d09aa6..a031fe22ac13 100644
--- a/lib/ARCMigrate/FileRemapper.cpp
+++ b/lib/ARCMigrate/FileRemapper.cpp
@@ -78,26 +78,26 @@ bool FileRemapper::initFromFile(StringRef filePath, DiagnosticsEngine &Diag,
Diag);
StringRef toFilename = lines[idx+2];
- const FileEntry *origFE = FileMgr->getFile(fromFilename);
+ llvm::ErrorOr<const FileEntry *> origFE = FileMgr->getFile(fromFilename);
if (!origFE) {
if (ignoreIfFilesChanged)
continue;
return report("File does not exist: " + fromFilename, Diag);
}
- const FileEntry *newFE = FileMgr->getFile(toFilename);
+ llvm::ErrorOr<const FileEntry *> newFE = FileMgr->getFile(toFilename);
if (!newFE) {
if (ignoreIfFilesChanged)
continue;
return report("File does not exist: " + toFilename, Diag);
}
- if ((uint64_t)origFE->getModificationTime() != timeModified) {
+ if ((uint64_t)(*origFE)->getModificationTime() != timeModified) {
if (ignoreIfFilesChanged)
continue;
return report("File was modified: " + fromFilename, Diag);
}
- pairs.push_back(std::make_pair(origFE, newFE));
+ pairs.push_back(std::make_pair(*origFE, *newFE));
}
for (unsigned i = 0, e = pairs.size(); i != e; ++i)
@@ -121,7 +121,7 @@ bool FileRemapper::flushToFile(StringRef outputPath, DiagnosticsEngine &Diag) {
std::error_code EC;
std::string infoFile = outputPath;
- llvm::raw_fd_ostream infoOut(infoFile, EC, llvm::sys::fs::F_None);
+ llvm::raw_fd_ostream infoOut(infoFile, EC, llvm::sys::fs::OF_None);
if (EC)
return report(EC.message(), Diag);
@@ -152,9 +152,11 @@ bool FileRemapper::flushToFile(StringRef outputPath, DiagnosticsEngine &Diag) {
newOut.write(mem->getBufferStart(), mem->getBufferSize());
newOut.close();
- const FileEntry *newE = FileMgr->getFile(tempPath);
- remap(origFE, newE);
- infoOut << newE->getName() << '\n';
+ auto newE = FileMgr->getFile(tempPath);
+ if (newE) {
+ remap(origFE, *newE);
+ infoOut << (*newE)->getName() << '\n';
+ }
}
}
@@ -175,7 +177,7 @@ bool FileRemapper::overwriteOriginal(DiagnosticsEngine &Diag,
Diag);
std::error_code EC;
- llvm::raw_fd_ostream Out(origFE->getName(), EC, llvm::sys::fs::F_None);
+ llvm::raw_fd_ostream Out(origFE->getName(), EC, llvm::sys::fs::OF_None);
if (EC)
return report(EC.message(), Diag);
@@ -224,7 +226,9 @@ void FileRemapper::remap(const FileEntry *file, const FileEntry *newfile) {
}
const FileEntry *FileRemapper::getOriginalFile(StringRef filePath) {
- const FileEntry *file = FileMgr->getFile(filePath);
+ const FileEntry *file = nullptr;
+ if (auto fileOrErr = FileMgr->getFile(filePath))
+ file = *fileOrErr;
// If we are updating a file that overridden an original file,
// actually update the original file.
llvm::DenseMap<const FileEntry *, const FileEntry *>::iterator