Skip to content

Commit 38cec2d

Browse files
committed
Do not allow lambdas on a single line
1 parent 3caf593 commit 38cec2d

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ AllowShortCaseLabelsOnASingleLine: false
1313
AllowShortFunctionsOnASingleLine: false
1414
AllowShortIfStatementsOnASingleLine: false
1515
AllowShortLoopsOnASingleLine: false
16+
AllowShortLambdasOnASingleLine: None
1617
AlwaysBreakAfterDefinitionReturnType: None
1718
AlwaysBreakAfterReturnType: None
1819
AlwaysBreakBeforeMultilineStrings: false

src/cmake_generator.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,15 @@ struct Generator {
558558
}
559559

560560
void conditional_includes(const parser::ConditionVector &include) {
561-
handle_condition(include, [this](const std::string &, const std::vector<std::string> &includes) { inject_includes(includes); });
561+
handle_condition(include, [this](const std::string &, const std::vector<std::string> &includes) {
562+
inject_includes(includes);
563+
});
562564
}
563565

564566
void conditional_cmake(const parser::Condition<std::string> &cmake) {
565-
handle_condition(cmake, [this](const std::string &, const std::string &cmake) { inject_cmake(cmake); });
567+
handle_condition(cmake, [this](const std::string &, const std::string &cmake) {
568+
inject_cmake(cmake);
569+
});
566570
}
567571

568572
bool if_condition(const std::string &condition) {
@@ -719,9 +723,15 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
719723

720724
// Helper lambdas for more convenient CMake generation
721725
auto &ss = gen.ss;
722-
auto cmd = [&gen](const std::string &command) { return gen.cmd(command); };
723-
auto comment = [&gen](const std::string &comment) { return gen.comment(comment); };
724-
auto endl = [&gen]() { gen.endl(); };
726+
auto cmd = [&gen](const std::string &command) {
727+
return gen.cmd(command);
728+
};
729+
auto comment = [&gen](const std::string &comment) {
730+
return gen.comment(comment);
731+
};
732+
auto endl = [&gen]() {
733+
gen.endl();
734+
};
725735

726736
std::string cmkr_url = "https://github.com/build-cpp/cmkr";
727737
comment("This file is automatically generated from cmake.toml - DO NOT EDIT");
@@ -1145,7 +1155,9 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
11451155
for (size_t i = 0; i < project.targets.size(); i++) {
11461156
const auto &target = project.targets[i];
11471157

1148-
auto throw_target_error = [&target](const std::string &message) { throw std::runtime_error("[target." + target.name + "] " + message); };
1158+
auto throw_target_error = [&target](const std::string &message) {
1159+
throw std::runtime_error("[target." + target.name + "] " + message);
1160+
};
11491161

11501162
const parser::Template *tmplate = nullptr;
11511163
std::unique_ptr<ConditionScope> tmplate_cs{};
@@ -1384,8 +1396,9 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
13841396
}
13851397

13861398
auto target_cmd = [&](const char *command, const parser::ConditionVector &cargs, const std::string &scope) {
1387-
gen.handle_condition(cargs,
1388-
[&](const std::string &, const std::vector<std::string> &args) { cmd(command)(target.name, scope, args); });
1399+
gen.handle_condition(cargs, [&](const std::string &, const std::vector<std::string> &args) {
1400+
cmd(command)(target.name, scope, args);
1401+
});
13891402
};
13901403

13911404
auto gen_target_cmds = [&](const parser::Target &t) {

0 commit comments

Comments
 (0)