Skip to content

Commit 0b6c1d2

Browse files
committed
Update clag-format to the latest (190926/r372920) version.
GitOrigin-RevId: 7861ae8ad28eb1f6a06ff3c6f56eff3f67b1d24c
1 parent c7811a0 commit 0b6c1d2

23 files changed

+199
-163
lines changed

‎.clang-format

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ Language: Cpp
33
# BasedOnStyle: Google
44
AccessModifierOffset: -1
55
AlignAfterOpenBracket: Align
6+
AlignConsecutiveMacros: false
67
AlignConsecutiveAssignments: false
78
AlignConsecutiveDeclarations: false
89
AlignEscapedNewlines: Left
910
AlignOperands: true
1011
AlignTrailingComments: true
12+
AllowAllArgumentsOnNextLine: true
13+
AllowAllConstructorInitializersOnNextLine: true
1114
AllowAllParametersOfDeclarationOnNextLine: true
12-
AllowShortBlocksOnASingleLine: false
15+
AllowShortBlocksOnASingleLine: Never
1316
AllowShortCaseLabelsOnASingleLine: false
1417
AllowShortFunctionsOnASingleLine: None # All
15-
AllowShortIfStatementsOnASingleLine: false # true
18+
AllowShortIfStatementsOnASingleLine: Never # WithoutElse
19+
AllowShortLambdasOnASingleLine: Inline # All
1620
AllowShortLoopsOnASingleLine: false # true
1721
AlwaysBreakAfterDefinitionReturnType: None
1822
AlwaysBreakAfterReturnType: None
@@ -21,6 +25,7 @@ AlwaysBreakTemplateDeclarations: Yes
2125
BinPackArguments: true
2226
BinPackParameters: true
2327
BraceWrapping:
28+
AfterCaseLabel: false
2429
AfterClass: false
2530
AfterControlStatement: false
2631
AfterEnum: false
@@ -60,6 +65,7 @@ ForEachMacros:
6065
- Q_FOREACH_THIS_LIST_MUST_BE_NON_EMPTY
6166
IncludeBlocks: Preserve
6267
IndentCaseLabels: true
68+
IndentGotoLabels: true
6369
IndentPPDirectives: None
6470
IndentWidth: 2
6571
IndentWrappedFunctionNames: false
@@ -87,13 +93,15 @@ ReflowComments: false # true
8793
SortIncludes: false # disabled, because we need case insensitive sort
8894
SortUsingDeclarations: false # true
8995
SpaceAfterCStyleCast: false
96+
SpaceAfterLogicalNot: false
9097
SpaceAfterTemplateKeyword: true
9198
SpaceBeforeAssignmentOperators: true
9299
SpaceBeforeCpp11BracedList: false
93100
SpaceBeforeCtorInitializerColon: true
94101
SpaceBeforeInheritanceColon: true
95102
SpaceBeforeParens: ControlStatements
96103
SpaceBeforeRangeBasedForLoopColon: true
104+
SpaceInEmptyBlock: false
97105
SpaceInEmptyParentheses: false
98106
SpacesBeforeTrailingComments: 2
99107
SpacesInAngles: false

‎benchmark/bench_misc.cpp

+21-27
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,13 @@ class CreateFileBench : public Benchmark {
222222
}
223223
}
224224
void tear_down() override {
225-
td::walk_path("A/",
226-
[&](CSlice path, auto type) {
227-
if (type == td::WalkPath::Type::ExitDir) {
228-
rmdir(path).ignore();
229-
} else if (type == td::WalkPath::Type::NotDir) {
230-
unlink(path).ignore();
231-
}
232-
})
233-
.ignore();
225+
td::walk_path("A/", [&](CSlice path, auto type) {
226+
if (type == td::WalkPath::Type::ExitDir) {
227+
rmdir(path).ignore();
228+
} else if (type == td::WalkPath::Type::NotDir) {
229+
unlink(path).ignore();
230+
}
231+
}).ignore();
234232
}
235233
};
236234

@@ -246,26 +244,22 @@ class WalkPathBench : public Benchmark {
246244
}
247245
void run(int n) override {
248246
int cnt = 0;
249-
td::walk_path("A/",
250-
[&](CSlice path, auto type) {
251-
if (type == td::WalkPath::Type::EnterDir) {
252-
return;
253-
}
254-
stat(path).ok();
255-
cnt++;
256-
})
257-
.ignore();
247+
td::walk_path("A/", [&](CSlice path, auto type) {
248+
if (type == td::WalkPath::Type::EnterDir) {
249+
return;
250+
}
251+
stat(path).ok();
252+
cnt++;
253+
}).ignore();
258254
}
259255
void tear_down() override {
260-
td::walk_path("A/",
261-
[&](CSlice path, auto type) {
262-
if (type == td::WalkPath::Type::ExitDir) {
263-
rmdir(path).ignore();
264-
} else if (type == td::WalkPath::Type::NotDir) {
265-
unlink(path).ignore();
266-
}
267-
})
268-
.ignore();
256+
td::walk_path("A/", [&](CSlice path, auto type) {
257+
if (type == td::WalkPath::Type::ExitDir) {
258+
rmdir(path).ignore();
259+
} else if (type == td::WalkPath::Type::NotDir) {
260+
unlink(path).ignore();
261+
}
262+
}).ignore();
269263
}
270264
};
271265

‎benchmark/check_tls.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ td::Result<TlsInfo> test_tls(const td::string &url) {
5353

5454
td::string request;
5555

56-
auto add_string = [&](td::Slice data) { request.append(data.data(), data.size()); };
56+
auto add_string = [&](td::Slice data) {
57+
request.append(data.data(), data.size());
58+
};
5759
auto add_random = [&](size_t length) {
5860
while (length-- > 0) {
5961
request += static_cast<char>(td::Random::secure_int32());

‎memprof/memprof.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ extern void *__libc_stack_end;
4141
static void *get_bp() {
4242
void *bp;
4343
#if defined(__i386__)
44-
__asm__ volatile("movl %%ebp, %[r]" : [r] "=r"(bp));
44+
__asm__ volatile("movl %%ebp, %[r]" : [ r ] "=r"(bp));
4545
#elif defined(__x86_64__)
46-
__asm__ volatile("movq %%rbp, %[r]" : [r] "=r"(bp));
46+
__asm__ volatile("movq %%rbp, %[r]" : [ r ] "=r"(bp));
4747
#endif
4848
return bp;
4949
}

‎td/mtproto/SessionConnection.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ class SessionConnection
202202
auto set_buffer_slice(BufferSlice *buffer_slice) TD_WARN_UNUSED_RESULT {
203203
auto old_buffer_slice = current_buffer_slice_;
204204
current_buffer_slice_ = buffer_slice;
205-
return ScopeExit() + [&to = current_buffer_slice_, from = old_buffer_slice] { to = from; };
205+
return ScopeExit() + [&to = current_buffer_slice_, from = old_buffer_slice] {
206+
to = from;
207+
};
206208
}
207209

208210
Status parse_message(TlParser &parser, MsgInfo *info, Slice *packet, bool crypto_flag = true) TD_WARN_UNUSED_RESULT;

‎td/telegram/ConfigManager.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,9 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
987987
shared_config.set_option_string("photo_search_bot_username", config->img_search_username_);
988988
}
989989

990-
auto fix_timeout_ms = [](int32 timeout_ms) { return clamp(timeout_ms, 1000, 86400 * 1000); };
990+
auto fix_timeout_ms = [](int32 timeout_ms) {
991+
return clamp(timeout_ms, 1000, 86400 * 1000);
992+
};
991993

992994
shared_config.set_option_integer("online_update_period_ms", fix_timeout_ms(config->online_update_period_ms_));
993995

‎td/telegram/MessagesManager.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -27065,13 +27065,17 @@ void MessagesManager::suffix_load_add_query(Dialog *d,
2706527065

2706627066
void MessagesManager::suffix_load_till_date(Dialog *d, int32 date, Promise<> promise) {
2706727067
LOG(INFO) << "Load suffix of " << d->dialog_id << " till date " << date;
27068-
auto condition = [date](const Message *m) { return m != nullptr && m->date < date; };
27068+
auto condition = [date](const Message *m) {
27069+
return m != nullptr && m->date < date;
27070+
};
2706927071
suffix_load_add_query(d, std::make_pair(std::move(promise), std::move(condition)));
2707027072
}
2707127073

2707227074
void MessagesManager::suffix_load_till_message_id(Dialog *d, MessageId message_id, Promise<> promise) {
2707327075
LOG(INFO) << "Load suffix of " << d->dialog_id << " till " << message_id;
27074-
auto condition = [message_id](const Message *m) { return m != nullptr && m->message_id.get() < message_id.get(); };
27076+
auto condition = [message_id](const Message *m) {
27077+
return m != nullptr && m->message_id.get() < message_id.get();
27078+
};
2707527079
suffix_load_add_query(d, std::make_pair(std::move(promise), std::move(condition)));
2707627080
}
2707727081

‎td/telegram/SecretChatActor.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,9 @@ void SecretChatActor::on_outbound_send_message_result(NetQueryPtr query, Promise
16621662
[&](telegram_api::encryptedFileEmpty &) {
16631663
state->message->file = logevent::EncryptedInputFile::from_input_encrypted_file(
16641664
telegram_api::inputEncryptedFileEmpty());
1665-
get_file = [] { return telegram_api::make_object<telegram_api::encryptedFileEmpty>(); };
1665+
get_file = [] {
1666+
return telegram_api::make_object<telegram_api::encryptedFileEmpty>();
1667+
};
16661668
},
16671669
[&](telegram_api::encryptedFile &file) {
16681670
state->message->file = logevent::EncryptedInputFile::from_input_encrypted_file(

‎td/telegram/UpdatesManager.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,9 @@ int32 UpdatesManager::get_short_update_date() const {
15511551

15521552
tl_object_ptr<td_api::ChatAction> UpdatesManager::convert_send_message_action(
15531553
tl_object_ptr<telegram_api::SendMessageAction> action) {
1554-
auto fix_progress = [](int32 progress) { return progress <= 0 || progress > 100 ? 0 : progress; };
1554+
auto fix_progress = [](int32 progress) {
1555+
return progress <= 0 || progress > 100 ? 0 : progress;
1556+
};
15551557

15561558
switch (action->get_id()) {
15571559
case telegram_api::sendMessageCancelAction::ID:

‎td/telegram/files/FileStatsWorker.cpp

+27-29
Original file line numberDiff line numberDiff line change
@@ -106,35 +106,33 @@ void scan_fs(CancellationToken &token, CallbackT &&callback) {
106106
continue;
107107
}
108108
auto files_dir = get_files_dir(file_type);
109-
walk_path(files_dir,
110-
[&](CSlice path, WalkPath::Type type) {
111-
if (token) {
112-
return WalkPath::Action::Abort;
113-
}
114-
if (type != WalkPath::Type::NotDir) {
115-
return WalkPath::Action::Continue;
116-
}
117-
auto r_stat = stat(path);
118-
if (r_stat.is_error()) {
119-
LOG(WARNING) << "Stat in files gc failed: " << r_stat.error();
120-
return WalkPath::Action::Continue;
121-
}
122-
auto stat = r_stat.move_as_ok();
123-
if (ends_with(path, "/.nomedia") && stat.size_ == 0) {
124-
// skip .nomedia file
125-
return WalkPath::Action::Continue;
126-
}
127-
128-
FsFileInfo info;
129-
info.path = path.str();
130-
info.size = stat.size_;
131-
info.file_type = file_type;
132-
info.atime_nsec = stat.atime_nsec_;
133-
info.mtime_nsec = stat.mtime_nsec_;
134-
callback(info);
135-
return WalkPath::Action::Continue;
136-
})
137-
.ignore();
109+
walk_path(files_dir, [&](CSlice path, WalkPath::Type type) {
110+
if (token) {
111+
return WalkPath::Action::Abort;
112+
}
113+
if (type != WalkPath::Type::NotDir) {
114+
return WalkPath::Action::Continue;
115+
}
116+
auto r_stat = stat(path);
117+
if (r_stat.is_error()) {
118+
LOG(WARNING) << "Stat in files gc failed: " << r_stat.error();
119+
return WalkPath::Action::Continue;
120+
}
121+
auto stat = r_stat.move_as_ok();
122+
if (ends_with(path, "/.nomedia") && stat.size_ == 0) {
123+
// skip .nomedia file
124+
return WalkPath::Action::Continue;
125+
}
126+
127+
FsFileInfo info;
128+
info.path = path.str();
129+
info.size = stat.size_;
130+
info.file_type = file_type;
131+
info.atime_nsec = stat.atime_nsec_;
132+
info.mtime_nsec = stat.mtime_nsec_;
133+
callback(info);
134+
return WalkPath::Action::Continue;
135+
}).ignore();
138136
}
139137
}
140138
} // namespace

‎td/telegram/files/PartsManager.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ bool PartsManager::is_part_in_streaming_limit(int part_i) const {
228228
return true;
229229
}
230230

231-
auto is_intersect_with = [&](int64 begin, int64 end) { return max(begin, offset_begin) < min(end, offset_end); };
231+
auto is_intersect_with = [&](int64 begin, int64 end) {
232+
return max(begin, offset_begin) < min(end, offset_end);
233+
};
232234

233235
auto streaming_begin = streaming_offset_;
234236
auto streaming_end = streaming_offset_ + streaming_limit_;

‎td/telegram/net/DcOptionsSet.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,9 @@ Result<DcOptionsSet::ConnectionInfo> DcOptionsSet::find_connection(DcId dc_id, b
135135
<< tag("prefer_ipv6", prefer_ipv6));
136136
}
137137

138-
auto last_error_at = std::min_element(options.begin(), options.end(),
139-
[](const auto &a_option, const auto &b_option) {
140-
return a_option.stat->error_at > b_option.stat->error_at;
141-
})
142-
->stat->error_at;
138+
auto last_error_at = std::min_element(options.begin(), options.end(), [](const auto &a_option, const auto &b_option) {
139+
return a_option.stat->error_at > b_option.stat->error_at;
140+
})->stat->error_at;
143141

144142
auto result = *std::min_element(options.begin(), options.end(), [](const auto &a_option, const auto &b_option) {
145143
auto &a = *a_option.stat;

‎tdactor/td/actor/impl/Scheduler.h

+25-22
Original file line numberDiff line numberDiff line change
@@ -229,37 +229,40 @@ void Scheduler::send_impl(const ActorId<> &actor_id, const RunFuncT &run_func, c
229229

230230
template <ActorSendType send_type, class EventT>
231231
void Scheduler::send_lambda(ActorRef actor_ref, EventT &&lambda) {
232-
return send_impl<send_type>(actor_ref.get(),
233-
[&](ActorInfo *actor_info) {
234-
event_context_ptr_->link_token = actor_ref.token();
235-
lambda();
236-
},
237-
[&]() {
238-
auto event = Event::lambda(std::forward<EventT>(lambda));
239-
event.set_link_token(actor_ref.token());
240-
return event;
241-
});
232+
return send_impl<send_type>(
233+
actor_ref.get(),
234+
[&](ActorInfo *actor_info) {
235+
event_context_ptr_->link_token = actor_ref.token();
236+
lambda();
237+
},
238+
[&]() {
239+
auto event = Event::lambda(std::forward<EventT>(lambda));
240+
event.set_link_token(actor_ref.token());
241+
return event;
242+
});
242243
}
243244

244245
template <ActorSendType send_type, class EventT>
245246
void Scheduler::send_closure(ActorRef actor_ref, EventT &&closure) {
246-
return send_impl<send_type>(actor_ref.get(),
247-
[&](ActorInfo *actor_info) {
248-
event_context_ptr_->link_token = actor_ref.token();
249-
closure.run(static_cast<typename EventT::ActorType *>(actor_info->get_actor_unsafe()));
250-
},
251-
[&]() {
252-
auto event = Event::immediate_closure(std::forward<EventT>(closure));
253-
event.set_link_token(actor_ref.token());
254-
return event;
255-
});
247+
return send_impl<send_type>(
248+
actor_ref.get(),
249+
[&](ActorInfo *actor_info) {
250+
event_context_ptr_->link_token = actor_ref.token();
251+
closure.run(static_cast<typename EventT::ActorType *>(actor_info->get_actor_unsafe()));
252+
},
253+
[&]() {
254+
auto event = Event::immediate_closure(std::forward<EventT>(closure));
255+
event.set_link_token(actor_ref.token());
256+
return event;
257+
});
256258
}
257259

258260
template <ActorSendType send_type>
259261
void Scheduler::send(ActorRef actor_ref, Event &&event) {
260262
event.set_link_token(actor_ref.token());
261-
return send_impl<send_type>(actor_ref.get(), [&](ActorInfo *actor_info) { do_event(actor_info, std::move(event)); },
262-
[&]() { return std::move(event); });
263+
return send_impl<send_type>(
264+
actor_ref.get(), [&](ActorInfo *actor_info) { do_event(actor_info, std::move(event)); },
265+
[&]() { return std::move(event); });
263266
}
264267

265268
inline void Scheduler::subscribe(PollableFd fd, PollFlags flags) {

‎tddb/td/db/BinlogKeyValue.h

+8-7
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,14 @@ class BinlogKeyValue : public KeyValueSyncInterface {
7777
}
7878

7979
binlog_ = std::make_shared<BinlogT>();
80-
TRY_STATUS(binlog_->init(name,
81-
[&](const BinlogEvent &binlog_event) {
82-
Event event;
83-
event.parse(TlParser(binlog_event.data_));
84-
map_.emplace(event.key.str(), std::make_pair(event.value.str(), binlog_event.id_));
85-
},
86-
std::move(db_key), DbKey::empty(), scheduler_id));
80+
TRY_STATUS(binlog_->init(
81+
name,
82+
[&](const BinlogEvent &binlog_event) {
83+
Event event;
84+
event.parse(TlParser(binlog_event.data_));
85+
map_.emplace(event.key.str(), std::make_pair(event.value.str(), binlog_event.id_));
86+
},
87+
std::move(db_key), DbKey::empty(), scheduler_id));
8788
return Status::OK();
8889
}
8990

‎tddb/td/db/SqliteKeyValue.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ Result<bool> SqliteKeyValue::init(string path) {
2424
}
2525

2626
Status SqliteKeyValue::init_with_connection(SqliteDb connection, string table_name) {
27-
auto init_guard = ScopeExit() + [&]() { close(); };
27+
auto init_guard = ScopeExit() + [&]() {
28+
close();
29+
};
2830
db_ = std::move(connection);
2931
table_name_ = std::move(table_name);
3032
TRY_STATUS(init(db_, table_name_));

0 commit comments

Comments
 (0)