diff options
author | dim <dim@FreeBSD.org> | 2015-01-18 16:23:48 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-01-18 16:23:48 +0000 |
commit | c86b984ea8ecb3e944dc3de48539f4c1f65851ea (patch) | |
tree | 3eb853da77d46cc77c4b017525a422f9ddb1385b /lib/ARCMigrate/FileRemapper.cpp | |
parent | c696171ff15f0ee60dea4abfd99a135473c95656 (diff) | |
download | FreeBSD-src-c86b984ea8ecb3e944dc3de48539f4c1f65851ea.zip FreeBSD-src-c86b984ea8ecb3e944dc3de48539f4c1f65851ea.tar.gz |
Vendor import of clang RELEASE_360/rc1 tag r226102 (effectively, 3.6.0 RC1):
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_360/rc1@226102
Diffstat (limited to 'lib/ARCMigrate/FileRemapper.cpp')
-rw-r--r-- | lib/ARCMigrate/FileRemapper.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/lib/ARCMigrate/FileRemapper.cpp b/lib/ARCMigrate/FileRemapper.cpp index 40e6060..72a55da 100644 --- a/lib/ARCMigrate/FileRemapper.cpp +++ b/lib/ARCMigrate/FileRemapper.cpp @@ -58,9 +58,7 @@ bool FileRemapper::initFromFile(StringRef filePath, DiagnosticsEngine &Diag, assert(FromToMappings.empty() && "initFromDisk should be called before any remap calls"); std::string infoFile = filePath; - bool fileExists = false; - llvm::sys::fs::exists(infoFile, fileExists); - if (!fileExists) + if (!llvm::sys::fs::exists(infoFile)) return false; std::vector<std::pair<const FileEntry *, const FileEntry *> > pairs; @@ -122,11 +120,11 @@ bool FileRemapper::flushToDisk(StringRef outputDir, DiagnosticsEngine &Diag) { bool FileRemapper::flushToFile(StringRef outputPath, DiagnosticsEngine &Diag) { using namespace llvm::sys; - std::string errMsg; + std::error_code EC; std::string infoFile = outputPath; - llvm::raw_fd_ostream infoOut(infoFile.c_str(), errMsg, llvm::sys::fs::F_None); - if (!errMsg.empty()) - return report(errMsg, Diag); + llvm::raw_fd_ostream infoOut(infoFile, EC, llvm::sys::fs::F_None); + if (EC) + return report(EC.message(), Diag); for (MappingsTy::iterator I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) { @@ -173,16 +171,14 @@ bool FileRemapper::overwriteOriginal(DiagnosticsEngine &Diag, I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) { const FileEntry *origFE = I->first; assert(I->second.is<llvm::MemoryBuffer *>()); - bool fileExists = false; - fs::exists(origFE->getName(), fileExists); - if (!fileExists) + if (!fs::exists(origFE->getName())) return report(StringRef("File does not exist: ") + origFE->getName(), Diag); - std::string errMsg; - llvm::raw_fd_ostream Out(origFE->getName(), errMsg, llvm::sys::fs::F_None); - if (!errMsg.empty()) - return report(errMsg, Diag); + std::error_code EC; + llvm::raw_fd_ostream Out(origFE->getName(), EC, llvm::sys::fs::F_None); + if (EC) + return report(EC.message(), Diag); llvm::MemoryBuffer *mem = I->second.get<llvm::MemoryBuffer *>(); Out.write(mem->getBufferStart(), mem->getBufferSize()); @@ -207,15 +203,17 @@ void FileRemapper::applyMappings(PreprocessorOptions &PPOpts) const { PPOpts.RetainRemappedFileBuffers = true; } -void FileRemapper::remap(StringRef filePath, llvm::MemoryBuffer *memBuf) { - remap(getOriginalFile(filePath), memBuf); +void FileRemapper::remap(StringRef filePath, + std::unique_ptr<llvm::MemoryBuffer> memBuf) { + remap(getOriginalFile(filePath), std::move(memBuf)); } -void FileRemapper::remap(const FileEntry *file, llvm::MemoryBuffer *memBuf) { +void FileRemapper::remap(const FileEntry *file, + std::unique_ptr<llvm::MemoryBuffer> memBuf) { assert(file); Target &targ = FromToMappings[file]; resetTarget(targ); - targ = memBuf; + targ = memBuf.release(); } void FileRemapper::remap(const FileEntry *file, const FileEntry *newfile) { |