folly::Optional -> std::optional

Summary: Eden's on C++17 so fully cross the rubicon!

Reviewed By: strager

Differential Revision: D10498200

fbshipit-source-id: 4e2af5a8d5cef9a106e8c05e6f93ea9e5b8e696e
This commit is contained in:
Chad Austin 2018-10-23 18:48:38 -07:00 committed by Facebook Github Bot
parent fcbabf9fc2
commit 2a6dd2879d
36 changed files with 188 additions and 211 deletions

View File

@ -65,9 +65,9 @@ CheckoutAction::CheckoutAction(
CheckoutAction::~CheckoutAction() {}
PathComponentPiece CheckoutAction::getEntryName() const {
DCHECK(oldScmEntry_.hasValue() || newScmEntry_.hasValue());
return oldScmEntry_.hasValue() ? oldScmEntry_.value().getName()
: newScmEntry_.value().getName();
DCHECK(oldScmEntry_.has_value() || newScmEntry_.has_value());
return oldScmEntry_.has_value() ? oldScmEntry_.value().getName()
: newScmEntry_.value().getName();
}
class CheckoutAction::LoadingRefcount {
@ -124,7 +124,7 @@ Future<Unit> CheckoutAction::run(
try {
// Load the Blob or Tree for the old TreeEntry.
if (oldScmEntry_.hasValue()) {
if (oldScmEntry_.has_value()) {
if (oldScmEntry_.value().isTree()) {
store->getTree(oldScmEntry_.value().getHash())
.thenValue([rc = LoadingRefcount(this)](
@ -147,7 +147,7 @@ Future<Unit> CheckoutAction::run(
}
// If we have a new TreeEntry, load the corresponding Blob or Tree
if (newScmEntry_.hasValue()) {
if (newScmEntry_.has_value()) {
const auto& newEntry = newScmEntry_.value();
if (newEntry.isTree()) {
store->getTree(newEntry.getHash())
@ -261,12 +261,12 @@ bool CheckoutAction::ensureDataReady() noexcept {
// Make sure we actually have all the data we need.
// (Just in case something went wrong when wiring up the callbacks in such a
// way that we also failed to call error().)
if (oldScmEntry_.hasValue() && (!oldTree_ && !oldBlob_)) {
if (oldScmEntry_.has_value() && (!oldTree_ && !oldBlob_)) {
promise_.setException(
std::runtime_error("failed to load data for old TreeEntry"));
return false;
}
if (newScmEntry_.hasValue() && (!newTree_ && !newBlob_)) {
if (newScmEntry_.has_value() && (!newTree_ && !newBlob_)) {
promise_.setException(
std::runtime_error("failed to load data for new TreeEntry"));
return false;

View File

@ -9,9 +9,9 @@
*/
#pragma once
#include <folly/Optional.h>
#include <folly/futures/Future.h>
#include <memory>
#include <optional>
#include <vector>
#include "eden/fs/inodes/InodePtr.h"
#include "eden/fs/model/TreeEntry.h"
@ -129,14 +129,14 @@ class CheckoutAction {
*
* This will be none if the entry did not exist in the old Tree.
*/
folly::Optional<TreeEntry> oldScmEntry_;
std::optional<TreeEntry> oldScmEntry_;
/**
* The TreeEntry in the new Tree that we are checking out.
*
* This will be none if the entry is deleted in the new Tree.
*/
folly::Optional<TreeEntry> newScmEntry_;
std::optional<TreeEntry> newScmEntry_;
/**
* A Future that will be invoked when the inode is loaded.

View File

@ -95,7 +95,7 @@ void CheckoutContext::addConflict(
// namespace. Therefore parent->getPath() must always return non-none value
// here.
auto parentPath = parent->getPath();
CHECK(parentPath.hasValue());
CHECK(parentPath.has_value());
addConflict(type, parentPath.value() + name);
}
@ -103,7 +103,7 @@ void CheckoutContext::addConflict(
void CheckoutContext::addConflict(ConflictType type, InodeBase* inode) {
// As above, the inode in question must have a path here.
auto path = inode->getPath();
CHECK(path.hasValue());
CHECK(path.has_value());
addConflict(type, path.value());
}
@ -113,7 +113,7 @@ void CheckoutContext::addError(
const folly::exception_wrapper& ew) {
// As above in addConflict(), the parent tree must have a valid path here.
auto parentPath = parent->getPath();
CHECK(parentPath.hasValue());
CHECK(parentPath.has_value());
auto path = parentPath.value() + name;
CheckoutConflict conflict;

View File

@ -9,7 +9,6 @@
*/
#include "eden/fs/inodes/DeferredDiffEntry.h"
#include <folly/Optional.h>
#include <folly/Unit.h>
#include <folly/futures/Future.h>
#include <folly/logging/xlog.h>

View File

@ -8,7 +8,6 @@
*
*/
#include "eden/fs/inodes/Differ.h"
#include <folly/Optional.h>
#include <folly/Synchronized.h>
#include <folly/futures/Future.h>
#include <folly/logging/xlog.h>

View File

@ -8,6 +8,7 @@
*
*/
#pragma once
#include <optional>
#include "eden/fs/fuse/FuseTypes.h"
#include "eden/fs/inodes/InodePtr.h"
#include "eden/fs/model/Hash.h"
@ -81,11 +82,11 @@ class DirEntry {
return hash_;
}
folly::Optional<Hash> getOptionalHash() const {
std::optional<Hash> getOptionalHash() const {
if (hasHash_) {
return hash_;
} else {
return folly::none;
return std::nullopt;
}
}

View File

@ -185,7 +185,7 @@ EdenMount::EdenMount(
clock_(serverState_->getClock()) {}
folly::Future<folly::Unit> EdenMount::initialize(
const folly::Optional<SerializedInodeMap>& takeover) {
const std::optional<SerializedInodeMap>& takeover) {
auto parents = std::make_shared<ParentCommits>(config_->getParentCommits());
parentInfo_.wlock()->parents.setParents(*parents);
@ -234,7 +234,7 @@ folly::Future<TreeInodePtr> EdenMount::createRootInode(
this,
rootOverlayDir->second,
std::move(rootOverlayDir->first),
folly::none);
std::nullopt);
}
return objectStore_->getTreeForCommit(parentCommits.parent1())
.thenValue([this](std::shared_ptr<const Tree> tree) {

View File

@ -19,6 +19,7 @@
#include <chrono>
#include <memory>
#include <mutex>
#include <optional>
#include <shared_mutex>
#include "eden/fs/fuse/EdenStats.h"
#include "eden/fs/fuse/FuseChannel.h"
@ -109,7 +110,7 @@ class EdenMount {
* If takeover data is specified, it is used to initialize the inode map.
*/
FOLLY_NODISCARD folly::Future<folly::Unit> initialize(
const folly::Optional<SerializedInodeMap>& takeover = folly::none);
const std::optional<SerializedInodeMap>& takeover = std::nullopt);
/**
* Destroy the EdenMount.

View File

@ -355,7 +355,7 @@ FileInode::truncateAndRun(LockedState state, Fn&& fn) {
// - If we successfully materialized the file and were in the
// BLOB_LOADING state, fulfill the blobLoadingPromise.
std::shared_ptr<EdenFileHandle> handle;
folly::Optional<folly::SharedPromise<FileHandlePtr>> loadingPromise;
std::optional<folly::SharedPromise<FileHandlePtr>> loadingPromise;
SCOPE_EXIT {
if (loadingPromise) {
loadingPromise->setValue(std::move(handle));
@ -384,6 +384,7 @@ FileInode::truncateAndRun(LockedState state, Fn&& fn) {
// Now that materializeAndTruncate() has succeeded, extract the
// blobLoadingPromise so we can fulfill it as we exit.
loadingPromise = std::move(innerState->blobLoadingPromise);
innerState->blobLoadingPromise.reset();
// Also call materializeInParent() as we exit, before fulfilling the
// blobLoadingPromise.
SCOPE_EXIT {
@ -413,7 +414,7 @@ FileInode::truncateAndRun(LockedState state, Fn&& fn) {
* FileInode::State methods
********************************************************************/
FileInodeState::FileInodeState(const folly::Optional<Hash>& h) : hash(h) {
FileInodeState::FileInodeState(const std::optional<Hash>& h) : hash(h) {
tag = hash ? NOT_LOADED : MATERIALIZED_IN_OVERLAY;
checkInvariants();
@ -527,8 +528,8 @@ FileInode::FileInode(
TreeInodePtr parentInode,
PathComponentPiece name,
mode_t initialMode,
folly::Function<folly::Optional<InodeTimestamps>()> initialTimestampsFn,
const folly::Optional<Hash>& hash)
folly::Function<std::optional<InodeTimestamps>()> initialTimestampsFn,
const std::optional<Hash>& hash)
: Base(
ino,
initialMode,
@ -629,7 +630,7 @@ void FileInode::fileHandleDidClose() {
state->decOpenCount();
}
folly::Optional<bool> FileInode::isSameAsFast(
std::optional<bool> FileInode::isSameAsFast(
const Hash& blobID,
TreeEntryType entryType) {
auto state = state_.rlock();
@ -637,7 +638,7 @@ folly::Optional<bool> FileInode::isSameAsFast(
return false;
}
if (state->hash.hasValue()) {
if (state->hash.has_value()) {
// This file is not materialized, so we can compare blob hashes.
// If the hashes are the same then assume the contents are the same.
//
@ -649,14 +650,14 @@ folly::Optional<bool> FileInode::isSameAsFast(
return true;
}
}
return folly::none;
return std::nullopt;
}
folly::Future<bool> FileInode::isSameAs(
const Blob& blob,
TreeEntryType entryType) {
auto result = isSameAsFast(blob.getHash(), entryType);
if (result.hasValue()) {
if (result.has_value()) {
return result.value();
}
@ -669,7 +670,7 @@ folly::Future<bool> FileInode::isSameAs(
const Hash& blobID,
TreeEntryType entryType) {
auto result = isSameAsFast(blobID, entryType);
if (result.hasValue()) {
if (result.has_value()) {
return makeFuture(result.value());
}
@ -693,7 +694,7 @@ InodeMetadata FileInode::getMetadata() const {
return getMetadataLocked(*lock);
}
folly::Optional<Hash> FileInode::getBlobHash() const {
std::optional<Hash> FileInode::getBlobHash() const {
return state_.rlock()->hash;
}
@ -950,7 +951,7 @@ size_t FileInode::writeImpl(
state.unlock();
auto myname = getPath();
if (myname.hasValue()) {
if (myname.has_value()) {
getMount()->getJournal().addDelta(std::make_unique<JournalDelta>(
std::move(myname.value()), JournalDelta::CHANGED));
}
@ -1021,7 +1022,7 @@ Future<FileInode::FileHandlePtr> FileInode::startLoadingData(
// MATERIALIZED_IN_OVERLAY at this point.
case State::BLOB_LOADING: {
auto promise = std::move(*state->blobLoadingPromise);
state->blobLoadingPromise.clear();
state->blobLoadingPromise.reset();
if (tryBlob.hasValue()) {
// Transition to 'loaded' state.

View File

@ -9,11 +9,11 @@
*/
#pragma once
#include <folly/File.h>
#include <folly/Optional.h>
#include <folly/Synchronized.h>
#include <folly/futures/Future.h>
#include <folly/futures/SharedPromise.h>
#include <chrono>
#include <optional>
#include "eden/fs/inodes/InodeBase.h"
#include "eden/fs/model/Tree.h"
@ -60,7 +60,7 @@ struct FileInodeState {
MATERIALIZED_IN_OVERLAY,
};
explicit FileInodeState(const folly::Optional<Hash>& hash);
explicit FileInodeState(const std::optional<Hash>& hash);
explicit FileInodeState();
~FileInodeState();
@ -101,12 +101,12 @@ struct FileInodeState {
* Set only in 'not loaded', 'loading', and 'loaded' states, none otherwise.
* TODO: Perhaps we ought to simply leave this defined...
*/
folly::Optional<Hash> hash;
std::optional<Hash> hash;
/**
* Set if 'loading'.
*/
folly::Optional<folly::SharedPromise<FileHandlePtr>> blobLoadingPromise;
std::optional<folly::SharedPromise<FileHandlePtr>> blobLoadingPromise;
/**
* Set if 'loaded', references immutable data from the backing store.
@ -162,8 +162,8 @@ class FileInode final : public InodeBaseMetadata<FileInodeState> {
TreeInodePtr parentInode,
PathComponentPiece name,
mode_t initialMode,
folly::Function<folly::Optional<InodeTimestamps>()> initialTimestampsFn,
const folly::Optional<Hash>& hash);
folly::Function<std::optional<InodeTimestamps>()> initialTimestampsFn,
const std::optional<Hash>& hash);
/**
* Construct an inode using a freshly created overlay file.
@ -226,7 +226,7 @@ class FileInode final : public InodeBaseMetadata<FileInodeState> {
/**
* If this file is backed by a source control Blob, return the hash of the
* Blob, or return folly::none if this file is materialized in the overlay.
* Blob, or return std::nullopt if this file is materialized in the overlay.
*
* Beware that the file's materialization state may have changed by the time
* you use the return value of this method. This method is primarily
@ -234,7 +234,7 @@ class FileInode final : public InodeBaseMetadata<FileInodeState> {
* generally cannot be trusted in situations where there may be concurrent
* modifications by other threads.
*/
folly::Optional<Hash> getBlobHash() const;
std::optional<Hash> getBlobHash() const;
/**
* Read the entire file contents, and return them as a string.
@ -388,13 +388,11 @@ class FileInode final : public InodeBaseMetadata<FileInodeState> {
* Helper function for isSameAs().
*
* This does the initial portion of the check which never requires a Future.
* Returns Optional<bool> if the check completes immediately, or
* folly::none if the contents need to be checked against sha1 of file
* Returns optional<bool> if the check completes immediately, or
* std::nullopt if the contents need to be checked against sha1 of file
* contents.
*/
folly::Optional<bool> isSameAsFast(
const Hash& blobID,
TreeEntryType entryType);
std::optional<bool> isSameAsFast(const Hash& blobID, TreeEntryType entryType);
/**
* Recompute the SHA1 content hash of the open file.

View File

@ -26,7 +26,7 @@ namespace eden {
InodeBase::InodeBase(
EdenMount* mount,
folly::Optional<InodeTimestamps> initialTimestamps)
std::optional<InodeTimestamps> initialTimestamps)
: ino_{kRootNodeId},
initialMode_{S_IFDIR | 0755},
mount_{mount},
@ -52,7 +52,7 @@ InodeBase::InodeBase(
InodeBase::InodeBase(
InodeNumber ino,
mode_t initialMode,
folly::Optional<InodeTimestamps> initialTimestamps,
std::optional<InodeTimestamps> initialTimestamps,
TreeInodePtr parent,
PathComponentPiece name)
: ino_{ino},
@ -77,7 +77,7 @@ InodeBase::InodeBase(
InodeBase::InodeBase(
InodeNumber ino,
mode_t initialMode,
folly::Function<folly::Optional<InodeTimestamps>()> initialTimestampsFn,
folly::Function<std::optional<InodeTimestamps>()> initialTimestampsFn,
TreeInodePtr parent,
PathComponentPiece name)
: ino_{ino},
@ -209,14 +209,14 @@ bool InodeBase::getPathHelper(
}
}
folly::Optional<RelativePath> InodeBase::getPath() const {
std::optional<RelativePath> InodeBase::getPath() const {
if (ino_ == kRootNodeId) {
return RelativePath();
}
std::vector<PathComponent> names;
if (!getPathHelper(names, true)) {
return folly::none;
return std::nullopt;
}
return RelativePath(names);
}
@ -417,7 +417,7 @@ const Clock& InodeBase::getClock() const {
// Helper function to update Journal used by FileInode and TreeInode.
void InodeBase::updateJournal() {
auto path = getPath();
if (path.hasValue()) {
if (path.has_value()) {
getMount()->getJournal().addDelta(std::make_unique<JournalDelta>(
std::move(path.value()), JournalDelta::CHANGED));
}

View File

@ -13,6 +13,7 @@
#include <folly/futures/Future.h>
#include <atomic>
#include <memory>
#include <optional>
#include <vector>
#include "eden/fs/fuse/Dispatcher.h"
#include "eden/fs/fuse/FuseTypes.h"
@ -36,9 +37,7 @@ class InodeBase {
* Constructor for the root TreeInode of an EdenMount.
* type is set to dtype_t::Dir
*/
InodeBase(
EdenMount* mount,
folly::Optional<InodeTimestamps> initialTimestamps);
InodeBase(EdenMount* mount, std::optional<InodeTimestamps> initialTimestamps);
/**
* Constructor for all non-root inodes.
@ -46,7 +45,7 @@ class InodeBase {
InodeBase(
InodeNumber ino,
mode_t initialMode,
folly::Optional<InodeTimestamps> initialTimestamps,
std::optional<InodeTimestamps> initialTimestamps,
TreeInodePtr parent,
PathComponentPiece name);
@ -59,7 +58,7 @@ class InodeBase {
InodeBase(
InodeNumber ino,
mode_t initialMode,
folly::Function<folly::Optional<InodeTimestamps>()> initialTimestampsFn,
folly::Function<std::optional<InodeTimestamps>()> initialTimestampsFn,
TreeInodePtr parent,
PathComponentPiece name);
@ -160,14 +159,14 @@ class InodeBase {
/**
* Compute the path to this inode, from the root of the mount point.
*
* This will return the path to the file, or folly::none if the file has
* This will return the path to the file, or std::nullopt if the file has
* been unlinked.
*
* BEWARE: Unless you are holding the mount-point's global rename lock when
* you call this function, the file may have been renamed or unlinked by the
* time you actually use the return value.
*/
folly::Optional<RelativePath> getPath() const;
std::optional<RelativePath> getPath() const;
/**
* Get a string to use to refer to this file in a log message.

View File

@ -46,7 +46,7 @@ const char* InodeError::what() const noexcept {
std::string InodeError::computeMessage() const {
std::string path;
if (child_.hasValue()) {
if (child_.has_value()) {
if (inode_->getNodeId() == kRootNodeId) {
path = child_.value().stringPiece().str();
} else {

View File

@ -10,9 +10,9 @@
#pragma once
#include <folly/Format.h>
#include <folly/Optional.h>
#include <folly/Synchronized.h>
#include <memory>
#include <optional>
#include <system_error>
#include "eden/fs/inodes/InodePtr.h"
#include "eden/fs/utils/PathFuncs.h"
@ -81,7 +81,7 @@ class InodeError : public std::system_error {
std::string computeMessage() const;
InodePtr inode_;
folly::Optional<PathComponent> child_;
std::optional<PathComponent> child_;
std::string message_;
mutable folly::Synchronized<std::string> fullMessage_;
};

View File

@ -23,10 +23,10 @@
#include "eden/fs/utils/Bug.h"
using folly::Future;
using folly::Optional;
using folly::Promise;
using folly::throwSystemErrorExplicit;
using folly::Unit;
using std::optional;
using std::string;
using namespace std::chrono_literals;
@ -45,7 +45,7 @@ InodeMap::UnloadedInode::UnloadedInode(
PathComponentPiece entryName,
bool isUnlinked,
mode_t mode,
folly::Optional<Hash> hash,
std::optional<Hash> hash,
uint32_t fuseRefcount)
: number(num),
parent(parentNum),
@ -60,7 +60,7 @@ InodeMap::UnloadedInode::UnloadedInode(
TreeInode* parent,
PathComponentPiece entryName,
bool isUnlinked,
folly::Optional<Hash> hash,
std::optional<Hash> hash,
uint32_t fuseRefcount)
: number{inode->getNodeId()},
parent{parent->getNodeId()},
@ -145,8 +145,8 @@ void InodeMap::initializeFromTakeover(
PathComponentPiece{entry.name},
entry.isUnlinked,
entry.mode,
entry.hash.empty() ? Optional<Hash>{folly::none}
: Optional<Hash>{hashFromThrift(entry.hash)},
entry.hash.empty() ? std::nullopt
: std::optional<Hash>{hashFromThrift(entry.hash)},
entry.numFuseReferences);
auto result = data->unloadedInodes_.emplace(
@ -292,7 +292,7 @@ void InodeMap::setupParentLookupPromise(
PathComponentPiece childName,
bool isUnlinked,
InodeNumber childInodeNumber,
folly::Optional<Hash> hash,
std::optional<Hash> hash,
mode_t mode) {
promise.getFuture()
.thenValue([name = PathComponent(childName),
@ -314,7 +314,7 @@ void InodeMap::startChildLookup(
PathComponentPiece childName,
bool isUnlinked,
InodeNumber childInodeNumber,
folly::Optional<Hash> hash,
std::optional<Hash> hash,
mode_t mode) {
auto treeInode = parent.asTreePtrOrNull();
if (!treeInode) {
@ -432,13 +432,12 @@ FileInodePtr InodeMap::lookupLoadedFile(InodeNumber number) {
return inode.asFilePtr();
}
folly::Optional<RelativePath> InodeMap::getPathForInode(
InodeNumber inodeNumber) {
std::optional<RelativePath> InodeMap::getPathForInode(InodeNumber inodeNumber) {
auto data = data_.rlock();
return getPathForInodeHelper(inodeNumber, data);
}
folly::Optional<RelativePath> InodeMap::getPathForInodeHelper(
std::optional<RelativePath> InodeMap::getPathForInodeHelper(
InodeNumber inodeNumber,
const folly::Synchronized<Members>::ConstLockedPtr& data) {
auto loadedIt = data->loadedInodes_.find(inodeNumber);
@ -449,7 +448,7 @@ folly::Optional<RelativePath> InodeMap::getPathForInodeHelper(
auto unloadedIt = data->unloadedInodes_.find(inodeNumber);
if (unloadedIt != data->unloadedInodes_.cend()) {
if (unloadedIt->second.isUnlinked) {
return folly::none;
return std::nullopt;
}
// If the inode is not loaded, return its parent's path as long as it's
// parent isn't the root
@ -520,10 +519,10 @@ Future<SerializedInodeMap> InodeMap::shutdown(bool doTakeover) {
auto future = Future<folly::Unit>::makeEmpty();
{
auto data = data_.wlock();
CHECK(!data->shutdownPromise.hasValue())
CHECK(!data->shutdownPromise.has_value())
<< "shutdown() invoked more than once on InodeMap for "
<< mount_->getPath();
data->shutdownPromise.assign(Promise<Unit>{});
data->shutdownPromise.emplace(Promise<Unit>{});
future = data->shutdownPromise->getFuture();
XLOG(DBG3) << "starting InodeMap::shutdown: loadedCount="
@ -662,7 +661,7 @@ void InodeMap::onInodeUnreferenced(
// Decide if we should unload the inode now, or wait until later.
bool unloadNow = false;
bool shuttingDown = data->shutdownPromise.hasValue();
bool shuttingDown = data->shutdownPromise.has_value();
DCHECK(shuttingDown || inode != root_.get());
if (shuttingDown) {
// Check to see if this was the root inode that got unloaded.
@ -750,7 +749,7 @@ void InodeMap::unloadInode(
<< inode->getLogPath();
}
Optional<InodeMap::UnloadedInode> InodeMap::updateOverlayForUnload(
optional<InodeMap::UnloadedInode> InodeMap::updateOverlayForUnload(
InodeBase* inode,
TreeInode* parent,
PathComponentPiece name,
@ -783,7 +782,7 @@ Optional<InodeMap::UnloadedInode> InodeMap::updateOverlayForUnload(
if (data->isUnmounted_) {
XLOG(DBG5) << "forgetting unreferenced inode " << inode->getNodeId()
<< " after unmount: " << inode->getLogPath();
return folly::none;
return std::nullopt;
}
// If the tree is unlinked and no longer referenced we can delete it from
@ -791,7 +790,7 @@ Optional<InodeMap::UnloadedInode> InodeMap::updateOverlayForUnload(
if (isUnlinked && fuseCount == 0) {
XLOG(DBG5) << "forgetting unreferenced unlinked inode "
<< inode->getNodeId() << ": " << inode->getLogPath();
return folly::none;
return std::nullopt;
}
auto* asTree = dynamic_cast<TreeInode*>(inode);
@ -840,7 +839,7 @@ Optional<InodeMap::UnloadedInode> InodeMap::updateOverlayForUnload(
fuseCount);
}
}
return folly::none;
return std::nullopt;
} else {
// We have to remember files only if their FUSE refcount is non-zero
if (fuseCount > 0) {
@ -852,7 +851,7 @@ Optional<InodeMap::UnloadedInode> InodeMap::updateOverlayForUnload(
} else {
XLOG(DBG5) << "forgetting unreferenced file inode " << inode->getNodeId()
<< " : " << inode->getLogPath();
return folly::none;
return std::nullopt;
}
}
}

View File

@ -13,6 +13,7 @@
#include <folly/futures/Future.h>
#include <list>
#include <memory>
#include <optional>
#include <unordered_map>
#include "eden/fs/fuse/FuseChannel.h"
@ -212,9 +213,9 @@ class InodeMap {
* queries the parent nodes).
*
* If there is an unlinked inode in the path, this function returns
* folly::none. If the inode is invalid, it throws EINVAL.
* std::nullopt. If the inode is invalid, it throws EINVAL.
*/
folly::Optional<RelativePath> getPathForInode(InodeNumber inodeNumber);
std::optional<RelativePath> getPathForInode(InodeNumber inodeNumber);
/**
* Decrement the number of outstanding FUSE references to an inode number.
@ -404,14 +405,14 @@ class InodeMap {
PathComponentPiece entryName,
bool isUnlinked,
mode_t mode,
folly::Optional<Hash> hash,
std::optional<Hash> hash,
uint32_t fuseRefcount);
UnloadedInode(
TreeInode* inode,
TreeInode* parent,
PathComponentPiece entryName,
bool isUnlinked,
folly::Optional<Hash> hash,
std::optional<Hash> hash,
uint32_t fuseRefcount);
UnloadedInode(
FileInode* inode,
@ -439,7 +440,7 @@ class InodeMap {
*
* If the entry is materialized, this field is not set.
*/
folly::Optional<Hash> const hash;
std::optional<Hash> const hash;
/**
* A list of promises waiting on this inode to be loaded.
@ -521,14 +522,14 @@ class InodeMap {
* A promise to fulfill once shutdown() completes.
*
* This is only initialized when shutdown() is called, and will be
* folly::none until we are shutting down.
* std::nullopt until we are shutting down.
*
* In the future we could update this to just use an empty promise to
* indicate that we are not shutting down yet. However, currently
* folly::Promise does not have a simple API to check if it is empty or not,
* so we have to wrap it in a folly::Optional.
* so we have to wrap it in a std::optional.
*/
folly::Optional<folly::Promise<folly::Unit>> shutdownPromise;
std::optional<folly::Promise<folly::Unit>> shutdownPromise;
};
InodeMap(InodeMap const&) = delete;
@ -541,14 +542,14 @@ class InodeMap {
PathComponentPiece childName,
bool isUnlinked,
InodeNumber childInodeNumber,
folly::Optional<Hash> hash,
std::optional<Hash> hash,
mode_t mode);
void startChildLookup(
const InodePtr& parent,
PathComponentPiece childName,
bool isUnlinked,
InodeNumber childInodeNumber,
folly::Optional<Hash> hash,
std::optional<Hash> hash,
mode_t mode);
/**
@ -560,7 +561,7 @@ class InodeMap {
*/
PromiseVector extractPendingPromises(InodeNumber number);
folly::Optional<RelativePath> getPathForInodeHelper(
std::optional<RelativePath> getPathForInodeHelper(
InodeNumber inodeNumber,
const folly::Synchronized<Members>::ConstLockedPtr& data);
@ -585,9 +586,9 @@ class InodeMap {
* This is called as the first step of unloadInode().
*
* This returns an UnloadedInode if we need to remember this inode in the
* unloadedInodes_ map, or folly::none if we can forget about it completely.
* unloadedInodes_ map, or std::nullopt if we can forget about it completely.
*/
folly::Optional<UnloadedInode> updateOverlayForUnload(
std::optional<UnloadedInode> updateOverlayForUnload(
InodeBase* inode,
TreeInode* parent,
PathComponentPiece name,

View File

@ -151,13 +151,13 @@ class InodeTable {
/**
* If the table has an entry for this inode, returns it. Otherwise, returns
* folly::none.
* std::nullopt.
*/
folly::Optional<Record> getOptional(InodeNumber ino) {
return state_.withRLock([&](const auto& state) -> folly::Optional<Record> {
std::optional<Record> getOptional(InodeNumber ino) {
return state_.withRLock([&](const auto& state) -> std::optional<Record> {
auto iter = state.indices.find(ino);
if (iter == state.indices.end()) {
return folly::none;
return std::nullopt;
} else {
auto index = iter->second;
CHECK_LT(index, state.storage.size());

View File

@ -33,8 +33,8 @@ using folly::fbvector;
using folly::File;
using folly::IOBuf;
using folly::MutableStringPiece;
using folly::Optional;
using folly::StringPiece;
using std::optional;
using folly::literals::string_piece_literals::operator""_sp;
using std::string;
@ -339,12 +339,12 @@ InodeNumber Overlay::allocateInodeNumber() {
return InodeNumber{previous};
}
Optional<std::pair<DirContents, InodeTimestamps>> Overlay::loadOverlayDir(
optional<std::pair<DirContents, InodeTimestamps>> Overlay::loadOverlayDir(
InodeNumber inodeNumber) {
InodeTimestamps timestamps;
auto dirData = deserializeOverlayDir(inodeNumber, timestamps);
if (!dirData.hasValue()) {
return folly::none;
if (!dirData.has_value()) {
return std::nullopt;
}
const auto& dir = dirData.value();
@ -503,7 +503,7 @@ InodeNumber Overlay::scanForNextInodeNumber() {
toProcess.pop_back();
InodeTimestamps timeStamps;
auto dir = Optional<overlay::OverlayDir>{};
auto dir = optional<overlay::OverlayDir>{};
try {
dir = deserializeOverlayDir(dirInodeNumber, timeStamps);
} catch (std::system_error& error) {
@ -512,7 +512,7 @@ InodeNumber Overlay::scanForNextInodeNumber() {
<< ": " << error.what();
encounteredBrokenDirectory = true;
}
if (!dir.hasValue()) {
if (!dir.has_value()) {
continue;
}
@ -565,17 +565,17 @@ Overlay::InodePath Overlay::getFilePath(InodeNumber inodeNumber) {
return outPath;
}
Optional<overlay::OverlayDir> Overlay::deserializeOverlayDir(
optional<overlay::OverlayDir> Overlay::deserializeOverlayDir(
InodeNumber inodeNumber,
InodeTimestamps& timeStamps) const {
// Open the file. Return folly::none if the file does not exist.
// Open the file. Return std::nullopt if the file does not exist.
auto path = getFilePath(inodeNumber);
int fd = openat(dirFile_.fd(), path.c_str(), O_RDWR | O_CLOEXEC | O_NOFOLLOW);
if (fd == -1) {
int err = errno;
if (err == ENOENT) {
// There is no overlay here
return folly::none;
return std::nullopt;
}
folly::throwSystemErrorExplicit(
err,
@ -592,7 +592,7 @@ Optional<overlay::OverlayDir> Overlay::deserializeOverlayDir(
int err = errno;
if (err == ENOENT) {
// There is no overlay here
return folly::none;
return std::nullopt;
}
folly::throwSystemErrorExplicit(
errno, "failed to read ", RelativePathPiece{path});
@ -945,7 +945,7 @@ void Overlay::handleGCRequest(GCRequest& request) {
try {
InodeTimestamps dummy;
auto dirData = deserializeOverlayDir(ino, dummy);
if (!dirData.hasValue()) {
if (!dirData.has_value()) {
XLOG(DBG3) << "no dir data for inode " << ino;
continue;
} else {

View File

@ -9,12 +9,12 @@
*/
#pragma once
#include <folly/File.h>
#include <folly/Optional.h>
#include <folly/Range.h>
#include <folly/futures/Promise.h>
#include <gtest/gtest_prod.h>
#include <array>
#include <condition_variable>
#include <optional>
#include <thread>
#include "eden/fs/fuse/FuseTypes.h"
#include "eden/fs/inodes/InodeTimestamps.h"
@ -129,7 +129,7 @@ class Overlay {
const DirContents& dir,
const InodeTimestamps& timestamps);
folly::Optional<std::pair<DirContents, InodeTimestamps>> loadOverlayDir(
std::optional<std::pair<DirContents, InodeTimestamps>> loadOverlayDir(
InodeNumber inodeNumber);
void removeOverlayData(InodeNumber inodeNumber);
@ -218,7 +218,7 @@ class Overlay {
overlay::OverlayDir dir;
// Iff set, this is a flush request.
folly::Optional<folly::Promise<folly::Unit>> flush;
std::optional<folly::Promise<folly::Unit>> flush;
};
struct GCQueue {
@ -233,7 +233,7 @@ class Overlay {
void initNewOverlay();
void ensureTmpDirectoryIsCreated();
folly::Optional<overlay::OverlayDir> deserializeOverlayDir(
std::optional<overlay::OverlayDir> deserializeOverlayDir(
InodeNumber inodeNumber,
InodeTimestamps& timeStamps) const;

View File

@ -51,10 +51,10 @@
using folly::ByteRange;
using folly::Future;
using folly::makeFuture;
using folly::Optional;
using folly::StringPiece;
using folly::Unit;
using std::make_unique;
using std::optional;
using std::shared_ptr;
using std::unique_ptr;
using std::vector;
@ -136,7 +136,7 @@ TreeInode::TreeInode(
parent,
name,
initialMode,
folly::none,
std::nullopt,
saveDirFromTree(ino, tree.get(), parent->getMount()),
tree->getHash()) {}
@ -145,9 +145,9 @@ TreeInode::TreeInode(
TreeInodePtr parent,
PathComponentPiece name,
mode_t initialMode,
folly::Function<folly::Optional<InodeTimestamps>()> initialTimestampsFn,
folly::Function<std::optional<InodeTimestamps>()> initialTimestampsFn,
DirContents&& dir,
folly::Optional<Hash> treeHash)
std::optional<Hash> treeHash)
: Base(ino, initialMode, std::move(initialTimestampsFn), parent, name),
contents_(folly::in_place, std::move(dir), treeHash) {
DCHECK_NE(ino, kRootNodeId);
@ -158,9 +158,9 @@ TreeInode::TreeInode(
TreeInodePtr parent,
PathComponentPiece name,
mode_t initialMode,
folly::Optional<InodeTimestamps> initialTimestamps,
std::optional<InodeTimestamps> initialTimestamps,
DirContents&& dir,
folly::Optional<Hash> treeHash)
std::optional<Hash> treeHash)
: Base(ino, initialMode, initialTimestamps, parent, name),
contents_(folly::in_place, std::move(dir), treeHash) {
DCHECK_NE(ino, kRootNodeId);
@ -169,15 +169,15 @@ TreeInode::TreeInode(
TreeInode::TreeInode(EdenMount* mount, std::shared_ptr<const Tree>&& tree)
: TreeInode(
mount,
folly::none,
std::nullopt,
saveDirFromTree(kRootNodeId, tree.get(), mount),
tree->getHash()) {}
TreeInode::TreeInode(
EdenMount* mount,
folly::Optional<InodeTimestamps> initialTimestamps,
std::optional<InodeTimestamps> initialTimestamps,
DirContents&& dir,
folly::Optional<Hash> treeHash)
std::optional<Hash> treeHash)
: Base(mount, initialTimestamps),
contents_(folly::in_place, std::move(dir), treeHash) {}
@ -207,18 +207,18 @@ folly::Future<InodePtr> TreeInode::getChildByName(
Future<InodePtr> TreeInode::getOrLoadChild(PathComponentPiece name) {
return tryRlockCheckBeforeUpdate<Future<InodePtr>>(
contents_,
[&](const auto& contents) -> folly::Optional<Future<InodePtr>> {
[&](const auto& contents) -> std::optional<Future<InodePtr>> {
// Check if the child is already loaded and return it if so
auto iter = contents.entries.find(name);
if (iter == contents.entries.end()) {
if (name == kDotEdenName && getNodeId() != kRootNodeId) {
return folly::make_optional(getInodeMap()->lookupInode(
return std::make_optional(getInodeMap()->lookupInode(
getMount()->getDotEdenInodeNumber()));
}
XLOG(DBG7) << "attempted to load non-existent entry \"" << name
<< "\" in " << getLogPath();
return folly::make_optional(makeFuture<InodePtr>(
return std::make_optional(makeFuture<InodePtr>(
InodeError(ENOENT, inodePtrFromThis(), name)));
}
@ -227,7 +227,7 @@ Future<InodePtr> TreeInode::getOrLoadChild(PathComponentPiece name) {
if (entry.getInode()) {
return makeFuture<InodePtr>(entry.getInodePtr());
}
return folly::none;
return std::nullopt;
},
[&](auto& contents) {
auto inodeLoadFuture = Future<unique_ptr<InodeBase>>::makeEmpty();
@ -352,7 +352,7 @@ InodeNumber TreeInode::getChildInodeNumber(PathComponentPiece name) {
void TreeInode::loadUnlinkedChildInode(
PathComponentPiece name,
InodeNumber number,
folly::Optional<Hash> hash,
std::optional<Hash> hash,
mode_t mode) {
try {
InodeMap::PromiseVector promises;
@ -364,11 +364,11 @@ void TreeInode::loadUnlinkedChildInode(
inodePtrFromThis(),
name,
mode,
[&]() -> folly::Optional<InodeTimestamps> {
[&]() -> std::optional<InodeTimestamps> {
// If this inode does not have timestamps in the metadata table but
// does in the overlay, migrate.
if (hash) {
return folly::none;
return std::nullopt;
} else {
InodeTimestamps fromOverlay;
(void)getMount()->getOverlay()->openFile(
@ -381,7 +381,7 @@ void TreeInode::loadUnlinkedChildInode(
inodePtr = InodePtr::takeOwnership(std::move(file));
} else {
DirContents dir;
folly::Optional<InodeTimestamps> fromOverlay;
std::optional<InodeTimestamps> fromOverlay;
auto overlayContents = getOverlay()->loadOverlayDir(number);
if (overlayContents) {
@ -548,7 +548,7 @@ Future<unique_ptr<InodeBase>> TreeInode::startLoadingInodeNoThrow(
template <typename T>
inline std::ostream& operator<<(
std::ostream& os,
const folly::Optional<T>& value) {
const std::optional<T>& value) {
if (value) {
return os << "some(" << *value << ")";
} else {
@ -573,7 +573,7 @@ static std::vector<std::string> computeEntryDifferences(
return std::vector<std::string>{differences.begin(), differences.end()};
}
folly::Optional<std::vector<std::string>> findEntryDifferences(
std::optional<std::vector<std::string>> findEntryDifferences(
const DirContents& dir,
const Tree& tree) {
// Avoid allocations in the case where the tree and dir agree.
@ -585,7 +585,7 @@ folly::Optional<std::vector<std::string>> findEntryDifferences(
return computeEntryDifferences(dir, tree);
}
}
return folly::none;
return std::nullopt;
}
Future<unique_ptr<InodeBase>> TreeInode::startLoadingInode(
@ -606,12 +606,12 @@ Future<unique_ptr<InodeBase>> TreeInode::startLoadingInode(
inodePtrFromThis(),
name,
entry.getInitialMode(),
[&]() -> folly::Optional<InodeTimestamps> {
[&]() -> std::optional<InodeTimestamps> {
// If this inode doesn't have timestamps in the inode metadata table
// but does in the overlay, use them.
if (entry.getOptionalHash()) {
// Only materialized files exist in the overlay.
return folly::none;
return std::nullopt;
}
InodeTimestamps fromOverlay;
(void)getMount()->getOverlay()->openFile(
@ -686,7 +686,7 @@ Future<unique_ptr<InodeBase>> TreeInode::startLoadingInode(
entry.getInitialMode(),
overlayDir->second,
std::move(overlayDir->first),
folly::none);
std::nullopt);
} // namespace eden
std::shared_ptr<DirHandle> TreeInode::opendir() {
@ -833,7 +833,7 @@ Overlay* TreeInode::getOverlay() const {
return getMount()->getOverlay();
}
folly::Optional<std::pair<DirContents, InodeTimestamps>>
std::optional<std::pair<DirContents, InodeTimestamps>>
TreeInode::loadOverlayDir(InodeNumber inodeNumber) const {
return getOverlay()->loadOverlayDir(inodeNumber);
}
@ -922,7 +922,7 @@ FileInodePtr TreeInode::createImpl(
// Make sure this directory has not been unlinked.
// We have to check this after acquiring the contents_ lock; otherwise
// we could race with rmdir() or rename() calls affecting us.
if (!myPath.hasValue()) {
if (!myPath.has_value()) {
throw InodeError(ENOENT, inodePtrFromThis());
}
@ -1082,7 +1082,7 @@ TreeInodePtr TreeInode::mkdir(PathComponentPiece name, mode_t mode) {
// Make sure this directory has not been unlinked.
// We have to check this after acquiring the contents_ lock; otherwise
// we could race with rmdir() or rename() calls affecting us.
if (!myPath.hasValue()) {
if (!myPath.has_value()) {
throw InodeError(ENOENT, inodePtrFromThis());
}
// Compute the target path, so we can record it in the journal below.
@ -1121,7 +1121,7 @@ TreeInodePtr TreeInode::mkdir(PathComponentPiece name, mode_t mode) {
mode,
childTimestamps,
std::move(emptyDir),
folly::none);
std::nullopt);
entry.setInode(newChild.get());
getInodeMap()->inodeCreated(newChild);
@ -1178,7 +1178,7 @@ folly::Future<folly::Unit> TreeInode::removeImpl(
// Make sure we only do this after we acquire the rename lock, so that the
// path reported in the journal will be accurate.
auto myPath = getPath();
if (!myPath.hasValue()) {
if (!myPath.has_value()) {
// It appears we have already been unlinked. It's possible someone other
// thread has already renamed child to another location and unlinked us.
// Just fail with ENOENT in this case.
@ -1653,7 +1653,7 @@ Future<Unit> TreeInode::doRename(
// Add a journal entry
auto srcPath = getPath();
auto destPath = destParent->getPath();
if (srcPath.hasValue() && destPath.hasValue()) {
if (srcPath.has_value() && destPath.has_value()) {
if (destChildExists) {
getMount()->getJournal().addDelta(std::make_unique<JournalDelta>(
srcPath.value() + srcName,
@ -2358,7 +2358,7 @@ void TreeInode::computeCheckoutActions(
// If we are the same as some known source control Tree, check to see if we
// can quickly tell if we have nothing to do for this checkout operation and
// can return early.
if (contents->treeHash.hasValue() &&
if (contents->treeHash.has_value() &&
canShortCircuitCheckout(
ctx, contents->treeHash.value(), fromTree, toTree)) {
return;
@ -2612,7 +2612,7 @@ Future<Unit> TreeInode::checkoutUpdateEntry(
InodePtr inode,
std::shared_ptr<const Tree> oldTree,
std::shared_ptr<const Tree> newTree,
const folly::Optional<TreeEntry>& newScmEntry) {
const std::optional<TreeEntry>& newScmEntry) {
auto treeInode = inode.asTreePtrOrNull();
if (!treeInode) {
// If the target of the update is not a directory, then we know we do not
@ -2669,7 +2669,7 @@ Future<Unit> TreeInode::checkoutUpdateEntry(
if (newTree) {
// TODO: Also apply permissions changes to the entry.
CHECK(newScmEntry.hasValue());
CHECK(newScmEntry.has_value());
CHECK(newScmEntry->isTree());
return treeInode->checkout(ctx, std::move(oldTree), std::move(newTree));
}
@ -2773,20 +2773,20 @@ void TreeInode::saveOverlayPostCheckout(
//
// If we can confirm that we are identical to the source control Tree we do
// not need to be materialized.
auto tryToDematerialize = [&]() -> folly::Optional<Hash> {
auto tryToDematerialize = [&]() -> std::optional<Hash> {
// If the new tree does not exist in source control, we must be
// materialized, since there is no source control Tree to refer to.
// (If we are empty in this case we will set deleteSelf and try to remove
// ourself entirely.)
if (!tree) {
return folly::none;
return std::nullopt;
}
const auto& scmEntries = tree->getTreeEntries();
// If we have a different number of entries we must be different from the
// Tree, and therefore must be materialized.
if (scmEntries.size() != contents->entries.size()) {
return folly::none;
return std::nullopt;
}
// This code relies on the fact that our contents->entries PathMap sorts
@ -2804,14 +2804,14 @@ void TreeInode::saveOverlayPostCheckout(
// control state we still want to make sure we are materialized if the
// child is.
if (inodeIter->second.isMaterialized()) {
return folly::none;
return std::nullopt;
}
// If the child is not materialized, it is the same as some source
// control object. However, if it isn't the same as the object in our
// Tree, we have to materialize ourself.
if (inodeIter->second.getHash() != scmIter->getHash()) {
return folly::none;
return std::nullopt;
}
}
@ -3181,7 +3181,7 @@ void TreeInode::getDebugStatus(vector<TreeInodeDebugInfo>& results) const {
info.refcount = debugGetFuseRefcount();
auto myPath = getPath();
if (myPath.hasValue()) {
if (myPath.has_value()) {
info.path = myPath.value().stringPiece().str();
}
@ -3231,7 +3231,7 @@ void TreeInode::getDebugStatus(vector<TreeInodeDebugInfo>& results) const {
// and grab the materialization and status info now.
{
auto childContents = childTree->contents_.rlock();
infoEntry.materialized = !childContents->treeHash.hasValue();
infoEntry.materialized = !childContents->treeHash.has_value();
infoEntry.hash = thriftHash(childContents->treeHash);
// TODO: We don't currently store mode data for TreeInodes. We should.
infoEntry.mode = (S_IFDIR | 0755);
@ -3241,7 +3241,7 @@ void TreeInode::getDebugStatus(vector<TreeInodeDebugInfo>& results) const {
infoEntry.mode = childFile->getMode();
auto blobHash = childFile->getBlobHash();
infoEntry.materialized = !blobHash.hasValue();
infoEntry.materialized = !blobHash.has_value();
infoEntry.hash = thriftHash(blobHash);
}
}

View File

@ -9,9 +9,9 @@
*/
#pragma once
#include <folly/File.h>
#include <folly/Optional.h>
#include <folly/Portability.h>
#include <folly/Synchronized.h>
#include <optional>
#include "eden/fs/inodes/DirEntry.h"
#include "eden/fs/inodes/InodeBase.h"
@ -39,14 +39,14 @@ constexpr folly::StringPiece kDotEdenName{".eden"};
* The state of a TreeInode as held in memory.
*/
struct TreeInodeState {
explicit TreeInodeState(DirContents&& dir, folly::Optional<Hash> hash)
explicit TreeInodeState(DirContents&& dir, std::optional<Hash> hash)
: entries{std::forward<DirContents>(dir)}, treeHash{hash} {}
bool isMaterialized() const {
return !treeHash.hasValue();
return !treeHash.has_value();
}
void setMaterialized() {
treeHash = folly::none;
treeHash = std::nullopt;
}
DirContents entries;
@ -60,7 +60,7 @@ struct TreeInodeState {
* control, and backed by the Overlay instead of a source control Tree),
* treeHash will be none.
*/
folly::Optional<Hash> treeHash;
std::optional<Hash> treeHash;
};
/**
@ -107,9 +107,9 @@ class TreeInode final : public InodeBaseMetadata<DirContents> {
TreeInodePtr parent,
PathComponentPiece name,
mode_t initialMode,
folly::Function<folly::Optional<InodeTimestamps>()> initialTimestampsFn,
folly::Function<std::optional<InodeTimestamps>()> initialTimestampsFn,
DirContents&& dir,
folly::Optional<Hash> treeHash);
std::optional<Hash> treeHash);
/**
* Construct an inode that only has backing in the Overlay area.
@ -119,9 +119,9 @@ class TreeInode final : public InodeBaseMetadata<DirContents> {
TreeInodePtr parent,
PathComponentPiece name,
mode_t initialMode,
folly::Optional<InodeTimestamps> initialTimestamps,
std::optional<InodeTimestamps> initialTimestamps,
DirContents&& dir,
folly::Optional<Hash> treeHash);
std::optional<Hash> treeHash);
/**
* Construct the root TreeInode from a source control commit's root.
@ -133,9 +133,9 @@ class TreeInode final : public InodeBaseMetadata<DirContents> {
*/
TreeInode(
EdenMount* mount,
folly::Optional<InodeTimestamps> initialTimestamps,
std::optional<InodeTimestamps> initialTimestamps,
DirContents&& dir,
folly::Optional<Hash> treeHash);
std::optional<Hash> treeHash);
~TreeInode() override;
@ -323,7 +323,7 @@ class TreeInode final : public InodeBaseMetadata<DirContents> {
void loadUnlinkedChildInode(
PathComponentPiece name,
InodeNumber number,
folly::Optional<Hash> hash,
std::optional<Hash> hash,
mode_t mode);
/**
@ -390,7 +390,7 @@ class TreeInode final : public InodeBaseMetadata<DirContents> {
* will be null if this entry does not exist or if it refers to a Blob in
* the source commit.
* @param newScmEntry The desired source control state for the new entry,
* or folly::none if the entry does not exist in the destination commit.
* or std::nullopt if the entry does not exist in the destination commit.
* This entry will refer to a tree if and only if the newTree parameter
* is non-null.
*/
@ -400,7 +400,7 @@ class TreeInode final : public InodeBaseMetadata<DirContents> {
InodePtr inode,
std::shared_ptr<const Tree> oldTree,
std::shared_ptr<const Tree> newTree,
const folly::Optional<TreeEntry>& newScmEntry);
const std::optional<TreeEntry>& newScmEntry);
/**
* Get debug data about this TreeInode and all of its children (recursively).
@ -475,7 +475,7 @@ class TreeInode final : public InodeBaseMetadata<DirContents> {
/**
* Loads a tree from the overlay given an inode number.
*/
folly::Optional<std::pair<DirContents, InodeTimestamps>> loadOverlayDir(
std::optional<std::pair<DirContents, InodeTimestamps>> loadOverlayDir(
InodeNumber inodeNumber) const;
/**
@ -707,7 +707,7 @@ class TreeInode final : public InodeBaseMetadata<DirContents> {
* An internal function which computes the difference between a Dir and a tree
* as a set of strings starting with + and - followed by the entry name.
*/
folly::Optional<std::vector<std::string>> findEntryDifferences(
std::optional<std::vector<std::string>> findEntryDifferences(
const DirContents& dir,
const Tree& tree);

View File

@ -8,7 +8,6 @@
*
*/
#include <folly/Conv.h>
#include <folly/Optional.h>
#include <folly/chrono/Conv.h>
#include <folly/container/Array.h>
#include <folly/test/TestUtils.h>
@ -33,9 +32,9 @@ using namespace facebook::eden;
using namespace std::chrono_literals;
using folly::Future;
using folly::makeFuture;
using folly::Optional;
using folly::StringPiece;
using folly::Unit;
using std::optional;
using std::string;
using std::chrono::system_clock;
using testing::UnorderedElementsAre;
@ -146,7 +145,7 @@ void loadInodes(
TestMount& testMount,
RelativePathPiece path,
LoadBehavior loadType,
folly::Optional<folly::StringPiece> expectedContents,
std::optional<folly::StringPiece> expectedContents,
mode_t expectedPerms) {
switch (loadType) {
case LoadBehavior::NONE:
@ -169,7 +168,7 @@ void loadInodes(
return;
}
case LoadBehavior::INODE: {
if (expectedContents.hasValue()) {
if (expectedContents.has_value()) {
// The inode in question must be a file. Load it and verify the
// contents are what we expect.
auto fileInode = testMount.getFileInode(path);
@ -206,14 +205,14 @@ void loadInodes(
TestMount& testMount,
RelativePathPiece path,
LoadBehavior loadType) {
loadInodes(testMount, path, loadType, folly::none, 0644);
loadInodes(testMount, path, loadType, std::nullopt, 0644);
}
void loadInodes(
TestMount& testMount,
folly::StringPiece path,
LoadBehavior loadType) {
loadInodes(testMount, RelativePathPiece{path}, loadType, folly::none, 0644);
loadInodes(testMount, RelativePathPiece{path}, loadType, std::nullopt, 0644);
}
CheckoutConflict
@ -352,7 +351,7 @@ void testModifyFile(
loadInodes(testMount, path, loadType, contents1, perms1);
Optional<struct stat> preStat;
optional<struct stat> preStat;
// If we were supposed to load this inode before the checkout,
// also store its stat information so we can compare it after the checkout.
if (loadType == LoadBehavior::INODE || loadType == LoadBehavior::ALL) {
@ -380,7 +379,7 @@ void testModifyFile(
folly::to<system_clock::time_point>(postStat.st_mtim), checkoutStart);
EXPECT_GE(
folly::to<system_clock::time_point>(postStat.st_ctim), checkoutStart);
if (preStat.hasValue()) {
if (preStat.has_value()) {
EXPECT_GE(
folly::to<system_clock::time_point>(postStat.st_atim),
folly::to<system_clock::time_point>(preStat->st_atim));

View File

@ -26,7 +26,7 @@
#include "eden/fs/testharness/TestUtil.h"
using namespace std::chrono_literals;
using folly::Optional;
using std::optional;
using namespace facebook::eden;
TEST(EdenMount, initFailure) {

View File

@ -271,13 +271,13 @@ class RawOverlayTest : public ::testing::TestWithParam<OverlayRestartMode> {
loadOverlay();
}
void recreate(folly::Optional<OverlayRestartMode> restartMode = folly::none) {
void recreate(std::optional<OverlayRestartMode> restartMode = std::nullopt) {
unloadOverlay(restartMode);
loadOverlay();
}
void unloadOverlay(
folly::Optional<OverlayRestartMode> restartMode = folly::none) {
std::optional<OverlayRestartMode> restartMode = std::nullopt) {
overlay->close();
overlay.reset();
switch (restartMode.value_or(GetParam())) {

View File

@ -17,7 +17,6 @@
#include "eden/fs/testharness/TestMount.h"
using namespace std::chrono_literals;
using folly::Optional;
using namespace facebook::eden;
namespace {

View File

@ -40,7 +40,7 @@ mode_t modeFromTreeEntryType(TreeEntryType ft);
/**
* Converts an arbitrary mode_t to the appropriate TreeEntryType if the file
* can be tracked by version control. If not, returns folly::none.
* can be tracked by version control. If not, returns std::nullopt.
*/
std::optional<TreeEntryType> treeEntryTypeFromMode(mode_t mode);

View File

@ -29,7 +29,7 @@ class GitIgnorePattern {
/**
* Parse a line from a gitignore file.
*
* Returns a GitIgnorePattern, or folly::none if the line did not contain a
* Returns a GitIgnorePattern, or std::nullopt if the line did not contain a
* pattern (e.g., if it was empty or a comment).
*/
static std::optional<GitIgnorePattern> parseLine(folly::StringPiece line);

View File

@ -817,8 +817,8 @@ folly::Future<std::shared_ptr<EdenMount>> EdenServer::mount(
std::move(initialConfig), std::move(objectStore), serverState_);
auto initFuture = edenMount->initialize(
optionalTakeover ? folly::make_optional(optionalTakeover->inodeMap)
: folly::none);
optionalTakeover ? std::make_optional(optionalTakeover->inodeMap)
: std::nullopt);
return std::move(initFuture)
.thenValue([this,
doTakeover,

View File

@ -1104,7 +1104,7 @@ void EdenServiceHandler::debugGetInodePath(
// Check if the inode is loaded
info.loaded = inodeMap->lookupLoadedInode(inodeNum) != nullptr;
// If getPathForInode returned none then the inode is unlinked
info.linked = relativePath != folly::none;
info.linked = relativePath != std::nullopt;
info.path = relativePath ? relativePath->stringPiece().str() : "";
#else
NOT_IMPLEMENTED();

View File

@ -38,16 +38,6 @@ inline std::string thriftHash(const std::optional<Hash>& hash) {
return std::string{};
}
/**
* TODO: remove this
*/
inline std::string thriftHash(const folly::Optional<Hash>& hash) {
if (hash.has_value()) {
return thriftHash(hash.value());
}
return std::string{};
}
/**
* Convert thrift BinaryHash data type into a Hash object.
*

View File

@ -144,7 +144,7 @@ class LocalStore {
/**
* Get the size of a blob and the SHA-1 hash of its contents.
*
* Returns folly::none if this key is not present in the store, or throws an
* Returns std::nullopt if this key is not present in the store, or throws an
* exception on error.
*/
folly::Future<std::optional<BlobMetadata>> getBlobMetadata(

View File

@ -172,7 +172,7 @@ AbsolutePath canonicalPathImpl(
} // namespace
AbsolutePath canonicalPath(folly::StringPiece path) {
// Pass in folly::none.
// Pass in std::nullopt.
// canonicalPathImpl() will only call getcwd() if it is actually necessary.
return canonicalPathImpl(path, std::nullopt);
}

View File

@ -37,22 +37,13 @@ class ScopedEnvVar {
private:
/**
* The environment variable name, or folly::none if this object has been
* moved-away from.
*
* We could just use a std::string instead of std::optional<std::string>,
* and used an empty string to indicate that this ScopedEnvVar has been
* moved-away from. However, then we would have to implement our own custom
* move constructor and move assignment operator to clear the name in the
* moved-from object. With std::optional the moved-from value is
* guaranteed to be cleared automatically, while this is not guaranteed with
* std::string.
* The environment variable name.
*/
std::optional<std::string> name_;
/**
* The original value of this environment variable that we should restore it
* to on destruction of this ScopedEnvVar. This will be folly::none if the
* to on destruction of this ScopedEnvVar. This will be std::nullopt if the
* environment variable was originally unset, and should be unset on
* destruction.
*/

View File

@ -108,7 +108,7 @@ class EdenMount {
* If takeover data is specified, it is used to initialize the inode map.
*/
FOLLY_NODISCARD folly::Future<folly::Unit> initialize(
const folly::Optional<SerializedInodeMap>& takeover = folly::none);
const std::optional<SerializedInodeMap>& takeover = std::nullopt);
/**
* Destroy the EdenMount.

View File

@ -106,7 +106,7 @@ class StartupLogger {
[[noreturn]] void failAndExit(uint8_t exitCode);
folly::Optional<std::pair<pid_t, folly::File>> daemonizeImpl(
std::optional<std::pair<pid_t, folly::File>> daemonizeImpl(
folly::StringPiece logPath);
/**

View File

@ -145,7 +145,7 @@ void runServer(const EdenServer& server);
} // namespace facebook
void startServer() {
folly::Optional<EdenServer> server;
std::optional<EdenServer> server;
UserInfo identity;
auto privHelper = make_unique<PrivHelper>();