Revert "SERVER-105043 LLVM 22 lint and format"

GitOrigin-RevId: 0244d545e453b3f667051f71ca643a821afaf84b
This commit is contained in:
Daniel Moody 2026-05-18 16:07:54 +00:00 committed by MongoDB Bot
parent a8826bd5d7
commit bd87181dd2
100 changed files with 632 additions and 326 deletions

4
MODULE.bazel.lock generated
View File

@ -249,7 +249,7 @@
"moduleExtensions": {
"//bazel:bzlmod.bzl%bazel_features_deps": {
"general": {
"bzlTransitiveDigest": "G/WD+JnQT596GnXuqRV363uynmjbkk1qeefCHRtgT3Y=",
"bzlTransitiveDigest": "dfSpTD7th7o+ah0Usp81y/clMRt3Eyfz/Ey59BcBl68=",
"usagesDigest": "c91kQ0HotoA1cfwWU4KaqCoQU7lT6pGi6XPGIiMGkb0=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
@ -356,7 +356,7 @@
},
"//bazel:bzlmod.bzl%setup_mongo_python_toolchains": {
"general": {
"bzlTransitiveDigest": "G/WD+JnQT596GnXuqRV363uynmjbkk1qeefCHRtgT3Y=",
"bzlTransitiveDigest": "dfSpTD7th7o+ah0Usp81y/clMRt3Eyfz/Ey59BcBl68=",
"usagesDigest": "bUxjq9n+hj2YwYT/lcSP4lHyQ2GVy5JpFgSmddUqUZg=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},

View File

@ -426,12 +426,29 @@ TEST(Ostream, StringDataMatchesStdString) {
std::function<void(std::ostream&)> manip;
};
const TestCase testCases[] = {
{__LINE__, [](std::ostream& os) {}},
{__LINE__, [](std::ostream& os) { os << std::setw(5); }},
{__LINE__, [](std::ostream& os) { os << std::left << std::setw(5); }},
{__LINE__, [](std::ostream& os) { os << std::right << std::setw(5); }},
{__LINE__, [](std::ostream& os) { os << std::setfill('.') << std::left << std::setw(5); }},
{__LINE__, [](std::ostream& os) { os << std::setfill('.') << std::right << std::setw(5); }},
{__LINE__,
[](std::ostream& os) {
}},
{__LINE__,
[](std::ostream& os) {
os << std::setw(5);
}},
{__LINE__,
[](std::ostream& os) {
os << std::left << std::setw(5);
}},
{__LINE__,
[](std::ostream& os) {
os << std::right << std::setw(5);
}},
{__LINE__,
[](std::ostream& os) {
os << std::setfill('.') << std::left << std::setw(5);
}},
{__LINE__,
[](std::ostream& os) {
os << std::setfill('.') << std::right << std::setw(5);
}},
};
for (const auto& testCase : testCases) {
const std::string location = std::string(" at line:") + std::to_string(testCase.line);
@ -440,8 +457,12 @@ TEST(Ostream, StringDataMatchesStdString) {
std::function<void(std::ostream&)> putter;
std::ostringstream os;
};
Experiment expected{[&](std::ostream& os) { os << s; }};
Experiment actual{[&](std::ostream& os) { os << StringData(s); }};
Experiment expected{[&](std::ostream& os) {
os << s;
}};
Experiment actual{[&](std::ostream& os) {
os << StringData(s);
}};
for (auto& x : {&expected, &actual}) {
x->os << ">>";
testCase.manip(x->os);

View File

@ -260,7 +260,9 @@ BSONColumn::Iterator& BSONColumn::Iterator::operator++() {
++_index;
visit(OverloadedVisitor{[&](Regular& regular) { _incrementRegular(regular); },
[&](Interleaved& interleaved) { _incrementInterleaved(interleaved); }},
[&](Interleaved& interleaved) {
_incrementInterleaved(interleaved);
}},
_mode);
return *this;

View File

@ -1196,11 +1196,12 @@ typename BSONColumnBuilder<Allocator>::BinaryDiff BSONColumnBuilder<Allocator>::
// Save some state related to last control byte so we can see how it changes after finalize() is
// called.
ptrdiff_t controlOffset =
visit(OverloadedVisitor{
[](const typename InternalState::Regular& regular) {
visit(OverloadedVisitor{[](const typename InternalState::Regular& regular) {
return regular._controlByteOffset;
},
[](const typename InternalState::Interleaved&) { return kNoSimple8bControl; }},
[](const typename InternalState::Interleaved&) {
return kNoSimple8bControl;
}},
_is.state);
uint8_t lastControlByte =
controlOffset != kNoSimple8bControl ? *(_bufBuilder.buf() + controlOffset) : 0;
@ -1347,7 +1348,9 @@ BSONElement BSONColumnBuilder<Allocator>::last() const {
*regular._prev.data() == stdx::to_underlying(BSONType::eoo) ? 0 : 1,
BSONElement::TrustedInitTag{}};
},
[](const typename InternalState::Interleaved&) { return BSONElement{}; }},
[](const typename InternalState::Interleaved&) {
return BSONElement{};
}},
_is.state);
}

View File

@ -427,7 +427,7 @@ Simple8bBuilder<T, Allocator>::PendingValue::PendingValue(
boost::optional<T> val,
std::array<uint8_t, kNumOfSelectorTypes> bitCount,
std::array<uint8_t, kNumOfSelectorTypes> trailingZerosCount)
: val(val), bitCount(bitCount), trailingZerosCount(trailingZerosCount) {};
: val(val), bitCount(bitCount), trailingZerosCount(trailingZerosCount){};
template <typename T, class Allocator>
Simple8bBuilder<T, Allocator>::PendingIterator::PendingIterator(

View File

@ -549,8 +549,8 @@ public:
RetryBudget& budget,
RetryCriteria retryCriteria = defaultRetryCriteria,
RetryParameters parameters = DefaultRetryStrategy::getRetryParametersFromServerParameters())
: _underlyingStrategy{
std::make_unique<DefaultRetryStrategy>(std::move(retryCriteria), parameters)},
: _underlyingStrategy{std::make_unique<DefaultRetryStrategy>(std::move(retryCriteria),
parameters)},
_budget{&budget} {}
/**

View File

@ -43,8 +43,9 @@ const auto getIngressAdmissionController =
ServiceContext::declareDecoration<IngressAdmissionController>();
const ConstructorActionRegistererType<ServiceContext> onServiceContextCreate{
"InitIngressAdmissionController",
[](ServiceContext* ctx) { getIngressAdmissionController(ctx).init(); }};
"InitIngressAdmissionController", [](ServiceContext* ctx) {
getIngressAdmissionController(ctx).init();
}};
} // namespace
void IngressAdmissionController::init() {

View File

@ -56,8 +56,9 @@ const auto getIngressRequestRateLimiter =
ServiceContext::declareDecoration<boost::optional<IngressRequestRateLimiter>>();
const ConstructorActionRegistererType<ServiceContext> onServiceContextCreate{
"InitIngressRequestRateLimiter",
[](ServiceContext* ctx) { getIngressRequestRateLimiter(ctx).emplace(); }};
"InitIngressRequestRateLimiter", [](ServiceContext* ctx) {
getIngressRequestRateLimiter(ctx).emplace();
}};
class ClientAdmissionControlState {
public:

View File

@ -49,8 +49,9 @@ void rotateAuditLog() {}
namespace {
const auto getAuditInterface = ServiceContext::declareDecoration<std::unique_ptr<AuditInterface>>();
ServiceContext::ConstructorActionRegisterer registerCreateNoopAudit{
"initializeNoopAuditInterface",
[](ServiceContext* svcCtx) { AuditInterface::set(svcCtx, std::make_unique<AuditNoOp>()); }};
"initializeNoopAuditInterface", [](ServiceContext* svcCtx) {
AuditInterface::set(svcCtx, std::make_unique<AuditNoOp>());
}};
} // namespace
AuditInterface* AuditInterface::get(ServiceContext* service) {

View File

@ -433,8 +433,9 @@ std::unique_ptr<DbCheckRun> singleCollectionRun(OperationContext* opCtx,
maxBatchTimeMillis,
_getBatchWriteConcern(opCtx, invocation.getBatchWriteConcern()),
secondaryIndexCheckParameters,
{opCtx->fastClockSource().now().toMillisSinceEpoch(),
[&]() { return gMaxDbCheckMBperSec.load(); }}};
{opCtx->fastClockSource().now().toMillisSinceEpoch(), [&]() {
return gMaxDbCheckMBperSec.load();
}}};
auto result = std::make_unique<DbCheckRun>();
result->push_back(info);
return result;
@ -471,8 +472,9 @@ std::unique_ptr<DbCheckRun> fullDatabaseRun(OperationContext* opCtx,
maxBatchTimeMillis,
_getBatchWriteConcern(opCtx, invocation.getBatchWriteConcern()),
boost::none,
{opCtx->fastClockSource().now().toMillisSinceEpoch(),
[&]() { return gMaxDbCheckMBperSec.load(); }}};
{opCtx->fastClockSource().now().toMillisSinceEpoch(), [&]() {
return gMaxDbCheckMBperSec.load();
}}};
result->push_back(info);
return true;
};

View File

@ -121,7 +121,9 @@ struct MakeObjSpec {
[](SetArg) { return Type::kSetArg; },
[](AddArg) { return Type::kAddArg; },
[](LambdaArg) { return Type::kLambdaArg; },
[](const MakeObj&) { return Type::kMakeObj; }},
[](const MakeObj&) {
return Type::kMakeObj;
}},
_data);
}

View File

@ -467,7 +467,7 @@ IndexScanStageBaseImpl<Derived>::IndexScanStageBaseImpl(
vars,
yieldPolicy,
nodeId,
participateInTrialRunTracking) {};
participateInTrialRunTracking){};
SimpleIndexScanStage::SimpleIndexScanStage(UUID collUuid,
DatabaseName dbName,

View File

@ -455,7 +455,7 @@ ScanStageBaseImpl<Derived>::ScanStageBaseImpl(UUID collUuid,
scanOpenCallback,
forward,
// Optional arguments:
participateInTrialRunTracking) {};
participateInTrialRunTracking){};
template <typename Derived>
@ -463,7 +463,7 @@ ScanStageBaseImpl<Derived>::ScanStageBaseImpl(std::shared_ptr<ScanStageBaseState
PlanYieldPolicySBE* yieldPolicy,
PlanNodeId nodeId,
bool participateInTrialRunTracking)
: ScanStageBase(std::move(state), yieldPolicy, nodeId, participateInTrialRunTracking) {};
: ScanStageBase(std::move(state), yieldPolicy, nodeId, participateInTrialRunTracking){};
ScanStage::ScanStage(UUID collUuid,
DatabaseName dbName,

View File

@ -36,7 +36,9 @@ namespace {
VersionedExtension makeTestVersionedExtension(uint32_t major, uint32_t minor) {
return VersionedExtension{::MongoExtensionAPIVersion{major, minor},
[]() -> std::unique_ptr<sdk::Extension> { return nullptr; }};
[]() -> std::unique_ptr<sdk::Extension> {
return nullptr;
}};
}
class VersionedExtensionGreaterComparatorTest : public unittest::Test {

View File

@ -114,7 +114,7 @@ boost::filesystem::path getFTDCDirectoryPathParameter() {
}
Status onUpdateFTDCEnabled(const bool value) {
if (FTDCController* controller;
if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
return controller->setEnabled(value);
}
@ -123,7 +123,7 @@ Status onUpdateFTDCEnabled(const bool value) {
}
Status onUpdateFTDCMetadataCaptureFrequency(const std::int32_t potentialNewValue) {
if (FTDCController* controller;
if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
controller->setMetadataCaptureFrequency(potentialNewValue);
}
@ -132,7 +132,7 @@ Status onUpdateFTDCMetadataCaptureFrequency(const std::int32_t potentialNewValue
}
Status onUpdateFTDCPeriod(const std::int32_t potentialNewValue) {
if (FTDCController* controller;
if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
controller->setPeriod(Milliseconds(potentialNewValue));
FTDCCollectionMetrics::get(getGlobalServiceContext())
@ -152,7 +152,7 @@ Status onUpdateFTDCDirectorySize(const std::int32_t potentialNewValue) {
<< "' which is the current value of diagnosticDataCollectionFileSizeMB.");
}
if (FTDCController* controller;
if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
controller->setMaxDirectorySizeBytes(potentialNewValue * 1024 * 1024);
}
@ -170,7 +170,7 @@ Status onUpdateFTDCFileSize(const std::int32_t potentialNewValue) {
<< "' which is the current value of diagnosticDataCollectionDirectorySizeMB.");
}
if (FTDCController* controller;
if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
controller->setMaxFileSizeBytes(potentialNewValue * 1024 * 1024);
}
@ -179,7 +179,7 @@ Status onUpdateFTDCFileSize(const std::int32_t potentialNewValue) {
}
Status onUpdateFTDCSamplesPerChunk(const std::int32_t potentialNewValue) {
if (FTDCController* controller;
if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
controller->setMaxSamplesPerArchiveMetricChunk(potentialNewValue);
}
@ -188,7 +188,7 @@ Status onUpdateFTDCSamplesPerChunk(const std::int32_t potentialNewValue) {
}
Status onUpdateFTDCPerInterimUpdate(const std::int32_t potentialNewValue) {
if (FTDCController* controller;
if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
controller->setMaxSamplesPerInterimMetricChunk(potentialNewValue);
}
@ -197,7 +197,7 @@ Status onUpdateFTDCPerInterimUpdate(const std::int32_t potentialNewValue) {
}
Status onUpdateFTDCSampleTimeout(std::int32_t potentialNewValue) {
if (FTDCController* controller;
if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
return controller->setSampleTimeout(Milliseconds(potentialNewValue));
}
@ -206,7 +206,7 @@ Status onUpdateFTDCSampleTimeout(std::int32_t potentialNewValue) {
}
Status onUpdateFTDCMinThreads(std::int32_t potentialNewValue) {
if (FTDCController* controller;
if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
return controller->setMinThreads(potentialNewValue);
}
@ -215,7 +215,7 @@ Status onUpdateFTDCMinThreads(std::int32_t potentialNewValue) {
}
Status onUpdateFTDCMaxThreads(std::int32_t potentialNewValue) {
if (FTDCController* controller;
if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
return controller->setMaxThreads(potentialNewValue);
}
@ -471,7 +471,7 @@ void startFTDC(ServiceContext* serviceContext,
}
void stopFTDC() {
if (FTDCController* controller;
if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
controller->stop();
}

View File

@ -127,7 +127,9 @@ public:
*/
void waitForOngoingCoordinatorsToFinish(OperationContext* opCtx,
std::function<bool(const ShardingCoordinator&)> pred = {
[](const ShardingCoordinator&) { return true; }});
[](const ShardingCoordinator&) {
return true;
}});
void waitForRecovery(OperationContext* opCtx) const override;

View File

@ -84,10 +84,14 @@ private:
}}},
{"server",
{BSON(ChangeLogType::server() << _kServer),
[&](const ChangeLogType& changelog) { ASSERT_EQUALS(changelog.getServer(), _kServer); }}},
[&](const ChangeLogType& changelog) {
ASSERT_EQUALS(changelog.getServer(), _kServer);
}}},
{"shard",
{BSON(ChangeLogType::shard() << _kShard),
[&](const ChangeLogType& changelog) { ASSERT_EQUALS(changelog.getShard(), _kShard); }}},
[&](const ChangeLogType& changelog) {
ASSERT_EQUALS(changelog.getShard(), _kShard);
}}},
{"clientAddr",
{BSON(ChangeLogType::clientAddr() << _kClientAddr),
[&](const ChangeLogType& changelog) {
@ -95,10 +99,14 @@ private:
}}},
{"time",
{BSON(ChangeLogType::time() << _kTime),
[&](const ChangeLogType& changelog) { ASSERT_EQUALS(changelog.getTime(), _kTime); }}},
[&](const ChangeLogType& changelog) {
ASSERT_EQUALS(changelog.getTime(), _kTime);
}}},
{"what",
{BSON(ChangeLogType::what() << _kWhat),
[&](const ChangeLogType& changelog) { ASSERT_EQUALS(changelog.getWhat(), _kWhat); }}},
[&](const ChangeLogType& changelog) {
ASSERT_EQUALS(changelog.getWhat(), _kWhat);
}}},
{"versionContext",
{BSON(ChangeLogType::versionContext() << _kVersionContext.toBSON()),
[&](const ChangeLogType& changelog) {

View File

@ -408,7 +408,8 @@ TEST_F(IndexAccessMethodBulkBuilder, CommitRejectsZeroInterval) {
}},
IndexAccessMethod::RecordIdHandlerFn{},
IndexAccessMethod::YieldFn{},
IndexAccessMethod::OnNKeysLoadedFn{[]() {}},
IndexAccessMethod::OnNKeysLoadedFn{[]() {
}},
/*onNKeysLoadedFnInterval=*/0,
/*keyBatchSize=*/1,
/*keyBatchBytes=*/1024),

View File

@ -351,7 +351,9 @@ struct ValidationErrorContext {
verifySizeAndAppend(details, kDetailsString, builder);
},
[&](const std::monostate& state) -> void { MONGO_UNREACHABLE },
[&](const std::string& str) -> void { MONGO_UNREACHABLE }},
[&](const std::string& str) -> void {
MONGO_UNREACHABLE
}},
latestCompleteError);
}
/**
@ -372,7 +374,9 @@ struct ValidationErrorContext {
verifySizeAndAppend(elem, builder);
}
},
[&](const std::monostate& state) -> void { MONGO_UNREACHABLE }},
[&](const std::monostate& state) -> void {
MONGO_UNREACHABLE
}},
latestCompleteError);
}

View File

@ -215,8 +215,9 @@ void buildUpdateDescriptionWithDeltaOplog(
while (auto nextSubDiff = reader->nextSubDiff()) {
std::variant<DocumentDiffReader*, ArrayDiffReader*> nextReader;
visit(
OverloadedVisitor{[&nextReader](auto& reader) { nextReader = &reader; }},
visit(OverloadedVisitor{[&nextReader](auto& reader) {
nextReader = &reader;
}},
nextSubDiff->second);
buildUpdateDescriptionWithDeltaOplog(
nextReader, builder, {{nextSubDiff->first}});

View File

@ -84,7 +84,9 @@ public:
*/
Value toValue() const {
return visit(OverloadedVisitor{[&](Value unwrappedVal) { return unwrappedVal; },
[&](Date_t dateVal) { return Value(dateVal); }
[&](Date_t dateVal) {
return Value(dateVal);
}
},
_value);
@ -128,7 +130,9 @@ public:
std::string toString() const {
return visit(OverloadedVisitor{[&](Value v) { return v.toString(); },
[&](Date_t d) { return d.toString(); }},
[&](Date_t d) {
return d.toString();
}},
_value);
}
@ -147,7 +151,9 @@ public:
*/
size_t getApproximateSize() const {
return visit(OverloadedVisitor{[&](Value v) { return v.getApproximateSize(); },
[&](Date_t d) { return Value(d).getApproximateSize(); }},
[&](Date_t d) {
return Value(d).getApproximateSize();
}},
_value);
}

View File

@ -102,8 +102,9 @@ public:
OwningDistributedPlanContext(std::unique_ptr<Pipeline> pipelinePrefix,
std::unique_ptr<Pipeline> pipelineSuffix,
boost::optional<OrderedPathSet> shardKeys)
: DocumentSourceGroup::DistributedPlanContext{
*pipelinePrefix, *pipelineSuffix, this->shardKeys},
: DocumentSourceGroup::DistributedPlanContext{*pipelinePrefix,
*pipelineSuffix,
this->shardKeys},
pipelinePrefix(std::move(pipelinePrefix)),
pipelineSuffix(std::move(pipelineSuffix)),
shardKeys(std::move(shardKeys)) {}

View File

@ -1372,8 +1372,9 @@ private:
boost::optional<query_settings::QuerySettings> _querySettings = boost::none;
DeferredFn<QueryKnobConfiguration, const query_settings::QuerySettings&>
_queryKnobConfiguration{
[](const auto& querySettings) { return QueryKnobConfiguration(querySettings); }};
_queryKnobConfiguration{[](const auto& querySettings) {
return QueryKnobConfiguration(querySettings);
}};
Deferred<bool (*)(const VersionContext&)> _featureFlagShardFilteringDistinctScan{
[](const VersionContext& vCtx) {

View File

@ -1824,9 +1824,9 @@ std::unique_ptr<Pipeline> targetShardsAndAddMergeCursors(
bool useCollectionDefaultCollator) {
auto&& aggRequestPipelinePair = [&] {
return visit(
OverloadedVisitor{
[&](std::unique_ptr<Pipeline>&& pipeline) {
return std::make_pair(AggregateCommandRequest(expCtx->getNamespaceString(),
OverloadedVisitor{[&](std::unique_ptr<Pipeline>&& pipeline) {
return std::make_pair(
AggregateCommandRequest(expCtx->getNamespaceString(),
pipeline->serializeToBson()),
std::move(pipeline));
},
@ -1838,7 +1838,9 @@ std::unique_ptr<Pipeline> targetShardsAndAddMergeCursors(
rawPipeline, expCtx, pipeline_factory::kOptionsMinimal));
},
[&](std::pair<AggregateCommandRequest, std::unique_ptr<Pipeline>>&&
aggRequestPipelinePair) { return std::move(aggRequestPipelinePair); }},
aggRequestPipelinePair) {
return std::move(aggRequestPipelinePair);
}},
std::move(targetRequest));
}();
const auto& aggRequest = aggRequestPipelinePair.first;

View File

@ -76,7 +76,8 @@ using StageParamsToDocumentSourceFn = std::function<std::list<boost::intrusive_p
* REGISTER_STAGE_PARAMS_TO_DOCUMENT_SOURCE_MAPPING macro defined in this file.
*/
MONGO_MOD_PUBLIC // Needed by enterprise hot backup registrations.
void registerStageParamsToDocumentSourceFn(StageParams::Id stageParamsId,
void
registerStageParamsToDocumentSourceFn(StageParams::Id stageParamsId,
StageParamsToDocumentSourceFn fn);
/**

View File

@ -380,8 +380,9 @@ void visitExtensionStage(DocsNeededBoundsContext* ctx,
}
const ServiceContext::ConstructorActionRegisterer docsNeededBoundsRegisterer{
"DocsNeededBoundsRegisterer",
[](ServiceContext* service) { registerMongodVisitor<DocsNeededBoundsContext>(service); }};
"DocsNeededBoundsRegisterer", [](ServiceContext* service) {
registerMongodVisitor<DocsNeededBoundsContext>(service);
}};
DocsNeededBounds extractDocsNeededBounds(const DocumentSourceContainer& sources,

View File

@ -223,9 +223,11 @@ void doProfile(auto opCtx,
boost::optional<CollectionAcquisition> profileCollection;
while (true) {
const auto deadline = std::visit(
OverloadedVisitor{[&](const NoTimeoutTag&) { return Date_t::max(); },
[&](const Milliseconds& millis) { return Date_t::now() + millis; }},
const auto deadline =
std::visit(OverloadedVisitor{[&](const NoTimeoutTag&) { return Date_t::max(); },
[&](const Milliseconds& millis) {
return Date_t::now() + millis;
}},
lockTimeout);
profileCollection.emplace(acquireCollection(

View File

@ -158,17 +158,19 @@ BSONObj JoinPlanNodeRegistry::joinPlanNodeToBSON(JoinPlanNodeId nodeId,
bob << "cost" << getCost(nodeId).toBSON();
}
std::visit(
OverloadedVisitor{
[this, numNodesToPrint, &bob](const JoiningNode& join) {
OverloadedVisitor{[this, numNodesToPrint, &bob](const JoiningNode& join) {
bob << "method" << joinMethodToString(join.method);
bob << "left" << joinPlanNodeToBSON(join.left, numNodesToPrint);
bob << "right" << joinPlanNodeToBSON(join.right, numNodesToPrint);
},
[&bob](const INLJRHSNode& ip) {
bob << "accessPath"
<< (str::stream() << "INDEX_PROBE " << ip.entry->descriptor()->keyPattern());
<< (str::stream()
<< "INDEX_PROBE " << ip.entry->descriptor()->keyPattern());
},
[&bob](const BaseNode& base) { bob << "accessPath" << base.soln->summaryString(); }},
[&bob](const BaseNode& base) {
bob << "accessPath" << base.soln->summaryString();
}},
get(nodeId));
return bob.obj();
}

View File

@ -163,7 +163,9 @@ inline JoinCostEstimate getNodeCost(const JoinPlanNode& node) {
MONGO_UNREACHABLE_TASSERT(11727800);
return JoinCostEstimate(zeroCE, zeroCE, zeroCE, zeroCE);
},
[](const BaseNode& base) { return base.cost; }},
[](const BaseNode& base) {
return base.cost;
}},
node);
}
@ -174,7 +176,9 @@ inline NodeSet getNodeBitset(const JoinPlanNode& node) {
return std::visit(
OverloadedVisitor{[](const JoiningNode& join) { return join.bitset; },
[](const INLJRHSNode& ip) { return NodeSet().set(ip.node); },
[](const BaseNode& base) { return NodeSet().set(base.node); }},
[](const BaseNode& base) {
return NodeSet().set(base.node);
}},
node);
}

View File

@ -83,7 +83,9 @@ using BSONValue = std::variant<BSONElement, std::reference_wrapper<Value>>;
template <typename T>
T parseFindPayload(BSONValue payload) {
return visit(OverloadedVisitor{[&](BSONElement payload) { return T(payload); },
[&](Value payload) { return T(payload); }},
[&](Value payload) {
return T(payload);
}},
payload);
}

View File

@ -975,9 +975,12 @@ public:
CanonicalQuery* cq,
PlanYieldPolicy::YieldPolicy policy,
std::unique_ptr<QueryPlannerParams> plannerParams)
: SbeWithClassicRuntimePlanningPrepareExecutionHelperBase{
opCtx, collections, cq, policy, std::move(plannerParams), false /*useSbePlanCache*/} {
}
: SbeWithClassicRuntimePlanningPrepareExecutionHelperBase{opCtx,
collections,
cq,
policy,
std::move(plannerParams),
false /*useSbePlanCache*/} {}
private:
PlanCacheKey buildPlanCacheKey() const override {

View File

@ -52,7 +52,7 @@ public:
// Allow implicit construction from a string literal, but not from a const char*.
template <size_t N>
StrongStringAlias(const char (&value)[N]) : _value(value) {};
StrongStringAlias(const char (&value)[N]) : _value(value){};
// We disallow empty strings based on the tag's kAllowEmpty field.
template <class TagType1 = TagType, class = typename std::enable_if_t<!TagType1::kAllowEmpty>>

View File

@ -747,8 +747,9 @@ boost::optional<SbBlockAggExprVector> tryToGenerateOneBlockAccumulator(
* exit.
*/
auto makeValueGuard(auto* dst, auto val) {
return ScopeGuard{
[dst, old = std::exchange(*dst, std::move(val))]() mutable { *dst = std::move(old); }};
return ScopeGuard{[dst, old = std::exchange(*dst, std::move(val))]() mutable {
*dst = std::move(old);
}};
}
SbHashAggAccumulatorVector generateScalarAccumulators(StageBuilderState& state,

View File

@ -751,7 +751,9 @@ public:
},
[](const Expr& e) { return ProjectNode(e.expr); },
[](const SbExpr& e) { return ProjectNode(e.clone()); },
[](const Slice& s) { return ProjectNode(s); }},
[](const Slice& s) {
return ProjectNode(s);
}},
_data);
}
@ -759,7 +761,9 @@ public:
return visit(OverloadedVisitor{[](const Bool&) { return Type::kBool; },
[](const Expr&) { return Type::kExpr; },
[](const SbExpr&) { return Type::kSbExpr; },
[](const Slice&) { return Type::kSlice; }},
[](const Slice&) {
return Type::kSlice;
}},
_data);
}

View File

@ -59,7 +59,9 @@ ProjectActionType ProjectAction::type() const {
[](const SetArg&) { return ProjectActionType::kSetArg; },
[](const AddArg&) { return ProjectActionType::kAddArg; },
[](const LambdaArg&) { return ProjectActionType::kLambdaArg; },
[](const MakeObj&) { return ProjectActionType::kMakeObj; }},
[](const MakeObj&) {
return ProjectActionType::kMakeObj;
}},
_data);
}

View File

@ -340,9 +340,7 @@ TEST_F(LookupStageBuilderTest, NestedLoopJoin_TopLevelLocalField_Null) {
std::vector<std::pair<BSONObj, std::vector<BSONObj>>> expected{
{ldocs[0],
{fdocs[1],
fdocs[2],
fdocs[3],
{fdocs[1], fdocs[2], fdocs[3],
/*fdocs[4], fdocs[5] - match in classic, but for undefined we don't care*/}},
};
@ -364,9 +362,7 @@ TEST_F(LookupStageBuilderTest, NestedLoopJoin_TopLevelLocalField_Missing) {
std::vector<std::pair<BSONObj, std::vector<BSONObj>>> expected = {
{ldocs[0],
{fdocs[1],
fdocs[2],
fdocs[3],
{fdocs[1], fdocs[2], fdocs[3],
/*fdocs[4], fdocs[5] - match in classic, but for undefined we don't care*/}},
};

View File

@ -105,7 +105,9 @@ TEST(DeferredTest, DeferredInitializationWithOneArgument) {
}
TEST(DeferredTest, DeferredInitializationWithTwoArgs) {
Deferred deferred{[&](const string& input, const string& prefix) { return prefix + input; }};
Deferred deferred{[&](const string& input, const string& prefix) {
return prefix + input;
}};
ASSERT_EQ(deferred.get("cowbell", "more "), "more cowbell"s);
ASSERT_EQ(deferred.get("cowbell", "more "), "more cowbell"s);

View File

@ -777,7 +777,9 @@ int UpdateModification::objsize() const {
return size + kWriteCommandBSONArrayPerElementOverheadBytes;
},
[](const DeltaUpdate& delta) -> int { return delta.diff.objsize(); },
[](const TransformUpdate& transform) -> int { return 0; }},
[](const TransformUpdate& transform) -> int {
return 0;
}},
_update);
}
@ -787,7 +789,9 @@ UpdateModification::Type UpdateModification::type() const {
[](const ModifierUpdate& modifier) { return Type::kModifier; },
[](const PipelineUpdate& pipelineUpdate) { return Type::kPipeline; },
[](const DeltaUpdate& delta) { return Type::kDelta; },
[](const TransformUpdate& transform) { return Type::kTransform; }},
[](const TransformUpdate& transform) {
return Type::kTransform;
}},
_update);
}
@ -812,7 +816,8 @@ void UpdateModification::serializeToBSON(StringData fieldName, BSONObjBuilder* b
arrayBuilder.doneFast();
},
[fieldName, bob](const DeltaUpdate& delta) { *bob << fieldName << delta.diff; },
[](const TransformUpdate& transform) {}},
[](const TransformUpdate& transform) {
}},
_update);
}

View File

@ -556,8 +556,9 @@ inline boost::optional<query_shape::DeferredQueryShape> computeInsertQueryShape(
if (wholeOp.getEncryptionInformation()) {
return boost::none;
}
query_shape::DeferredQueryShape deferredShape{
[&]() { return shape_helpers::tryMakeShape<query_shape::InsertCmdShape>(wholeOp); }};
query_shape::DeferredQueryShape deferredShape{[&]() {
return shape_helpers::tryMakeShape<query_shape::InsertCmdShape>(wholeOp);
}};
return deferredShape;
}

View File

@ -192,20 +192,22 @@ public:
std::string toString() const {
StringBuilder sb;
visit(OverloadedVisitor{
[&sb](const ReplacementUpdate& replacement) {
visit(OverloadedVisitor{[&sb](const ReplacementUpdate& replacement) {
sb << "{type: Replacement, update: " << replacement.bson << "}";
},
[&sb](const ModifierUpdate& modifier) {
sb << "{type: Modifier, update: " << modifier.bson << "}";
},
[&sb](const PipelineUpdate& pipeline) {
sb << "{type: Pipeline, update: " << Value(pipeline).toString() << "}";
sb << "{type: Pipeline, update: " << Value(pipeline).toString()
<< "}";
},
[&sb](const DeltaUpdate& delta) {
sb << "{type: Delta, update: " << delta.diff << "}";
},
[&sb](const TransformUpdate& transform) { sb << "{type: Transform}"; }},
[&sb](const TransformUpdate& transform) {
sb << "{type: Transform}";
}},
_update);
return sb.str();

View File

@ -1302,10 +1302,14 @@ const StringMap<ApplyOpMetadata> kOpsMap = {
}}},
{"commitTransaction",
{[](OperationContext* opCtx, const ApplierOperation& op, OplogApplication::Mode mode)
-> Status { return applyCommitTransaction(opCtx, op, mode); }}},
-> Status {
return applyCommitTransaction(opCtx, op, mode);
}}},
{"abortTransaction",
{[](OperationContext* opCtx, const ApplierOperation& op, OplogApplication::Mode mode)
-> Status { return applyAbortTransaction(opCtx, op, mode); }}},
-> Status {
return applyAbortTransaction(opCtx, op, mode);
}}},
{"createDatabaseMetadata",
{[](OperationContext* opCtx, const ApplierOperation& op, OplogApplication::Mode mode)
-> Status {

View File

@ -528,7 +528,9 @@ TEST_F(OplogApplierImplTest, applyOplogEntryToRecordChangeStreamPreImages) {
auto op = makeOplogEntry(
[opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }};
ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx);
}(),
testCase.opType,
@ -603,7 +605,9 @@ TEST_F(OplogApplierImplTest, ApplyApplyOpsWithMixedFromMigrateRecordsCorrectPreI
// Get an optime for the applyOps entry.
auto opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }};
ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx);
}();
@ -832,7 +836,9 @@ TEST_F(OplogApplierImplTest, RenameCollectionCommandMultitenant) {
// createCollection uses an actual opTime, so we must generate an actually opTime in the future.
auto opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }};
ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx);
}();
auto op = makeCommandOplogEntry(opTime, sourceNss, oRename, {});
@ -860,7 +866,9 @@ TEST_F(OplogApplierImplTest, RenameCollectionCommandMultitenantRequireTenantIDFa
// createCollection uses an actual opTime, so we must generate an actually opTime in the future.
auto opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }};
ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx);
}();
auto op = makeCommandOplogEntry(opTime, sourceNss, oRename, {});
@ -893,7 +901,9 @@ TEST_F(OplogApplierImplTest, RenameCollectionCommandMultitenantAcrossTenantsRequ
// createCollection uses an actual opTime, so we must generate an actually opTime in the future.
auto opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }};
ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx);
}();
auto op = makeCommandOplogEntry(opTime, sourceNss, oRename, {});

View File

@ -421,7 +421,9 @@ TEST_F(DeleteWithRecordIdAndPreImagesTest,
// Create a delete oplog entry with recordId.
OpTime opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }};
ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx);
}();
auto op = makeDeleteOplogEntryWithRecordId(opTime, _nss, _uuid, BSON("_id" << 1), rid);
@ -461,7 +463,9 @@ DEATH_TEST_F(DeleteWithRecordIdAndPreImagesDeathTest,
// Create an update oplog entry with the non-existent recordId.
OpTime opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }};
ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx);
}();
auto op =

View File

@ -611,7 +611,9 @@ TEST_F(UpdateWithRecordIdAndPreImagesTest,
// Create an update oplog entry with recordId.
OpTime opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }};
ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx);
}();
auto op = makeUpdateOplogEntryWithRecordId(
@ -654,7 +656,9 @@ DEATH_TEST_F(UpdateWithRecordIdAndPreImagesDeathTest,
// Create an update oplog entry with the non-existent recordId.
OpTime opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }};
ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx);
}();
auto op = makeUpdateOplogEntryWithRecordId(

View File

@ -270,8 +270,9 @@ Status RollbackImpl::runRollback(OperationContext* opCtx) {
// the size storer information is no longer accurate. This may be necessary if capped deletes
// are rolled-back or if rollback occurs across a collection rename.
sizeRecovery.setRecordStoresShouldAlwaysCheckSize(true);
ScopeGuard sizeRecoveryStateGuard{
[&sizeRecovery] { sizeRecovery.setRecordStoresShouldAlwaysCheckSize(false); }};
ScopeGuard sizeRecoveryStateGuard{[&sizeRecovery] {
sizeRecovery.setRecordStoresShouldAlwaysCheckSize(false);
}};
// After successfully transitioning to the ROLLBACK state, we must always transition back to
// SECONDARY, even if we fail at any point during the rollback process.

View File

@ -252,7 +252,8 @@ protected:
}
protected:
AutoMergerPolicy _automerger{[]() {}};
AutoMergerPolicy _automerger{[]() {
}};
inline const static auto _shards =
std::vector<ShardType>{ShardType{"shard0", "host0:123"}, ShardType{"shard1", "host1:123"}};

View File

@ -171,8 +171,10 @@ TEST_F(BalancerCommandsSchedulerTest, StartAndStopScheduler) {
}
TEST_F(BalancerCommandsSchedulerTest, SuccessfulMoveRangeCommand) {
auto remoteResponsesFuture = setRemoteResponses(
{[&](const executor::RemoteCommandRequest& request) { return OkReply().toBSON(); }});
auto remoteResponsesFuture =
setRemoteResponses({[&](const executor::RemoteCommandRequest& request) {
return OkReply().toBSON();
}});
_scheduler.start(operationContext());
ShardsvrMoveRange shardsvrRequest(kNss);
shardsvrRequest.setCollectionTimestamp(Timestamp(10));
@ -192,8 +194,10 @@ TEST_F(BalancerCommandsSchedulerTest, SuccessfulMoveRangeCommand) {
}
TEST_F(BalancerCommandsSchedulerTest, SuccessfulMergeChunkCommand) {
auto remoteResponsesFuture = setRemoteResponses(
{[&](const executor::RemoteCommandRequest& request) { return OkReply().toBSON(); }});
auto remoteResponsesFuture =
setRemoteResponses({[&](const executor::RemoteCommandRequest& request) {
return OkReply().toBSON();
}});
_scheduler.start(operationContext());
ChunkRange range(BSON("x" << 0), BSON("x" << 20));
@ -223,8 +227,10 @@ TEST_F(BalancerCommandsSchedulerTest, SuccessfulRequestChunkDataSizeCommand) {
chunkSizeResponse.append("ok", "1");
chunkSizeResponse.append("size", 156);
chunkSizeResponse.append("numObjects", 25);
auto remoteResponsesFuture = setRemoteResponses(
{[&](const executor::RemoteCommandRequest& request) { return chunkSizeResponse.obj(); }});
auto remoteResponsesFuture =
setRemoteResponses({[&](const executor::RemoteCommandRequest& request) {
return chunkSizeResponse.obj();
}});
_scheduler.start(operationContext());
ChunkType chunk = makeChunk(0, kShardId0);
@ -295,8 +301,10 @@ TEST_F(BalancerCommandsSchedulerTest, SuccessfulMoveCollectionRequest) {
TEST_F(BalancerCommandsSchedulerTest, CommandFailsWhenNetworkReturnsError) {
auto timeoutError = Status{ErrorCodes::NetworkTimeout, "Mock error: network timed out"};
auto remoteResponsesFuture = setRemoteResponses(
{[&](const executor::RemoteCommandRequest& request) { return timeoutError; }});
auto remoteResponsesFuture =
setRemoteResponses({[&](const executor::RemoteCommandRequest& request) {
return timeoutError;
}});
_scheduler.start(operationContext());
auto req = makeMoveRangeRequest(0, kShardId1, kShardId0);
auto futureResponse = _scheduler.requestMoveRange(

View File

@ -783,7 +783,9 @@ TEST_F(BalancerDefragmentationPolicyTest, PhaseOneNotConsecutive) {
}
},
[](const MigrateInfo& _) { FAIL("Unexpected action type"); },
[](const MergeAllChunksOnShardInfo& _) { FAIL("Unexpected action type"); }},
[](const MergeAllChunksOnShardInfo& _) {
FAIL("Unexpected action type");
}},
action);
};
inspectAction(*nextAction);

View File

@ -50,17 +50,19 @@ protected:
}
PrimaryOnlyServiceRetryStrategy makeStrategy() {
return PrimaryOnlyServiceRetryStrategy{
kDefaultRetryabilityPredicate,
return PrimaryOnlyServiceRetryStrategy{kDefaultRetryabilityPredicate,
[this](const Status& s) { ++_transientErrorCount; },
[this](const Status& s) { ++_unrecoverableErrorCount; }};
[this](const Status& s) {
++_unrecoverableErrorCount;
}};
}
PrimaryOnlyServiceRetryStrategy makeNeverRetryStrategy() {
return PrimaryOnlyServiceRetryStrategy{
makeNeverRetryPredicate(),
return PrimaryOnlyServiceRetryStrategy{makeNeverRetryPredicate(),
[this](const Status& s) { ++_transientErrorCount; },
[this](const Status& s) { ++_unrecoverableErrorCount; }};
[this](const Status& s) {
++_unrecoverableErrorCount;
}};
}
int transientErrorCount() const {

View File

@ -117,7 +117,9 @@ public:
auto body = std::make_shared<BodyCallable>(std::move(_body));
return AsyncTry{[body, retryFactory = _retryFactory, executor, cancelToken] {
auto strategy = retryFactory.make();
return AsyncTry{[body](const TargetingMetadata& metadata) { return (*body)(); }}
return AsyncTry{[body](const TargetingMetadata& metadata) {
return (*body)();
}}
.withRetryStrategy(strategy)
.on(executor, cancelToken);
}}
@ -140,8 +142,9 @@ public:
auto runOn(SleepableExecutor executor,
CancellationToken cancelToken,
std::shared_ptr<RetryStrategy> retryStrategy) && {
return AsyncTry{
[body = std::move(_body)](const TargetingMetadata& metadata) { return body(); }}
return AsyncTry{[body = std::move(_body)](const TargetingMetadata& metadata) {
return body();
}}
.withRetryStrategy(std::move(retryStrategy))
.on(executor, cancelToken);
}

View File

@ -276,8 +276,9 @@ DEATH_TEST_F(ReshardingCoordinatorDaoFixtureDeathTest,
shardToNumDocsCopied.emplace(shard2, 200);
runPhaseTransitionTest(PhaseTransitionTestCase{
.initialPhase = CoordinatorStateEnum::kApplying,
.transitionFn = [&]() { _dao->updateNumberOfDocsToCopy(_opCtx, shardToNumDocsCopied); }});
.initialPhase = CoordinatorStateEnum::kApplying, .transitionFn = [&]() {
_dao->updateNumberOfDocsToCopy(_opCtx, shardToNumDocsCopied);
}});
}
TEST_F(ReshardingCoordinatorDaoFixture, UpdateNumberOfDocsCopiedFinal) {
@ -359,8 +360,9 @@ DEATH_TEST_F(ReshardingCoordinatorDaoFixtureDeathTest,
auto applyStartTime = _clock->now();
runPhaseTransitionTest(PhaseTransitionTestCase{
.initialPhase = CoordinatorStateEnum::kApplying,
.transitionFn = [&]() { _dao->transitionToApplyingPhase(_opCtx, applyStartTime); }});
.initialPhase = CoordinatorStateEnum::kApplying, .transitionFn = [&]() {
_dao->transitionToApplyingPhase(_opCtx, applyStartTime);
}});
}
TEST_F(ReshardingCoordinatorDaoFixture, TransitionToBlockingWritesPhaseSucceeds) {
@ -448,8 +450,9 @@ DEATH_TEST_F(ReshardingCoordinatorDaoFixtureDeathTest,
Status abortReason = Status::OK();
runPhaseTransitionTest(PhaseTransitionTestCase{
.initialPhase = CoordinatorStateEnum::kApplying,
.transitionFn = [&]() { _dao->transitionToAbortingPhase(_opCtx, now, abortReason); }});
.initialPhase = CoordinatorStateEnum::kApplying, .transitionFn = [&]() {
_dao->transitionToAbortingPhase(_opCtx, now, abortReason);
}});
}
DEATH_TEST_F(ReshardingCoordinatorDaoFixtureDeathTest,
@ -459,8 +462,9 @@ DEATH_TEST_F(ReshardingCoordinatorDaoFixtureDeathTest,
Status abortReason{ErrorCodes::InternalError, "Something went horribly wrong"};
runPhaseTransitionTest(PhaseTransitionTestCase{
.initialPhase = CoordinatorStateEnum::kCommitting,
.transitionFn = [&]() { _dao->transitionToAbortingPhase(_opCtx, now, abortReason); }});
.initialPhase = CoordinatorStateEnum::kCommitting, .transitionFn = [&]() {
_dao->transitionToAbortingPhase(_opCtx, now, abortReason);
}});
}
TEST_F(ReshardingCoordinatorDaoFixture, UpdateSessionSetsSessionField) {

View File

@ -104,8 +104,9 @@ using MetricsPtr = std::unique_ptr<Metrics>;
const auto getMetrics = ServiceContext::declareDecoration<MetricsPtr>();
const auto metricsRegisterer = ServiceContext::ConstructorActionRegisterer{
"ShardingDataTransformMetrics",
[](ServiceContext* ctx) { getMetrics(ctx) = std::make_unique<Metrics>(); }};
"ShardingDataTransformMetrics", [](ServiceContext* ctx) {
getMetrics(ctx) = std::make_unique<Metrics>();
}};
} // namespace

View File

@ -656,7 +656,9 @@ std::unique_ptr<ReshardingMetrics> ReshardingMetrics::makeInstance_forTest(
StringData ReshardingMetrics::getStateString() const {
return visit(OverloadedVisitor{[](CoordinatorStateEnum state) { return idl::serialize(state); },
[](RecipientStateEnum state) { return idl::serialize(state); },
[](DonorStateEnum state) { return idl::serialize(state); }},
[](DonorStateEnum state) {
return idl::serialize(state);
}},
getState());
}

View File

@ -140,7 +140,9 @@ public:
auto opTime = [opCtx] {
WriteUnitOfWork wuow(opCtx);
ScopeGuard guard{[&wuow] { wuow.commit(); }};
ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx);
}();
WriteUnitOfWork wuow(opCtx);

View File

@ -1030,7 +1030,9 @@ TEST_F(TransactionCoordinatorServiceTest,
// Vote commit before the deadline
onCommands({[&](const executor::RemoteCommandRequest&) { return kPrepareOk; },
[&](const executor::RemoteCommandRequest&) { return kPrepareOk; }});
[&](const executor::RemoteCommandRequest&) {
return kPrepareOk;
}});
// Reach the deadline.
network()->enterNetwork();
@ -1075,7 +1077,9 @@ TEST_F(TransactionCoordinatorServiceTestSingleTxn,
// Simulate a participant voting to abort.
onCommands({[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; },
[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; }});
[&](const executor::RemoteCommandRequest& request) {
return kNoSuchTransaction;
}});
assertAbortSentAndRespondWithSuccess();
assertAbortSentAndRespondWithSuccess();

View File

@ -548,7 +548,9 @@ TEST_F(TransactionCoordinatorDriverTest,
kTwoShardIdList);
onCommands({[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; },
[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; }});
[&](const executor::RemoteCommandRequest& request) {
return kPrepareOk;
}});
auto decision = future.get().decision();
@ -587,7 +589,9 @@ TEST_F(TransactionCoordinatorDriverTest,
kTwoShardIdList);
onCommands({[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; },
[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; }});
[&](const executor::RemoteCommandRequest& request) {
return kNoSuchTransaction;
}});
auto decision = future.get().decision();
ASSERT(decision.getDecision() == txn::CommitDecision::kAbort);
@ -1306,7 +1310,9 @@ TEST_F(TransactionCoordinatorTest, RunCommitProducesAbortDecisionOnAbortAndCommi
auto commitDecisionFuture = coordinator->getDecision();
onCommands({[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; },
[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; }});
[&](const executor::RemoteCommandRequest& request) {
return kPrepareOk;
}});
assertAbortSentAndRespondWithSuccess();
assertAbortSentAndRespondWithSuccess();
@ -1332,7 +1338,9 @@ TEST_F(TransactionCoordinatorTest,
auto commitDecisionFuture = coordinator->getDecision();
onCommands({[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; },
[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; }});
[&](const executor::RemoteCommandRequest& request) {
return kNoSuchTransaction;
}});
assertAbortSentAndRespondWithSuccess();
assertAbortSentAndRespondWithSuccess();
@ -1357,9 +1365,10 @@ TEST_F(TransactionCoordinatorTest,
coordinator->runCommit(operationContext(), kTwoShardIdList);
auto commitDecisionFuture = coordinator->getDecision();
onCommands(
{[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; },
[&](const executor::RemoteCommandRequest& request) { return kTxnRetryCounterTooOld; }});
onCommands({[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; },
[&](const executor::RemoteCommandRequest& request) {
return kTxnRetryCounterTooOld;
}});
assertAbortSentAndRespondWithSuccess();
assertAbortSentAndRespondWithSuccess();
@ -1411,7 +1420,9 @@ TEST_F(TransactionCoordinatorTest,
// One participant votes commit and other encounters retryable error
onCommands({[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; },
[&](const executor::RemoteCommandRequest& request) { return kRetryableError; }});
[&](const executor::RemoteCommandRequest& request) {
return kRetryableError;
}});
advanceClockAndExecuteScheduledTasks(); // Make sure the scheduled retry executes
// One participant votes abort after retry.
@ -1442,7 +1453,9 @@ TEST_F(TransactionCoordinatorTest,
// One participant votes abort and other encounters retryable error
onCommands({[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; },
[&](const executor::RemoteCommandRequest& request) { return kRetryableError; }});
[&](const executor::RemoteCommandRequest& request) {
return kRetryableError;
}});
advanceClockAndExecuteScheduledTasks(); // Make sure the cancellation callback is delivered
assertAbortSentAndRespondWithSuccess();

View File

@ -550,7 +550,9 @@ typename T::ConstructorActionRegisterer registerConstructorAction(
return typename T::ConstructorActionRegisterer{name,
prereqs,
[name](T*) { actionListener.onConstruct(name); },
[name](T*) { actionListener.onDestruct(name); }};
[name](T*) {
actionListener.onDestruct(name);
}};
}
const auto serviceContext1Registerer = registerConstructorAction<ServiceContext>("ServiceContext1");

View File

@ -1788,7 +1788,9 @@ TEST_F(DConcurrencyTestFixture,
auto result = task.get_future();
stdx::thread taskThread{std::move(task)};
ScopeGuard joinGuard{[&taskThread] { taskThread.join(); }};
ScopeGuard joinGuard{[&taskThread] {
taskThread.join();
}};
// Wait for the database X lock to conflict.
while (!shard_role_details::getLocker(opCtx2)->hasLockPending()) {

View File

@ -216,7 +216,9 @@ private:
return visit(
OverloadedVisitor{
[](std::reference_wrapper<RecoveryUnit> ru) -> RecoveryUnit& { return ru; },
[](const std::function<RecoveryUnit&()>& ru) -> RecoveryUnit& { return ru(); }},
[](const std::function<RecoveryUnit&()>& ru) -> RecoveryUnit& {
return ru();
}},
_ru);
}

View File

@ -570,12 +570,13 @@ DropIndexesReply dropIndexes(OperationContext* opCtx,
"CMD: dropIndexes",
logAttrs(collAcq->nss()),
"uuid"_attr = collectionUUID,
"indexes"_attr =
visit(OverloadedVisitor{[](const std::string& arg) { return arg; },
"indexes"_attr = visit(OverloadedVisitor{[](const std::string& arg) { return arg; },
[](const std::vector<std::string>& arg) {
return boost::algorithm::join(arg, ",");
},
[](const BSONObj& arg) { return arg.toString(); }},
[](const BSONObj& arg) {
return arg.toString();
}},
index));
}

View File

@ -633,8 +633,9 @@ StatusWith<std::vector<BSONObj>> Shard::runAggregationWithResult(
Shard::RetryStrategy::RequestStartTransactionState isStartTransaction =
Shard::RetryStrategy::extractRequestTransactionState(aggRequest.getGenericArguments());
RetryStrategyWithFailureRetryHook retryStrategy{
RetryStrategy{*this, retryPolicy, isStartTransaction},
[&](Status s) { aggResult.clear(); }};
RetryStrategy{*this, retryPolicy, isStartTransaction}, [&](Status s) {
aggResult.clear();
}};
auto status =
runWithRetryStrategy(opCtx, retryStrategy, [&](const TargetingMetadata& targetingMetadata) {

View File

@ -183,8 +183,10 @@ std::unique_ptr<ShardRegistry> ShardingMongoDTestFixture::makeShardRegistry(
std::make_unique<ShardFactory>(std::move(buildersMap), std::move(targeterFactory));
auto shardRemovalHooks = std::vector<ShardRegistry::ShardRemovalHook>{
[&shardSharedStateCache = ShardSharedStateCache::get(service)](
const ShardId& removedShard) { shardSharedStateCache.forgetShardState(removedShard); }};
[&shardSharedStateCache =
ShardSharedStateCache::get(service)](const ShardId& removedShard) {
shardSharedStateCache.forgetShardState(removedShard);
}};
return std::make_unique<ShardRegistry>(
getServiceContext(), std::move(shardFactory), configConnStr, std::move(shardRemovalHooks));

View File

@ -355,7 +355,9 @@ std::string toString(const StorageEngine::OldestActiveTransactionTimestampResult
void setKeyOnCursor(WT_CURSOR* c, const std::variant<std::span<const char>, int64_t>& key) {
std::visit(OverloadedVisitor{
[&](const std::span<const char> k) { c->set_key(c, WiredTigerItem{k}.get()); },
[&](int64_t k) { c->set_key(c, k); }},
[&](int64_t k) {
c->set_key(c, k);
}},
key);
}

View File

@ -449,7 +449,9 @@ TEST_F(WiredTigerRecoveryUnitTestFixture, ReadUncommittedIsolation) {
auto session = ru2->getSession();
ru1->beginUnitOfWork(clientAndCtx1.second->readOnly());
ScopeGuard guard{[this] { ru1->abortUnitOfWork(); }};
ScopeGuard guard{[this] {
ru1->abortUnitOfWork();
}};
WT_CURSOR* cursor;
getCursor(ru1, &cursor);
@ -474,7 +476,9 @@ TEST_F(WiredTigerRecoveryUnitTestFixture, ReadCommittedIsolation) {
auto session = ru2->getSession();
ru1->beginUnitOfWork(clientAndCtx1.second->readOnly());
ScopeGuard guard{[this] { ru1->abortUnitOfWork(); }};
ScopeGuard guard{[this] {
ru1->abortUnitOfWork();
}};
WT_CURSOR* cursor;
getCursor(ru1, &cursor);
@ -499,7 +503,9 @@ TEST_F(WiredTigerRecoveryUnitTestFixture, SnapshotIsolation) {
auto session = ru2->getSession();
ru1->beginUnitOfWork(clientAndCtx1.second->readOnly());
ScopeGuard guard{[this] { ru1->abortUnitOfWork(); }};
ScopeGuard guard{[this] {
ru1->abortUnitOfWork();
}};
WT_CURSOR* cursor;
getCursor(ru1, &cursor);

View File

@ -62,7 +62,9 @@ WiredTigerStats::WiredTigerStats(WiredTigerSession& session) {
"Unable to open statistics cursor",
!session.open_cursor("statistics:session", nullptr, "statistics=(fast)", &c));
ScopeGuard guard{[c] { c->close(c); }};
ScopeGuard guard{[c] {
c->close(c);
}};
// Get all the stats
while (c->next(c) == 0) {

View File

@ -1653,8 +1653,9 @@ TEST_F(BucketCatalogTest, CannotConcurrentlyCommitBatchesForSameBucket) {
{
auto task = RunBackgroundTaskAndWaitForFailpoint{
"hangTimeSeriesBatchPrepareWaitingForConflictingOperation",
[&]() { ASSERT_OK(prepareCommit(*_bucketCatalog, batch2, _getCollator(_ns1))); }};
"hangTimeSeriesBatchPrepareWaitingForConflictingOperation", [&]() {
ASSERT_OK(prepareCommit(*_bucketCatalog, batch2, _getCollator(_ns1)));
}};
// Finish the first batch.
finish(*_bucketCatalog, batch1);
@ -1689,8 +1690,9 @@ TEST_F(BucketCatalogTest, AbortingBatchEnsuresBucketIsEventuallyClosed) {
{
auto task = RunBackgroundTaskAndWaitForFailpoint{
"hangTimeSeriesBatchPrepareWaitingForConflictingOperation",
[&]() { ASSERT_NOT_OK(prepareCommit(*_bucketCatalog, batch2, _getCollator(_ns2))); }};
"hangTimeSeriesBatchPrepareWaitingForConflictingOperation", [&]() {
ASSERT_NOT_OK(prepareCommit(*_bucketCatalog, batch2, _getCollator(_ns2)));
}};
// If we abort the third batch, it should abort the second one too, as it isn't prepared.
// However, since the first batch is prepared, we can't abort it or clean up the bucket. We

View File

@ -77,7 +77,9 @@ public:
return bucketState == BucketState::kCleared ||
bucketState == BucketState::kPreparedAndCleared;
},
[](DirectWriteCounter dwcount) { return false; }},
[](DirectWriteCounter dwcount) {
return false;
}},
*state);
}

View File

@ -157,7 +157,9 @@ void appendElementToBuilder(std::variant<mutablebson::Element, BSONElement> elem
element.writeArrayTo(&subBuilder);
}
},
[&](BSONElement element) { builder->appendAs(element, fieldName); }},
[&](BSONElement element) {
builder->appendAs(element, fieldName);
}},
elem);
}
@ -537,8 +539,9 @@ boost::optional<std::pair<size_t, ArrayDiffReader::ArrayModification>> ArrayDiff
str::stream() << "expected sub diff at index " << idx << " but got " << next,
next.type() == BSONType::object);
auto modification = visit(
OverloadedVisitor{[](const auto& reader) -> ArrayModification { return {reader}; }},
auto modification = visit(OverloadedVisitor{[](const auto& reader) -> ArrayModification {
return {reader};
}},
getReader(next.embeddedObject()));
return {{idx, modification}};
} else {

View File

@ -87,7 +87,9 @@ void VersionContext::resetToOperationWithoutOFCV() {
BSONObj VersionContext::toBSON() const {
return visit(
OverloadedVisitor{[](const VersionContextMetadata& metadata) { return metadata.toBSON(); },
[](auto&&) -> BSONObj { MONGO_UNREACHABLE_TASSERT(10083532); }},
[](auto&&) -> BSONObj {
MONGO_UNREACHABLE_TASSERT(10083532);
}},
_metadataOrTag);
}

View File

@ -88,7 +88,9 @@ void serializeWriteConcernW(const WriteConcernW& w, StringData fieldName, BSONOb
builder->appendNumber(fieldName, static_cast<long long>(wNumNodes));
},
[&](const std::string& wMode) { builder->append(fieldName, wMode); },
[&](WTags wTags) { builder->append(fieldName, wTags); }},
[&](WTags wTags) {
builder->append(fieldName, wTags);
}},
w);
}

View File

@ -91,7 +91,8 @@ class EmbeddedBuilder {
public:
explicit EmbeddedBuilder(BSONObjBuilder* root) {
// Root isn't owned, so give it a nop deleter.
_builders.push_back({{}, {root, [](auto) {}}});
_builders.push_back({{}, {root, [](auto) {
}}});
}
void appendAs(const BSONElement& e, StringData name) {

View File

@ -165,9 +165,11 @@ public:
}
};
const auto implRegisterer = ServiceContext::ConstructorActionRegisterer{
"RemoteCommmandRunner",
[](ServiceContext* ctx) { getRCRImpl(ctx) = std::make_unique<AsyncRPCRunnerImpl>(); }};
const auto implRegisterer =
ServiceContext::ConstructorActionRegisterer{"RemoteCommmandRunner", [](ServiceContext* ctx) {
getRCRImpl(ctx) =
std::make_unique<AsyncRPCRunnerImpl>();
}};
AsyncRPCRunner* AsyncRPCRunner::get(ServiceContext* svcCtx) {
return getRCRImpl(svcCtx).get();

View File

@ -354,7 +354,9 @@ TEST_F(ThreadPoolExecutorTest, CancelFromAnotherThread) {
finishedShutdown.get();
});
unittest::JoinThread th{[&] { executor.cancel(swCbHandle.getValue()); }};
unittest::JoinThread th{[&] {
executor.cancel(swCbHandle.getValue());
}};
startedCancellation.get();
shutdownExecutorThread();

View File

@ -121,7 +121,8 @@ GetTenantIDFn& getTenantID() {
return *fn;
}
LogCounterCallback& getLogCounterCallback() {
static StaticImmortal<LogCounterCallback> fn{[]() {}};
static StaticImmortal<LogCounterCallback> fn{[]() {
}};
return *fn;
}
} // namespace

View File

@ -74,12 +74,10 @@ private:
};
/** Helper to create MetricName instances. */
class MONGO_MOD_FILE_PRIVATE MetricNameMaker {
public:
static constexpr MetricName make(StringData name) {
return MetricName(name, Passkey<MetricNameMaker>{});
}
};
class MONGO_MOD_FILE_PRIVATE MetricNameMaker{public : static constexpr MetricName make(
StringData name){return MetricName(name, Passkey<MetricNameMaker>{});
} // namespace otel::metrics
}; // namespace mongo
/**
* Central registry of OpenTelemetry metric names used in the server. When adding a new metric to

View File

@ -222,7 +222,9 @@ TEST_F(PrometheusFileExporterTest, SkippedExportIncrementsCounter) {
// guarantee that one export is skipped.
auto [promise, future] = makePromiseFuture<void>();
std::unique_ptr<PushMetricExporter> exporter =
makeExporter(/*options=*/{.testOnlyFailpointCallback = [&future]() { future.wait(); }});
makeExporter(/*options=*/{.testOnlyFailpointCallback = [&future]() {
future.wait();
}});
FailPointEnableBlock fp("metricsPrometheusFileExporterThreadCallback",
BSON("UnlockOnly" << true));
@ -493,8 +495,9 @@ TEST_F(PrometheusFileExporterTest, ExactlyMaxConsecutiveSkipsIsOk) {
// The writer thread blocks on this future.
auto [promise, future] = makePromiseFuture<void>();
std::unique_ptr<PushMetricExporter> exporter = makeExporter(
/*options=*/{.maxConsecutiveFailures = 3,
.testOnlyFailpointCallback = [&future]() { future.wait(); }});
/*options=*/{.maxConsecutiveFailures = 3, .testOnlyFailpointCallback = [&future]() {
future.wait();
}});
FailPointEnableBlock fp("metricsPrometheusFileExporterThreadCallback",
BSON("UnlockOnly" << true));
@ -514,8 +517,9 @@ DEATH_TEST_F(PrometheusFileExporterDeathTest,
// The writer thread blocks on this future.
auto [promise, future] = makePromiseFuture<void>();
std::unique_ptr<PushMetricExporter> exporter = makeExporter(
/*options=*/{.maxConsecutiveFailures = 3,
.testOnlyFailpointCallback = [&future]() { future.wait(); }});
/*options=*/{.maxConsecutiveFailures = 3, .testOnlyFailpointCallback = [&future]() {
future.wait();
}});
FailPointEnableBlock fp("metricsPrometheusFileExporterThreadCallback",
BSON("UnlockOnly" << true));

View File

@ -370,7 +370,9 @@ private:
// See documentWithoutMongosInfo().
Deferred<BSONObj (*)(const BSONObj&)> _documentWithoutMongosInfo{
[](const BSONObj& fullDocument) { return fullDocument.removeField("mongos"); }};
[](const BSONObj& fullDocument) {
return fullDocument.removeField("mongos");
}};
// See hashWithoutMongosInfo().
Deferred<size_t (*)(const BSONObj&)> _hashWithoutMongos{simpleHash};

View File

@ -38,6 +38,7 @@ void visit(DocsNeededBoundsContext* ctx, const T&) {
}
const ServiceContext::ConstructorActionRegisterer DocsNeededBoundsRegisterer{
"DocsNeededBoundsRegistererMongos",
[](ServiceContext* service) { registerMongosVisitor<DocsNeededBoundsContext>(service); }};
"DocsNeededBoundsRegistererMongos", [](ServiceContext* service) {
registerMongosVisitor<DocsNeededBoundsContext>(service);
}};
} // namespace mongo

View File

@ -156,7 +156,9 @@ void BatchedCommandRequest::unsetLegacyRuntimeConstants() {
_visit(OverloadedVisitor{
[](write_ops::InsertCommandRequest&) {},
[&](write_ops::UpdateCommandRequest& op) { op.setLegacyRuntimeConstants(boost::none); },
[&](write_ops::DeleteCommandRequest& op) { op.setLegacyRuntimeConstants(boost::none); }});
[&](write_ops::DeleteCommandRequest& op) {
op.setLegacyRuntimeConstants(boost::none);
}});
}
const boost::optional<LegacyRuntimeConstants>& BatchedCommandRequest::getLegacyRuntimeConstants()
@ -193,7 +195,9 @@ const boost::optional<BSONObj>& BatchedCommandRequest::getLet() const {
void BatchedCommandRequest::setLet(boost::optional<mongo::BSONObj> value) {
_visit(OverloadedVisitor{[&](write_ops::InsertCommandRequest& op) {},
[&](write_ops::UpdateCommandRequest& op) { op.setLet(value); },
[&](write_ops::DeleteCommandRequest& op) { op.setLet(value); }});
[&](write_ops::DeleteCommandRequest& op) {
op.setLet(value);
}});
}
void BatchedCommandRequest::evaluateAndReplaceLetParams(OperationContext* opCtx) {

View File

@ -203,7 +203,9 @@ const BSONObj& BatchWriteCommandRefImpl::getFilter(int index) const {
index,
OverloadedVisitor{
[&](const write_ops::UpdateOpEntry& updateOp) -> RetT { return updateOp.getQ(); },
[&](const write_ops::DeleteOpEntry& deleteOp) -> RetT { return deleteOp.getQ(); }});
[&](const write_ops::DeleteOpEntry& deleteOp) -> RetT {
return deleteOp.getQ();
}});
}
const BSONObj& BatchWriteCommandRefImpl::getHint(int index) const {
@ -212,7 +214,9 @@ const BSONObj& BatchWriteCommandRefImpl::getHint(int index) const {
index,
OverloadedVisitor{
[&](const write_ops::UpdateOpEntry& updateOp) -> RetT { return updateOp.getHint(); },
[&](const write_ops::DeleteOpEntry& deleteOp) -> RetT { return deleteOp.getHint(); }});
[&](const write_ops::DeleteOpEntry& deleteOp) -> RetT {
return deleteOp.getHint();
}});
}
const BSONObj& BatchWriteCommandRefImpl::getDocument(int index) const {
@ -221,12 +225,14 @@ const BSONObj& BatchWriteCommandRefImpl::getDocument(int index) const {
}
bool BatchWriteCommandRefImpl::getMulti(int index) const {
return visitOpData(
index,
OverloadedVisitor{
[&](const BSONObj& insertDoc) { return false; },
[&](const write_ops::UpdateOpEntry& updateOp) { return updateOp.getMulti(); },
[&](const write_ops::DeleteOpEntry& deleteOp) { return deleteOp.getMulti(); }});
return visitOpData(index,
OverloadedVisitor{[&](const BSONObj& insertDoc) { return false; },
[&](const write_ops::UpdateOpEntry& updateOp) {
return updateOp.getMulti();
},
[&](const write_ops::DeleteOpEntry& deleteOp) {
return deleteOp.getMulti();
}});
}
const NamespaceString& BatchWriteCommandRefImpl::getNss(int index) const {
@ -264,12 +270,14 @@ const write_ops::UpdateModification& BatchWriteCommandRefImpl::getUpdateMods(int
}
bool BatchWriteCommandRefImpl::getUpsert(int index) const {
return visitOpData(
index,
OverloadedVisitor{
[&](const BSONObj& insertDoc) { return false; },
[&](const write_ops::UpdateOpEntry& updateOp) { return updateOp.getUpsert(); },
[&](const write_ops::DeleteOpEntry& deleteOp) { return false; }});
return visitOpData(index,
OverloadedVisitor{[&](const BSONObj& insertDoc) { return false; },
[&](const write_ops::UpdateOpEntry& updateOp) {
return updateOp.getUpsert();
},
[&](const write_ops::DeleteOpEntry& deleteOp) {
return false;
}});
}
OptionalBool BatchWriteCommandRefImpl::getUpsertSupplied(int index) const {
@ -308,16 +316,20 @@ boost::optional<mongo::BSONObj> BatchWriteCommandRefImpl::getSort(int index) con
OverloadedVisitor{
[&](const BSONObj& insertDoc) -> RetT { return boost::none; },
[&](const write_ops::UpdateOpEntry& updateOp) -> RetT { return updateOp.getSort(); },
[&](const write_ops::DeleteOpEntry& deleteOp) -> RetT { return boost::none; }});
[&](const write_ops::DeleteOpEntry& deleteOp) -> RetT {
return boost::none;
}});
}
BSONObj BatchWriteCommandRefImpl::toBSON(int index) const {
return visitOpData(
index,
OverloadedVisitor{
[&](const BSONObj& insertDoc) { return insertDoc; },
[&](const write_ops::UpdateOpEntry& updateOp) { return updateOp.toBSON(); },
[&](const write_ops::DeleteOpEntry& deleteOp) { return deleteOp.toBSON(); }});
return visitOpData(index,
OverloadedVisitor{[&](const BSONObj& insertDoc) { return insertDoc; },
[&](const write_ops::UpdateOpEntry& updateOp) {
return updateOp.toBSON();
},
[&](const write_ops::DeleteOpEntry& deleteOp) {
return deleteOp.toBSON();
}});
}
int BulkWriteCommandRefImpl::estimateOpSizeInBytes(int index) const {
@ -377,7 +389,9 @@ const boost::optional<BSONObj>& BulkWriteCommandRefImpl::getCollation(int index)
OverloadedVisitor{
[&](const BulkWriteInsertOp& insertOp) -> RetT { return kMissingBSONObj; },
[&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getCollation(); },
[&](const BulkWriteDeleteOp& deleteOp) -> RetT { return deleteOp.getCollation(); }});
[&](const BulkWriteDeleteOp& deleteOp) -> RetT {
return deleteOp.getCollation();
}});
}
boost::optional<BSONObj> BulkWriteCommandRefImpl::getConstants(int index) const {
@ -392,7 +406,9 @@ const BSONObj& BulkWriteCommandRefImpl::getFilter(int index) const {
index,
OverloadedVisitor{
[&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getFilter(); },
[&](const BulkWriteDeleteOp& deleteOp) -> RetT { return deleteOp.getFilter(); }});
[&](const BulkWriteDeleteOp& deleteOp) -> RetT {
return deleteOp.getFilter();
}});
}
boost::optional<UUID> BulkWriteCommandRefImpl::getSampleId(int index) const {
@ -401,7 +417,9 @@ boost::optional<UUID> BulkWriteCommandRefImpl::getSampleId(int index) const {
index,
OverloadedVisitor{
[&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getSampleId(); },
[&](const BulkWriteDeleteOp& deleteOp) -> RetT { return deleteOp.getSampleId(); }});
[&](const BulkWriteDeleteOp& deleteOp) -> RetT {
return deleteOp.getSampleId();
}});
}
const BSONObj& BulkWriteCommandRefImpl::getHint(int index) const {
@ -410,7 +428,9 @@ const BSONObj& BulkWriteCommandRefImpl::getHint(int index) const {
index,
OverloadedVisitor{
[&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getHint(); },
[&](const BulkWriteDeleteOp& deleteOp) -> RetT { return deleteOp.getHint(); }});
[&](const BulkWriteDeleteOp& deleteOp) -> RetT {
return deleteOp.getHint();
}});
}
const BSONObj& BulkWriteCommandRefImpl::getDocument(int index) const {
@ -424,7 +444,9 @@ bool BulkWriteCommandRefImpl::getMulti(int index) const {
index,
OverloadedVisitor{[&](const BulkWriteInsertOp& insertOp) { return false; },
[&](const BulkWriteUpdateOp& updateOp) { return updateOp.getMulti(); },
[&](const BulkWriteDeleteOp& deleteOp) { return deleteOp.getMulti(); }});
[&](const BulkWriteDeleteOp& deleteOp) {
return deleteOp.getMulti();
}});
}
const NamespaceString& BulkWriteCommandRefImpl::getNss(int index) const {
@ -445,7 +467,9 @@ BatchedCommandRequest::BatchType BulkWriteCommandRefImpl::getOpType(int index) c
OverloadedVisitor{
[&](const BulkWriteInsertOp&) { return BatchedCommandRequest::BatchType_Insert; },
[&](const BulkWriteUpdateOp&) { return BatchedCommandRequest::BatchType_Update; },
[&](const BulkWriteDeleteOp&) { return BatchedCommandRequest::BatchType_Delete; }});
[&](const BulkWriteDeleteOp&) {
return BatchedCommandRequest::BatchType_Delete;
}});
}
const write_ops::UpdateModification& BulkWriteCommandRefImpl::getUpdateMods(int index) const {
@ -477,7 +501,9 @@ bool BulkWriteCommandRefImpl::getUpsert(int index) const {
index,
OverloadedVisitor{[&](const BulkWriteInsertOp& insertOp) { return false; },
[&](const BulkWriteUpdateOp& updateOp) { return updateOp.getUpsert(); },
[&](const BulkWriteDeleteOp& deleteOp) { return false; }});
[&](const BulkWriteDeleteOp& deleteOp) {
return false;
}});
}
const boost::optional<mongo::EncryptionInformation>&
@ -496,7 +522,9 @@ boost::optional<mongo::BSONObj> BulkWriteCommandRefImpl::getSort(int index) cons
OverloadedVisitor{
[&](const BulkWriteInsertOp& insertOp) -> RetT { return boost::none; },
[&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getSort(); },
[&](const BulkWriteDeleteOp& deleteOp) -> RetT { return boost::none; }});
[&](const BulkWriteDeleteOp& deleteOp) -> RetT {
return boost::none;
}});
}
BSONObj BulkWriteCommandRefImpl::toBSON(int index) const {

View File

@ -218,7 +218,9 @@ int recursionTestImpl(bool useSigAltStack) {
void* deepestAddress;
const std::function<void()> recur;
};
MostlyInfiniteRecursion recursion = {0, &recursion, [&] { recursion.run(); }};
MostlyInfiniteRecursion recursion = {0, &recursion, [&] {
recursion.run();
}};
// When the signal handler fires, it will return to this sigsetjmp call, causing
// it to return a nonzero value. This makes the child thread viable again, and

View File

@ -126,7 +126,9 @@ class ConnectionThread {
public:
explicit ConnectionThread(int port) : ConnectionThread(port, nullptr) {}
ConnectionThread(int port, std::function<void(ConnectionThread&)> onConnect)
: _port{port}, _onConnect{std::move(onConnect)}, _thread{[this] { _run(); }} {}
: _port{port}, _onConnect{std::move(onConnect)}, _thread{[this] {
_run();
}} {}
~ConnectionThread() {
LOGV2(6109500, "connection: Tx stop request");
@ -1064,7 +1066,9 @@ TEST(AsioTransportLayer, EgressConnectionResetByPeerDuringSessionCtor) {
conn->socket.close();
fp.reset();
});
test::JoinThread ioThread{[&] { ioContext.run(); }};
test::JoinThread ioThread{[&] {
ioContext.run();
}};
ScopeGuard ioContextStop = [&] {
ioContext.stop();
};
@ -1102,7 +1106,9 @@ TEST(AsioTransportLayer, ConfirmSocketSetOptionOnResetConnections) {
sleepFor(Seconds{1});
accepted.set(true);
});
test::JoinThread ioThread{[&] { ioContext.run(); }};
test::JoinThread ioThread{[&] {
ioContext.run();
}};
ScopeGuard ioContextStop = [&] {
ioContext.stop();
};

View File

@ -82,7 +82,9 @@ struct MONGO_MOD_NEEDS_REPLACEMENT SessionThread {
struct StopException {};
explicit SessionThread(std::shared_ptr<transport::Session> s)
: _session{std::move(s)}, _thread{[this] { _run(); }} {}
: _session{std::move(s)}, _thread{[this] {
_run();
}} {}
~SessionThread() {
if (!_thread.joinable())

View File

@ -63,7 +63,9 @@ public:
/** Spawn and return a `stdx::thread` that invokes `f` as if by `exec(f)`. */
template <typename F>
stdx::thread spawn(F&& f) {
return stdx::thread{[this, f = std::move(f)]() mutable { exec(std::move(f)); }};
return stdx::thread{[this, f = std::move(f)]() mutable {
exec(std::move(f));
}};
}
/** Spawn a thread that will invoke monitor.notifyDone()` when it finishes. */

View File

@ -60,7 +60,9 @@ TEST(ThreadAssertionMonitor, Trivial) {
TEST(ThreadAssertionMonitor, ControllerInStdxThread) {
ThreadAssertionMonitor monitor;
stdx::thread{[&] { monitor.notifyDone(); }}.join();
stdx::thread{[&] {
monitor.notifyDone();
}}.join();
}
TEST(ThreadAssertionMonitor, OnlyControllerInSpawn) {

View File

@ -178,7 +178,9 @@ void BackgroundJob::go() {
// If the job is already 'done', for instance because it was cancelled or already
// finished, ignore additional requests to run the job.
if (_status->state == NotStarted) {
stdx::thread{[this] { jobBody(); }}.detach();
stdx::thread{[this] {
jobBody();
}}.detach();
_status->state = Running;
}
}

View File

@ -286,7 +286,7 @@ struct UFDeductionHelper {};
template <typename Class, typename Ret, typename... Args>
struct UFDeductionHelper<Ret (Class::*)(Args...)> : std::type_identity<Ret(Args...)> {};
template <typename Class, typename Ret, typename... Args>
struct UFDeductionHelper<Ret (Class::*)(Args...) &> : std::type_identity<Ret(Args...)> {};
struct UFDeductionHelper<Ret (Class::*)(Args...)&> : std::type_identity<Ret(Args...)> {};
template <typename Class, typename Ret, typename... Args>
struct UFDeductionHelper<Ret (Class::*)(Args...) const> : std::type_identity<Ret(Args...)> {};
template <typename Class, typename Ret, typename... Args>

View File

@ -120,7 +120,9 @@ TEST(UniqueFunctionTest, construct_simple_unique_function_from_lambda) {
// Explicit construction
{
RunDetection<0> runDetection;
mongo::unique_function<void()> uf{[] { RunDetection<0>::itRan = true; }};
mongo::unique_function<void()> uf{[] {
RunDetection<0>::itRan = true;
}};
uf();

View File

@ -304,7 +304,9 @@ using unittest::JoinThread;
TEST(SharedFuture, ConcurrentTest_Simple) {
SharedPromise<void> promise;
auto shared = promise.getFuture();
JoinThread thread{stdx::thread{[&] { shared.get(); }}};
JoinThread thread{stdx::thread{[&] {
shared.get();
}}};
std::this_thread::yield(); // Slightly increase the chance of racing.
promise.emplaceValue();
}

View File

@ -619,8 +619,9 @@ public:
ExtractRetryParameters extractRetryParameters = {}) && {
using ReturnType = FutureContinuationResult<Callable, const TargetingMetadata&>;
return mongo::AsyncTry{
[body = std::move(_body), strategy] { return body(strategy->getTargetingMetadata()); }}
return mongo::AsyncTry{[body = std::move(_body), strategy] {
return body(strategy->getTargetingMetadata());
}}
.until([strategy, extractRetryParameters = std::move(extractRetryParameters)](
const StatusOrStatusWith<ReturnType>& swResult) {
auto result = extractRetryParameters(swResult);

View File

@ -82,7 +82,9 @@ public:
std::vector<std::tuple<void*, size_t, size_t>> upstreamDeallocations;
MockResource<> mockResource{
[&](void* p, size_t sz, size_t al) { upstreamAllocations.push_back({p, sz, al}); },
[&](void* p, size_t sz, size_t al) { upstreamDeallocations.push_back({p, sz, al}); }};
[&](void* p, size_t sz, size_t al) {
upstreamDeallocations.push_back({p, sz, al});
}};
};
TEST_F(MonotonicBufferResourceTest, UpstreamAllocationsReduced) {

View File

@ -69,7 +69,9 @@ private:
template <typename T>
static inline VTable forT = VTable{+[](void* t) { static_cast<T*>(t)->lock(); },
+[](void* t) { static_cast<T*>(t)->unlock(); }};
+[](void* t) {
static_cast<T*>(t)->unlock();
}};
void* _underlyingLock;
const VTable* _vtable;

View File

@ -144,7 +144,9 @@ public:
bool containsClusterMembershipConfig = false;
bool containsOverrideClusterMembershipConfig = false;
auto visitor = OverloadedVisitor{[](const SSLX509Name&) { return false; },
[](const std::string&) { return true; }};
[](const std::string&) {
return true;
}};
if (_clusterAuthX509Config._configCriteria) {
containsClusterMembershipConfig =

View File

@ -53,7 +53,7 @@ struct SigHelper<Ret (*)(Args...)> : std::type_identity<Ret(Args...)> {};
template <typename Class, typename Ret, typename... Args>
struct SigHelper<Ret (Class::*)(Args...)> : std::type_identity<Ret(Args...)> {};
template <typename Class, typename Ret, typename... Args>
struct SigHelper<Ret (Class::*)(Args...) &> : std::type_identity<Ret(Args...)> {};
struct SigHelper<Ret (Class::*)(Args...)&> : std::type_identity<Ret(Args...)> {};
template <typename Class, typename Ret, typename... Args>
struct SigHelper<Ret (Class::*)(Args...) const> : std::type_identity<Ret(Args...)> {};
template <typename Class, typename Ret, typename... Args>

View File

@ -525,10 +525,15 @@ public:
};
std::set<CpuId, decltype(cmp)> cpuIds(cmp);
CpuInfoParser cpuInfoParser{
{
{"physical id", [&](const std::string& value) { parsedCpuId.physical = value; }},
{"core id", [&](const std::string& value) { parsedCpuId.core = value; }},
CpuInfoParser cpuInfoParser{{
{"physical id",
[&](const std::string& value) {
parsedCpuId.physical = value;
}},
{"core id",
[&](const std::string& value) {
parsedCpuId.core = value;
}},
},
[&]() {
cpuIds.insert(parsedCpuId);
@ -545,11 +550,14 @@ public:
static int getNumCpuSockets() {
std::set<std::string> socketIds;
CpuInfoParser cpuInfoParser{
{
{"physical id", [&](const std::string& value) { socketIds.insert(value); }},
CpuInfoParser cpuInfoParser{{
{"physical id",
[&](const std::string& value) {
socketIds.insert(value);
}},
},
[]() {}};
[]() {
}};
cpuInfoParser.run();
// On ARM64, the "physical id" field is unpopulated, causing there to be 0 sockets found. In
@ -572,25 +580,61 @@ public:
procCount = 0;
CpuInfoParser cpuInfoParser{
{
CpuInfoParser cpuInfoParser{{
#ifdef __s390x__
{R"re(processor\s+\d+)re", [&](const std::string& value) { procCount++; }},
{"cpu MHz static", [&](const std::string& value) { freq = value; }},
{"features", [&](const std::string& value) { features = value; }},
{R"re(processor\s+\d+)re",
[&](const std::string& value) {
procCount++;
}},
{"cpu MHz static",
[&](const std::string& value) {
freq = value;
}},
{"features",
[&](const std::string& value) {
features = value;
}},
#else
{"processor", [&](const std::string& value) { procCount++; }},
{"model name", [&](const std::string& value) { modelString = value; }},
{"cpu MHz", [&](const std::string& value) { freq = value; }},
{"flags", [&](const std::string& value) { features = value; }},
{"CPU implementer", [&](const std::string& value) { cpuImplementer = value; }},
{"CPU architecture", [&](const std::string& value) { cpuArchitecture = value; }},
{"CPU variant", [&](const std::string& value) { cpuVariant = value; }},
{"CPU part", [&](const std::string& value) { cpuPart = value; }},
{"CPU revision", [&](const std::string& value) { cpuRevision = value; }},
{"processor",
[&](const std::string& value) {
procCount++;
}},
{"model name",
[&](const std::string& value) {
modelString = value;
}},
{"cpu MHz",
[&](const std::string& value) {
freq = value;
}},
{"flags",
[&](const std::string& value) {
features = value;
}},
{"CPU implementer",
[&](const std::string& value) {
cpuImplementer = value;
}},
{"CPU architecture",
[&](const std::string& value) {
cpuArchitecture = value;
}},
{"CPU variant",
[&](const std::string& value) {
cpuVariant = value;
}},
{"CPU part",
[&](const std::string& value) {
cpuPart = value;
}},
{"CPU revision",
[&](const std::string& value) {
cpuRevision = value;
}},
#endif
},
[]() {}};
[]() {
}};
cpuInfoParser.run();
}

View File

@ -234,7 +234,7 @@ private:
__VA_ARGS__(name##CB{}); \
} \
template <typename Helper> \
void name##CB::operator()(Helper&& helper)
void name##CB::operator()(Helper && helper)
PRODUCER_CONSUMER_QUEUE_TEST(basicPushPop, runPermutations<false, false>) {
typename Helper::template ProducerConsumerQueue<MoveOnly> pcq{};

View File

@ -728,7 +728,9 @@ TEST_F(PrintAllThreadStacksTest, SessionBasic) {
stacktrace_details::PrintAllStacksSession session;
auto waiter = boost::make_optional(session.waiter());
stdx::thread producer{[&] { auto notifier = session.notifier(); }};
stdx::thread producer{[&] {
auto notifier = session.notifier();
}};
waiter = {};
producer.join();
}

View File

@ -65,7 +65,9 @@ ProfilerTag ProfilerTags::getOrInsertTag(StringData name) {
size_t CallTree::ChildrenMap::size() const {
return std::visit(
OverloadedVisitor{[](const ChildrenInlinedMap& map) -> size_t { return map.size; },
[](const ChildrenHashMap& map) -> size_t { return map.size(); }},
[](const ChildrenHashMap& map) -> size_t {
return map.size();
}},
*this);
}

View File

@ -48,7 +48,9 @@ CallTree::ChildrenHashMap getChildren(const CallTree::Node& node) {
}
return r;
},
[](const CallTree::ChildrenHashMap& map) { return map; }},
[](const CallTree::ChildrenHashMap& map) {
return map;
}},
node.children);
}

View File

@ -220,7 +220,8 @@ public:
#if __has_feature(thread_sanitizer)
__attribute__((no_sanitize("thread")))
#endif
void setSignalOnCount(int c) {
void
setSignalOnCount(int c) {
_wait = c;
}