[Lint] Added InsertBraces to linter to unify codebase to one standard

This commit is contained in:
Gliniak
2026-05-08 18:47:25 +02:00
parent 2c68a2fc4b
commit 74f34818e7
39 changed files with 426 additions and 170 deletions

View File

@@ -22,7 +22,9 @@ namespace ppc {
void PadStringBuffer(StringBuffer* str, size_t base, size_t pad) {
size_t added_len = str->length() - base;
if (added_len < pad) str->AppendBytes(kSpaces, kNamePad - added_len);
if (added_len < pad) {
str->AppendBytes(kSpaces, kNamePad - added_len);
}
}
void PrintDisasm_bcx(const PPCDecodeData& d, StringBuffer* str) {
@@ -145,15 +147,23 @@ void PrintDisasm_bcx(const PPCDecodeData& d, StringBuffer* str) {
if (str_start == str->length()) {
// Default
str->Append("bc");
if (d.B.LK()) str->Append('l');
if (d.B.AA()) str->Append('a');
if (d.B.LK()) {
str->Append('l');
}
if (d.B.AA()) {
str->Append('a');
}
PadStringBuffer(str, str_start, kNamePad);
str->AppendFormat("{}", bo);
str->Append(", ");
str->AppendFormat("{}", bi);
} else {
if (d.B.LK()) str->Append('l');
if (d.B.AA()) str->Append('a');
if (d.B.LK()) {
str->Append('l');
}
if (d.B.AA()) {
str->Append('a');
}
if (sign_char > 0) {
str->Append('+');

View File

@@ -74,9 +74,13 @@ PPCTranslator::PPCTranslator(PPCFrontend* frontend) : frontend_(frontend) {
// Loops until no changes are made.
auto sap = std::make_unique<passes::ConditionalGroupPass>();
sap->AddPass(std::make_unique<passes::SimplificationPass>());
if (validate) sap->AddPass(std::make_unique<passes::ValidationPass>());
if (validate) {
sap->AddPass(std::make_unique<passes::ValidationPass>());
}
sap->AddPass(std::make_unique<passes::ConstantPropagationPass>());
if (validate) sap->AddPass(std::make_unique<passes::ValidationPass>());
if (validate) {
sap->AddPass(std::make_unique<passes::ValidationPass>());
}
compiler_->AddPass(std::move(sap));
if (backend->machine_info()->supports_extended_load_store) {
@@ -84,16 +88,21 @@ PPCTranslator::PPCTranslator(PPCFrontend* frontend) : frontend_(frontend) {
// These will save us a lot of HIR opcodes.
compiler_->AddPass(
std::make_unique<passes::MemorySequenceCombinationPass>());
if (validate)
if (validate) {
compiler_->AddPass(std::make_unique<passes::ValidationPass>());
}
}
compiler_->AddPass(std::make_unique<passes::SimplificationPass>());
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
if (validate) {
compiler_->AddPass(std::make_unique<passes::ValidationPass>());
}
// compiler_->AddPass(std::make_unique<passes::DeadStoreEliminationPass>());
// if (validate)
// compiler_->AddPass(std::make_unique<passes::ValidationPass>());
compiler_->AddPass(std::make_unique<passes::DeadCodeEliminationPass>());
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
if (validate) {
compiler_->AddPass(std::make_unique<passes::ValidationPass>());
}
//// Removes all unneeded variables. Try not to add new ones after this.
// compiler_->AddPass(new passes::ValueReductionPass());
@@ -105,7 +114,9 @@ PPCTranslator::PPCTranslator(PPCFrontend* frontend) : frontend_(frontend) {
// registers are assigned and ready to be emitted.
compiler_->AddPass(std::make_unique<passes::RegisterAllocationPass>(
backend->machine_info()));
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
if (validate) {
compiler_->AddPass(std::make_unique<passes::ValidationPass>());
}
// Must come last. The HIR is not really HIR after this.
compiler_->AddPass(std::make_unique<passes::FinalizationPass>());

View File

@@ -376,7 +376,9 @@ class TestRunner {
auto p = memory_->TranslateVirtual(address);
const char* c = bytes_str.c_str();
while (*c) {
while (*c == ' ') ++c;
while (*c == ' ') {
++c;
}
if (!*c) {
break;
}
@@ -425,7 +427,9 @@ class TestRunner {
StringBuffer expecteds;
StringBuffer actuals;
while (*c) {
while (*c == ' ') ++c;
while (*c == ' ') {
++c;
}
if (!*c) {
break;
}
@@ -728,7 +732,9 @@ bool RunTests(const std::vector<std::string>& test_names) {
suite_tests.push_back(&test_case);
}
}
if (suite_tests.empty()) continue;
if (suite_tests.empty()) {
continue;
}
++suite_index;
int pct =
@@ -753,7 +759,9 @@ bool RunTests(const std::vector<std::string>& test_names) {
// instance per thread (avoids shm name collisions between concurrent
// children).
unsigned int num_cores = std::thread::hardware_concurrency();
if (num_cores == 0) num_cores = 4;
if (num_cores == 0) {
num_cores = 4;
}
num_cores = std::max(1u, num_cores * 3 / 4);
fprintf(stderr, "Running tests in parallel using %u workers\n", num_cores);
@@ -795,7 +803,9 @@ bool RunTests(const std::vector<std::string>& test_names) {
while (true) {
size_t idx = test_index.fetch_add(1);
if (idx >= all_tests.size()) break;
if (idx >= all_tests.size()) {
break;
}
auto& [test_suite, test_case] = all_tests[idx];
int local_failed = 0;