Merge branch 'refactor/format_cxx' into 'master'

refactor(cxx): formatted according to IDF astyle rules

See merge request espressif/esp-idf!29417
This commit is contained in:
Jakob Hasse
2024-03-06 17:45:57 +08:00
10 changed files with 90 additions and 103 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -60,7 +60,6 @@ extern "C" void __wrap___register_frame_info_table (void *begin, struct object *
abort();
}
extern "C" void __wrap___register_frame(void *begin)
__attribute__((alias("abort_expect_void")));
@@ -152,7 +151,6 @@ extern "C" void __wrap__Unwind_DeleteException (struct _Unwind_Exception *exc)
abort();
}
extern "C" _Unwind_Reason_Code __wrap__Unwind_RaiseException(struct _Unwind_Exception *exc)
{
return abort_return<_Unwind_Reason_Code>();

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -171,12 +171,9 @@ TEST_CASE("c++ exceptions emergency pool", "[cxx] [exceptions]")
void **p, **pprev = NULL;
int thrown_value = 0;
// throw first exception to ensure that all initial allocations are made
try
{
try {
throw 33;
}
catch (int e)
{
} catch (int e) {
thrown_value = e;
}
TEST_ASSERT_EQUAL(33, thrown_value);
@@ -189,12 +186,9 @@ TEST_CASE("c++ exceptions emergency pool", "[cxx] [exceptions]")
}
pprev = p;
}
try
{
try {
throw 20;
}
catch (int e)
{
} catch (int e) {
thrown_value = e;
}
#if CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE > 0

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -28,8 +28,7 @@ extern "C" void tearDown()
static const char* TAG = "cxx";
class NonPOD
{
class NonPOD {
public:
NonPOD(int a_) : a(a_) { }
int a;
@@ -60,10 +59,10 @@ TEST_CASE("can use static initializers for non-POD types", "[restart_init]")
static SemaphoreHandle_t s_slow_init_sem = NULL;
template<int obj>
class SlowInit
{
class SlowInit {
public:
SlowInit(int arg) {
SlowInit(int arg)
{
ESP_LOGD(TAG, "init obj=%d start, arg=%d", obj, arg);
vTaskDelay(300 / portTICK_PERIOD_MS);
TEST_ASSERT_EQUAL(-1, mInitBy);
@@ -73,7 +72,8 @@ public:
ESP_LOGD(TAG, "init obj=%d done", obj);
}
static void task(void* arg) {
static void task(void* arg)
{
int taskId = reinterpret_cast<int>(arg);
ESP_LOGD(TAG, "obj=%d before static init, task=%d", obj, taskId);
static SlowInit slowinit(taskId);
@@ -129,9 +129,9 @@ TEST_CASE("static initialization guards work as expected", "[misc]")
vTaskDelay(10); // Allow tasks to clean up, avoids race with leak detector
}
struct GlobalInitTest
struct GlobalInitTest {
GlobalInitTest() : index(order++)
{
GlobalInitTest() : index(order++) {
}
int index;
static int order;
@@ -150,8 +150,7 @@ TEST_CASE("global initializers run in the correct order", "[misc]")
TEST_ASSERT_EQUAL(2, g_init_test3.index);
}
struct StaticInitTestBeforeScheduler
{
struct StaticInitTestBeforeScheduler {
StaticInitTestBeforeScheduler()
{
static int first_init_order = getOrder();
@@ -181,8 +180,7 @@ TEST_CASE("before scheduler has started, static initializers work correctly", "[
TEST_ASSERT_EQUAL(2, StaticInitTestBeforeScheduler::order);
}
struct PriorityInitTest
{
struct PriorityInitTest {
PriorityInitTest()
{
index = getOrder();
@@ -220,15 +218,13 @@ TEST_CASE("can use new and delete", "[misc]")
delete[] int_array;
}
class Base
{
class Base {
public:
virtual ~Base() = default;
virtual void foo() = 0;
};
class Derived : public Base
{
class Derived : public Base {
public:
virtual void foo() { }
};

View File

@@ -14,8 +14,7 @@ using std::endl;
using std::runtime_error;
/* A simple class which may throw an exception from constructor */
class Throwing
{
class Throwing {
public:
Throwing(int arg)
: m_arg(arg)

View File

@@ -20,8 +20,7 @@
using namespace std::chrono;
const auto sleep_time = seconds
{
const auto sleep_time = seconds {
5
};

View File

@@ -25,24 +25,27 @@ class DerivedB;
static string demangle(const char* name);
class Base
{
class Base {
public:
virtual ~Base() {} ;
virtual string name() = 0;
static shared_ptr<Base> make_random_derived();
};
class DerivedA : public Base
{
class DerivedA : public Base {
public:
string name() override { return "DerivedA"; }
string name() override
{
return "DerivedA";
}
};
class DerivedB : public Base
{
class DerivedB : public Base {
public:
string name() override { return "DerivedB"; }
string name() override
{
return "DerivedB";
}
};
/* Creates either DerivedA or DerivedB, depending on a random number */

View File

@@ -50,7 +50,6 @@ components_not_formatted_temporary:
- "/components/bt/"
- "/components/cmock/"
- "/components/console/"
- "/components/cxx/"
- "/components/efuse/"
- "/components/esp_coex/"
- "/components/esp_eth/"
@@ -102,7 +101,6 @@ components_not_formatted_temporary:
- "/examples/build_system/"
- "/examples/common_components/"
- "/examples/custom_bootloader/"
- "/examples/cxx/"
- "/examples/ethernet/"
- "/examples/get-started/"
- "/examples/mesh/"