Update clag-format to the latest (190926/r372920) version.

GitOrigin-RevId: 7861ae8ad28eb1f6a06ff3c6f56eff3f67b1d24c
This commit is contained in:
levlam 2019-09-28 05:14:21 +03:00
parent c7811a01b6
commit 0b6c1d226f
23 changed files with 198 additions and 162 deletions

View File

@ -3,16 +3,20 @@ Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None # All
AllowShortIfStatementsOnASingleLine: false # true
AllowShortIfStatementsOnASingleLine: Never # WithoutElse
AllowShortLambdasOnASingleLine: Inline # All
AllowShortLoopsOnASingleLine: false # true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
@ -21,6 +25,7 @@ AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
@ -60,6 +65,7 @@ ForEachMacros:
- Q_FOREACH_THIS_LIST_MUST_BE_NON_EMPTY
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
@ -87,6 +93,7 @@ ReflowComments: false # true
SortIncludes: false # disabled, because we need case insensitive sort
SortUsingDeclarations: false # true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
@ -94,6 +101,7 @@ SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false

View File

@ -222,15 +222,13 @@ class CreateFileBench : public Benchmark {
}
}
void tear_down() override {
td::walk_path("A/",
[&](CSlice path, auto type) {
td::walk_path("A/", [&](CSlice path, auto type) {
if (type == td::WalkPath::Type::ExitDir) {
rmdir(path).ignore();
} else if (type == td::WalkPath::Type::NotDir) {
unlink(path).ignore();
}
})
.ignore();
}).ignore();
}
};
@ -246,26 +244,22 @@ class WalkPathBench : public Benchmark {
}
void run(int n) override {
int cnt = 0;
td::walk_path("A/",
[&](CSlice path, auto type) {
td::walk_path("A/", [&](CSlice path, auto type) {
if (type == td::WalkPath::Type::EnterDir) {
return;
}
stat(path).ok();
cnt++;
})
.ignore();
}).ignore();
}
void tear_down() override {
td::walk_path("A/",
[&](CSlice path, auto type) {
td::walk_path("A/", [&](CSlice path, auto type) {
if (type == td::WalkPath::Type::ExitDir) {
rmdir(path).ignore();
} else if (type == td::WalkPath::Type::NotDir) {
unlink(path).ignore();
}
})
.ignore();
}).ignore();
}
};

View File

@ -53,7 +53,9 @@ td::Result<TlsInfo> test_tls(const td::string &url) {
td::string request;
auto add_string = [&](td::Slice data) { request.append(data.data(), data.size()); };
auto add_string = [&](td::Slice data) {
request.append(data.data(), data.size());
};
auto add_random = [&](size_t length) {
while (length-- > 0) {
request += static_cast<char>(td::Random::secure_int32());

View File

@ -202,7 +202,9 @@ class SessionConnection
auto set_buffer_slice(BufferSlice *buffer_slice) TD_WARN_UNUSED_RESULT {
auto old_buffer_slice = current_buffer_slice_;
current_buffer_slice_ = buffer_slice;
return ScopeExit() + [&to = current_buffer_slice_, from = old_buffer_slice] { to = from; };
return ScopeExit() + [&to = current_buffer_slice_, from = old_buffer_slice] {
to = from;
};
}
Status parse_message(TlParser &parser, MsgInfo *info, Slice *packet, bool crypto_flag = true) TD_WARN_UNUSED_RESULT;

View File

@ -987,7 +987,9 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
shared_config.set_option_string("photo_search_bot_username", config->img_search_username_);
}
auto fix_timeout_ms = [](int32 timeout_ms) { return clamp(timeout_ms, 1000, 86400 * 1000); };
auto fix_timeout_ms = [](int32 timeout_ms) {
return clamp(timeout_ms, 1000, 86400 * 1000);
};
shared_config.set_option_integer("online_update_period_ms", fix_timeout_ms(config->online_update_period_ms_));

View File

@ -27065,13 +27065,17 @@ void MessagesManager::suffix_load_add_query(Dialog *d,
void MessagesManager::suffix_load_till_date(Dialog *d, int32 date, Promise<> promise) {
LOG(INFO) << "Load suffix of " << d->dialog_id << " till date " << date;
auto condition = [date](const Message *m) { return m != nullptr && m->date < date; };
auto condition = [date](const Message *m) {
return m != nullptr && m->date < date;
};
suffix_load_add_query(d, std::make_pair(std::move(promise), std::move(condition)));
}
void MessagesManager::suffix_load_till_message_id(Dialog *d, MessageId message_id, Promise<> promise) {
LOG(INFO) << "Load suffix of " << d->dialog_id << " till " << message_id;
auto condition = [message_id](const Message *m) { return m != nullptr && m->message_id.get() < message_id.get(); };
auto condition = [message_id](const Message *m) {
return m != nullptr && m->message_id.get() < message_id.get();
};
suffix_load_add_query(d, std::make_pair(std::move(promise), std::move(condition)));
}

View File

@ -1662,7 +1662,9 @@ void SecretChatActor::on_outbound_send_message_result(NetQueryPtr query, Promise
[&](telegram_api::encryptedFileEmpty &) {
state->message->file = logevent::EncryptedInputFile::from_input_encrypted_file(
telegram_api::inputEncryptedFileEmpty());
get_file = [] { return telegram_api::make_object<telegram_api::encryptedFileEmpty>(); };
get_file = [] {
return telegram_api::make_object<telegram_api::encryptedFileEmpty>();
};
},
[&](telegram_api::encryptedFile &file) {
state->message->file = logevent::EncryptedInputFile::from_input_encrypted_file(

View File

@ -1551,7 +1551,9 @@ int32 UpdatesManager::get_short_update_date() const {
tl_object_ptr<td_api::ChatAction> UpdatesManager::convert_send_message_action(
tl_object_ptr<telegram_api::SendMessageAction> action) {
auto fix_progress = [](int32 progress) { return progress <= 0 || progress > 100 ? 0 : progress; };
auto fix_progress = [](int32 progress) {
return progress <= 0 || progress > 100 ? 0 : progress;
};
switch (action->get_id()) {
case telegram_api::sendMessageCancelAction::ID:

View File

@ -106,8 +106,7 @@ void scan_fs(CancellationToken &token, CallbackT &&callback) {
continue;
}
auto files_dir = get_files_dir(file_type);
walk_path(files_dir,
[&](CSlice path, WalkPath::Type type) {
walk_path(files_dir, [&](CSlice path, WalkPath::Type type) {
if (token) {
return WalkPath::Action::Abort;
}
@ -133,8 +132,7 @@ void scan_fs(CancellationToken &token, CallbackT &&callback) {
info.mtime_nsec = stat.mtime_nsec_;
callback(info);
return WalkPath::Action::Continue;
})
.ignore();
}).ignore();
}
}
} // namespace

View File

@ -228,7 +228,9 @@ bool PartsManager::is_part_in_streaming_limit(int part_i) const {
return true;
}
auto is_intersect_with = [&](int64 begin, int64 end) { return max(begin, offset_begin) < min(end, offset_end); };
auto is_intersect_with = [&](int64 begin, int64 end) {
return max(begin, offset_begin) < min(end, offset_end);
};
auto streaming_begin = streaming_offset_;
auto streaming_end = streaming_offset_ + streaming_limit_;

View File

@ -135,11 +135,9 @@ Result<DcOptionsSet::ConnectionInfo> DcOptionsSet::find_connection(DcId dc_id, b
<< tag("prefer_ipv6", prefer_ipv6));
}
auto last_error_at = std::min_element(options.begin(), options.end(),
[](const auto &a_option, const auto &b_option) {
auto last_error_at = std::min_element(options.begin(), options.end(), [](const auto &a_option, const auto &b_option) {
return a_option.stat->error_at > b_option.stat->error_at;
})
->stat->error_at;
})->stat->error_at;
auto result = *std::min_element(options.begin(), options.end(), [](const auto &a_option, const auto &b_option) {
auto &a = *a_option.stat;

View File

@ -229,7 +229,8 @@ void Scheduler::send_impl(const ActorId<> &actor_id, const RunFuncT &run_func, c
template <ActorSendType send_type, class EventT>
void Scheduler::send_lambda(ActorRef actor_ref, EventT &&lambda) {
return send_impl<send_type>(actor_ref.get(),
return send_impl<send_type>(
actor_ref.get(),
[&](ActorInfo *actor_info) {
event_context_ptr_->link_token = actor_ref.token();
lambda();
@ -243,7 +244,8 @@ void Scheduler::send_lambda(ActorRef actor_ref, EventT &&lambda) {
template <ActorSendType send_type, class EventT>
void Scheduler::send_closure(ActorRef actor_ref, EventT &&closure) {
return send_impl<send_type>(actor_ref.get(),
return send_impl<send_type>(
actor_ref.get(),
[&](ActorInfo *actor_info) {
event_context_ptr_->link_token = actor_ref.token();
closure.run(static_cast<typename EventT::ActorType *>(actor_info->get_actor_unsafe()));
@ -258,7 +260,8 @@ void Scheduler::send_closure(ActorRef actor_ref, EventT &&closure) {
template <ActorSendType send_type>
void Scheduler::send(ActorRef actor_ref, Event &&event) {
event.set_link_token(actor_ref.token());
return send_impl<send_type>(actor_ref.get(), [&](ActorInfo *actor_info) { do_event(actor_info, std::move(event)); },
return send_impl<send_type>(
actor_ref.get(), [&](ActorInfo *actor_info) { do_event(actor_info, std::move(event)); },
[&]() { return std::move(event); });
}

View File

@ -77,7 +77,8 @@ class BinlogKeyValue : public KeyValueSyncInterface {
}
binlog_ = std::make_shared<BinlogT>();
TRY_STATUS(binlog_->init(name,
TRY_STATUS(binlog_->init(
name,
[&](const BinlogEvent &binlog_event) {
Event event;
event.parse(TlParser(binlog_event.data_));

View File

@ -24,7 +24,9 @@ Result<bool> SqliteKeyValue::init(string path) {
}
Status SqliteKeyValue::init_with_connection(SqliteDb connection, string table_name) {
auto init_guard = ScopeExit() + [&]() { close(); };
auto init_guard = ScopeExit() + [&]() {
close();
};
db_ = std::move(connection);
table_name_ = std::move(table_name);
TRY_STATUS(init(db_, table_name_));

View File

@ -56,7 +56,9 @@ class SqliteStatement {
void reset();
auto guard() {
return ScopeExit{} + [this] { this->reset(); };
return ScopeExit{} + [this] {
this->reset();
};
}
// TODO get row

View File

@ -28,7 +28,8 @@ int main(int argc, char *argv[]) {
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(ERROR));
td::Binlog binlog;
binlog
.init(argv[1],
.init(
argv[1],
[&](auto &event) {
info[0].compressed_size += event.raw_event_.size();
info[event.type_].compressed_size += event.raw_event_.size();

View File

@ -224,7 +224,9 @@ class SslStreamImpl {
if (ssl_ctx == nullptr) {
return create_openssl_error(-7, "Failed to create an SSL context");
}
auto ssl_ctx_guard = ScopeExit() + [&]() { SSL_CTX_free(ssl_ctx); };
auto ssl_ctx_guard = ScopeExit() + [&]() {
SSL_CTX_free(ssl_ctx);
};
long options = 0;
#ifdef SSL_OP_NO_SSLv2
options |= SSL_OP_NO_SSLv2;

View File

@ -22,7 +22,9 @@ namespace td {
template <int id>
static FileFd &get_file_fd() {
static FileFd result = FileFd::from_native_fd(NativeFd(id, true));
static auto guard = ScopeExit() + [&] { result.move_as_native_fd().release(); };
static auto guard = ScopeExit() + [&] {
result.move_as_native_fd().release();
};
return result;
}
@ -42,7 +44,9 @@ static FileFd &get_file_fd() {
static auto handle = GetStdHandle(id);
LOG_IF(FATAL, handle == INVALID_HANDLE_VALUE) << "Failed to GetStdHandle " << id;
static FileFd result = FileFd::from_native_fd(NativeFd(handle, true));
static auto guard = ScopeExit() + [&] { result.move_as_native_fd().release(); };
static auto guard = ScopeExit() + [&] {
result.move_as_native_fd().release();
};
#else
static FileFd result;
#endif

View File

@ -31,9 +31,7 @@ class ThreadPthread {
ThreadPthread() = default;
ThreadPthread(const ThreadPthread &other) = delete;
ThreadPthread &operator=(const ThreadPthread &other) = delete;
ThreadPthread(ThreadPthread &&other) noexcept
: is_inited_(std::move(other.is_inited_))
, thread_(other.thread_) {
ThreadPthread(ThreadPthread &&other) noexcept : is_inited_(std::move(other.is_inited_)), thread_(other.thread_) {
}
ThreadPthread &operator=(ThreadPthread &&other) {
join();

View File

@ -153,7 +153,8 @@ TEST(Misc, get_last_argument) {
}
TEST(Misc, call_n_arguments) {
auto f = [](int, int) {};
auto f = [](int, int) {
};
call_n_arguments<2>(f, 1, 3, 4);
}
@ -757,8 +758,12 @@ TEST(Misc, uint128) {
static_cast<int64>(std::numeric_limits<int32>::min()) - 1};
#if TD_HAVE_INT128
auto to_intrinsic = [](uint128_emulated num) { return uint128_intrinsic(num.hi(), num.lo()); };
auto eq = [](uint128_emulated a, uint128_intrinsic b) { return a.hi() == b.hi() && a.lo() == b.lo(); };
auto to_intrinsic = [](uint128_emulated num) {
return uint128_intrinsic(num.hi(), num.lo());
};
auto eq = [](uint128_emulated a, uint128_intrinsic b) {
return a.hi() == b.hi() && a.lo() == b.lo();
};
auto ensure_eq = [&](uint128_emulated a, uint128_intrinsic b) {
if (!eq(a, b)) {
LOG(FATAL) << "[" << a.hi() << ";" << a.lo() << "] vs [" << b.hi() << ";" << b.lo() << "]";

View File

@ -41,33 +41,28 @@ TEST(Port, files) {
int cnt = 0;
const int ITER_COUNT = 1000;
for (int i = 0; i < ITER_COUNT; i++) {
walk_path(main_dir,
[&](CSlice name, WalkPath::Type type) {
walk_path(main_dir, [&](CSlice name, WalkPath::Type type) {
if (type == WalkPath::Type::NotDir) {
ASSERT_TRUE(name == fd_path || name == fd2_path);
}
cnt++;
})
.ensure();
}).ensure();
}
ASSERT_EQ((5 * 2 + 2) * ITER_COUNT, cnt);
bool was_abort = false;
walk_path(main_dir,
[&](CSlice name, WalkPath::Type type) {
walk_path(main_dir, [&](CSlice name, WalkPath::Type type) {
CHECK(!was_abort);
if (type == WalkPath::Type::EnterDir && ends_with(name, PSLICE() << TD_DIR_SLASH << "B")) {
was_abort = true;
return WalkPath::Action::Abort;
}
return WalkPath::Action::Continue;
})
.ensure();
}).ensure();
CHECK(was_abort);
cnt = 0;
bool is_first_dir = true;
walk_path(main_dir,
[&](CSlice name, WalkPath::Type type) {
walk_path(main_dir, [&](CSlice name, WalkPath::Type type) {
cnt++;
if (type == WalkPath::Type::EnterDir) {
if (is_first_dir) {
@ -77,8 +72,7 @@ TEST(Port, files) {
}
}
return WalkPath::Action::Continue;
})
.ensure();
}).ensure();
ASSERT_EQ(6, cnt);
ASSERT_EQ(0u, fd.get_size().move_as_ok());

View File

@ -47,11 +47,17 @@ TEST(DB, binlog_encryption_bug) {
auto empty = DbKey::empty();
{
Binlog binlog;
binlog.init(binlog_name.str(), [&](const BinlogEvent &x) {}, cucumber).ensure();
binlog
.init(
binlog_name.str(), [&](const BinlogEvent &x) {}, cucumber)
.ensure();
}
{
Binlog binlog;
binlog.init(binlog_name.str(), [&](const BinlogEvent &x) {}, cucumber).ensure();
binlog
.init(
binlog_name.str(), [&](const BinlogEvent &x) {}, cucumber)
.ensure();
}
}
@ -92,7 +98,10 @@ TEST(DB, binlog_encryption) {
std::vector<string> v;
LOG(INFO) << "RESTART";
Binlog binlog;
binlog.init(binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, hello).ensure();
binlog
.init(
binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, hello)
.ensure();
CHECK(v == std::vector<string>({"AAAA", "BBBB", long_data, "CCCC"}));
}
@ -102,7 +111,8 @@ TEST(DB, binlog_encryption) {
std::vector<string> v;
LOG(INFO) << "RESTART";
Binlog binlog;
auto status = binlog.init(binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, cucumber);
auto status = binlog.init(
binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, cucumber);
CHECK(status.is_error());
}
@ -112,8 +122,8 @@ TEST(DB, binlog_encryption) {
std::vector<string> v;
LOG(INFO) << "RESTART";
Binlog binlog;
auto status =
binlog.init(binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, cucumber, hello);
auto status = binlog.init(
binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, cucumber, hello);
CHECK(v == std::vector<string>({"AAAA", "BBBB", long_data, "CCCC"}));
}
};