Refer to error_code with the std prefix.
llvm-svn: 210817
This commit is contained in:
@@ -65,17 +65,15 @@ File::~File() {}
|
||||
|
||||
FileSystem::~FileSystem() {}
|
||||
|
||||
error_code FileSystem::getBufferForFile(const llvm::Twine &Name,
|
||||
std::unique_ptr<MemoryBuffer> &Result,
|
||||
int64_t FileSize,
|
||||
bool RequiresNullTerminator,
|
||||
bool IsVolatile) {
|
||||
std::error_code FileSystem::getBufferForFile(
|
||||
const llvm::Twine &Name, std::unique_ptr<MemoryBuffer> &Result,
|
||||
int64_t FileSize, bool RequiresNullTerminator, bool IsVolatile) {
|
||||
std::unique_ptr<File> F;
|
||||
if (error_code EC = openFileForRead(Name, F))
|
||||
if (std::error_code EC = openFileForRead(Name, F))
|
||||
return EC;
|
||||
|
||||
error_code EC = F->getBuffer(Name, Result, FileSize, RequiresNullTerminator,
|
||||
IsVolatile);
|
||||
std::error_code EC =
|
||||
F->getBuffer(Name, Result, FileSize, RequiresNullTerminator, IsVolatile);
|
||||
return EC;
|
||||
}
|
||||
|
||||
@@ -96,11 +94,12 @@ class RealFile : public File {
|
||||
public:
|
||||
~RealFile();
|
||||
ErrorOr<Status> status() override;
|
||||
error_code getBuffer(const Twine &Name, std::unique_ptr<MemoryBuffer> &Result,
|
||||
int64_t FileSize = -1,
|
||||
bool RequiresNullTerminator = true,
|
||||
bool IsVolatile = false) override;
|
||||
error_code close() override;
|
||||
std::error_code getBuffer(const Twine &Name,
|
||||
std::unique_ptr<MemoryBuffer> &Result,
|
||||
int64_t FileSize = -1,
|
||||
bool RequiresNullTerminator = true,
|
||||
bool IsVolatile = false) override;
|
||||
std::error_code close() override;
|
||||
void setName(StringRef Name) override;
|
||||
};
|
||||
} // end anonymous namespace
|
||||
@@ -110,7 +109,7 @@ ErrorOr<Status> RealFile::status() {
|
||||
assert(FD != -1 && "cannot stat closed file");
|
||||
if (!S.isStatusKnown()) {
|
||||
file_status RealStatus;
|
||||
if (error_code EC = sys::fs::status(FD, RealStatus))
|
||||
if (std::error_code EC = sys::fs::status(FD, RealStatus))
|
||||
return EC;
|
||||
Status NewS(RealStatus);
|
||||
NewS.setName(S.getName());
|
||||
@@ -119,10 +118,11 @@ ErrorOr<Status> RealFile::status() {
|
||||
return S;
|
||||
}
|
||||
|
||||
error_code RealFile::getBuffer(const Twine &Name,
|
||||
std::unique_ptr<MemoryBuffer> &Result,
|
||||
int64_t FileSize, bool RequiresNullTerminator,
|
||||
bool IsVolatile) {
|
||||
std::error_code RealFile::getBuffer(const Twine &Name,
|
||||
std::unique_ptr<MemoryBuffer> &Result,
|
||||
int64_t FileSize,
|
||||
bool RequiresNullTerminator,
|
||||
bool IsVolatile) {
|
||||
assert(FD != -1 && "cannot get buffer for closed file");
|
||||
return MemoryBuffer::getOpenFile(FD, Name.str().c_str(), Result, FileSize,
|
||||
RequiresNullTerminator, IsVolatile);
|
||||
@@ -138,11 +138,11 @@ error_code RealFile::getBuffer(const Twine &Name,
|
||||
#define S_ISFIFO(x) (0)
|
||||
#endif
|
||||
#endif
|
||||
error_code RealFile::close() {
|
||||
std::error_code RealFile::close() {
|
||||
if (::close(FD))
|
||||
return error_code(errno, std::generic_category());
|
||||
return std::error_code(errno, std::generic_category());
|
||||
FD = -1;
|
||||
return error_code();
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
void RealFile::setName(StringRef Name) {
|
||||
@@ -154,28 +154,28 @@ namespace {
|
||||
class RealFileSystem : public FileSystem {
|
||||
public:
|
||||
ErrorOr<Status> status(const Twine &Path) override;
|
||||
error_code openFileForRead(const Twine &Path,
|
||||
std::unique_ptr<File> &Result) override;
|
||||
std::error_code openFileForRead(const Twine &Path,
|
||||
std::unique_ptr<File> &Result) override;
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
ErrorOr<Status> RealFileSystem::status(const Twine &Path) {
|
||||
sys::fs::file_status RealStatus;
|
||||
if (error_code EC = sys::fs::status(Path, RealStatus))
|
||||
if (std::error_code EC = sys::fs::status(Path, RealStatus))
|
||||
return EC;
|
||||
Status Result(RealStatus);
|
||||
Result.setName(Path.str());
|
||||
return Result;
|
||||
}
|
||||
|
||||
error_code RealFileSystem::openFileForRead(const Twine &Name,
|
||||
std::unique_ptr<File> &Result) {
|
||||
std::error_code RealFileSystem::openFileForRead(const Twine &Name,
|
||||
std::unique_ptr<File> &Result) {
|
||||
int FD;
|
||||
if (error_code EC = sys::fs::openFileForRead(Name, FD))
|
||||
if (std::error_code EC = sys::fs::openFileForRead(Name, FD))
|
||||
return EC;
|
||||
Result.reset(new RealFile(FD));
|
||||
Result->setName(Name.str());
|
||||
return error_code();
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
IntrusiveRefCntPtr<FileSystem> vfs::getRealFileSystem() {
|
||||
@@ -204,11 +204,12 @@ ErrorOr<Status> OverlayFileSystem::status(const Twine &Path) {
|
||||
return std::make_error_code(std::errc::no_such_file_or_directory);
|
||||
}
|
||||
|
||||
error_code OverlayFileSystem::openFileForRead(const llvm::Twine &Path,
|
||||
std::unique_ptr<File> &Result) {
|
||||
std::error_code
|
||||
OverlayFileSystem::openFileForRead(const llvm::Twine &Path,
|
||||
std::unique_ptr<File> &Result) {
|
||||
// FIXME: handle symlinks that cross file systems
|
||||
for (iterator I = overlays_begin(), E = overlays_end(); I != E; ++I) {
|
||||
error_code EC = (*I)->openFileForRead(Path, Result);
|
||||
std::error_code EC = (*I)->openFileForRead(Path, Result);
|
||||
if (!EC || EC != std::errc::no_such_file_or_directory)
|
||||
return EC;
|
||||
}
|
||||
@@ -389,8 +390,8 @@ public:
|
||||
IntrusiveRefCntPtr<FileSystem> ExternalFS);
|
||||
|
||||
ErrorOr<Status> status(const Twine &Path) override;
|
||||
error_code openFileForRead(const Twine &Path,
|
||||
std::unique_ptr<File> &Result) override;
|
||||
std::error_code openFileForRead(const Twine &Path,
|
||||
std::unique_ptr<File> &Result) override;
|
||||
};
|
||||
|
||||
/// \brief A helper class to hold the common YAML parsing state.
|
||||
@@ -740,7 +741,7 @@ ErrorOr<Entry *> VFSFromYAML::lookupPath(const Twine &Path_) {
|
||||
Path_.toVector(Path);
|
||||
|
||||
// Handle relative paths
|
||||
if (error_code EC = sys::fs::make_absolute(Path))
|
||||
if (std::error_code EC = sys::fs::make_absolute(Path))
|
||||
return EC;
|
||||
|
||||
if (Path.empty())
|
||||
@@ -812,8 +813,9 @@ ErrorOr<Status> VFSFromYAML::status(const Twine &Path) {
|
||||
}
|
||||
}
|
||||
|
||||
error_code VFSFromYAML::openFileForRead(const Twine &Path,
|
||||
std::unique_ptr<vfs::File> &Result) {
|
||||
std::error_code
|
||||
VFSFromYAML::openFileForRead(const Twine &Path,
|
||||
std::unique_ptr<vfs::File> &Result) {
|
||||
ErrorOr<Entry *> E = lookupPath(Path);
|
||||
if (!E)
|
||||
return E.getError();
|
||||
@@ -822,14 +824,14 @@ error_code VFSFromYAML::openFileForRead(const Twine &Path,
|
||||
if (!F) // FIXME: errc::not_a_file?
|
||||
return std::make_error_code(std::errc::invalid_argument);
|
||||
|
||||
if (error_code EC = ExternalFS->openFileForRead(F->getExternalContentsPath(),
|
||||
Result))
|
||||
if (std::error_code EC =
|
||||
ExternalFS->openFileForRead(F->getExternalContentsPath(), Result))
|
||||
return EC;
|
||||
|
||||
if (!F->useExternalName(UseExternalNames))
|
||||
Result->setName(Path.str());
|
||||
|
||||
return error_code();
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
IntrusiveRefCntPtr<FileSystem>
|
||||
|
||||
Reference in New Issue
Block a user