Skip to content

Commit

Permalink
Insert Braces around single line ifs. (#1077)
Browse files Browse the repository at this point in the history
Add the `InsertBraces: true` flag for clang-format and re-run the
formatter. This forces brackets around all of the single line entries
which did not previously have them.
  • Loading branch information
dj2 authored Jan 9, 2025
1 parent ffc084a commit a3fa7cc
Show file tree
Hide file tree
Showing 72 changed files with 3,693 additions and 2,059 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
BasedOnStyle: Chromium

InsertBraces: true
2 changes: 1 addition & 1 deletion include/amber/amber.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Delegate {
std::vector<char>* buffer) const = 0;

/// Mechanism for gathering timing from 'TIME_EXECUTION'
virtual void ReportExecutionTiming(double){}
virtual void ReportExecutionTiming(double) {}
};

/// Stores configuration options for Amber.
Expand Down
33 changes: 22 additions & 11 deletions samples/amber.cc
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,9 @@ class SampleDelegate : public amber::Delegate {
#endif // AMBER_ENABLE_LODEPNG
} else {
auto data = ReadFile(path_ + file_name);
if (data.empty())
if (data.empty()) {
return amber::Result("Failed to load buffer data " + file_name);
}

for (auto d : data) {
amber::Value v;
Expand All @@ -413,8 +414,9 @@ class SampleDelegate : public amber::Delegate {
amber::Result LoadFile(const std::string file_name,
std::vector<char>* buffer) const override {
*buffer = ReadFile(path_ + file_name);
if (buffer->empty())
if (buffer->empty()) {
return amber::Result("Failed to load file " + file_name);
}
return {};
}

Expand All @@ -433,8 +435,9 @@ std::string disassemble(const std::string& env,

spv_target_env target_env = SPV_ENV_UNIVERSAL_1_0;
if (!env.empty()) {
if (!spvParseTargetEnv(env.c_str(), &target_env))
if (!spvParseTargetEnv(env.c_str(), &target_env)) {
return "";
}
}

auto msg_consumer = [&spv_errors](spv_message_level_t level, const char*,
Expand Down Expand Up @@ -539,8 +542,9 @@ int main(int argc, const char** argv) {
continue;
}

if (options.fence_timeout > -1)
if (options.fence_timeout > -1) {
recipe->SetFenceTimeout(static_cast<uint32_t>(options.fence_timeout));
}

recipe->SetPipelineRuntimeLayerEnabled(
options.enable_pipeline_runtime_layer);
Expand All @@ -550,15 +554,19 @@ int main(int argc, const char** argv) {
recipe_data.back().recipe = std::move(recipe);
}

if (options.parse_only)
if (options.parse_only) {
return 0;
}

if (options.log_graphics_calls)
if (options.log_graphics_calls) {
delegate.SetLogGraphicsCalls(true);
if (options.log_graphics_calls_time)
}
if (options.log_graphics_calls_time) {
delegate.SetLogGraphicsCallsTime(true);
if (options.log_execute_calls)
}
if (options.log_execute_calls) {
delegate.SetLogExecuteCalls(true);
}

amber::Options amber_options;
amber_options.engine = options.engine;
Expand Down Expand Up @@ -628,8 +636,9 @@ int main(int argc, const char** argv) {
}

// Use default frame buffer name when not specified.
while (options.image_filenames.size() > options.fb_names.size())
while (options.image_filenames.size() > options.fb_names.size()) {
options.fb_names.push_back(kGeneratedColorBuffer);
}

for (const auto& fb_name : options.fb_names) {
amber::BufferInfo buffer_info;
Expand Down Expand Up @@ -773,8 +782,9 @@ int main(int argc, const char** argv) {
for (size_t i = 0; i < values.size(); ++i) {
buffer_file << " " << std::setfill('0') << std::setw(2) << std::hex
<< values[i].AsUint32();
if (i % 16 == 15)
if (i % 16 == 15) {
buffer_file << std::endl;
}
}
buffer_file << std::endl;
}
Expand All @@ -787,8 +797,9 @@ int main(int argc, const char** argv) {
if (!failures.empty()) {
std::cout << "\nSummary of Failures:" << std::endl;

for (const auto& failure : failures)
for (const auto& failure : failures) {
std::cout << " " << failure << std::endl;
}
}

std::cout << "\nSummary: "
Expand Down
3 changes: 2 additions & 1 deletion samples/android_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ extern "C" JNIEXPORT JNICALL int Java_com_google_amber_Amber_androidHelper(

std::vector<const char*> argv;

for (const std::string& arg : argv_string)
for (const std::string& arg : argv_string) {
argv.push_back(arg.c_str());
}

return android_main(static_cast<int>(argv.size()), argv.data());
}
Expand Down
3 changes: 2 additions & 1 deletion samples/config_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ amber::Result ConfigHelper::CreateConfig(
#endif // AMBER_ENGINE_DAWN
}

if (!impl_)
if (!impl_) {
return amber::Result("Unable to create config helper");
}

return impl_->CreateConfig(
engine_major, engine_minor, selected_device, required_features,
Expand Down
3 changes: 2 additions & 1 deletion samples/config_helper_dawn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ amber::Result ConfigHelperDawn::CreateConfig(
}
}

if (!dawn_device_)
if (!dawn_device_) {
return amber::Result("could not find Vulkan or Metal backend for Dawn");
}

backendProcs.deviceSetUncapturedErrorCallback(dawn_device_.Get(),
PrintDeviceError, nullptr);
Expand Down
Loading

0 comments on commit a3fa7cc

Please sign in to comment.