forked from espressif/esp-idf
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:
@@ -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
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -60,7 +60,6 @@ extern "C" void __wrap___register_frame_info_table (void *begin, struct object *
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" void __wrap___register_frame(void *begin)
|
extern "C" void __wrap___register_frame(void *begin)
|
||||||
__attribute__((alias("abort_expect_void")));
|
__attribute__((alias("abort_expect_void")));
|
||||||
|
|
||||||
@@ -152,7 +151,6 @@ extern "C" void __wrap__Unwind_DeleteException (struct _Unwind_Exception *exc)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" _Unwind_Reason_Code __wrap__Unwind_RaiseException(struct _Unwind_Exception *exc)
|
extern "C" _Unwind_Reason_Code __wrap__Unwind_RaiseException(struct _Unwind_Exception *exc)
|
||||||
{
|
{
|
||||||
return abort_return<_Unwind_Reason_Code>();
|
return abort_return<_Unwind_Reason_Code>();
|
||||||
|
@@ -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
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -171,12 +171,9 @@ TEST_CASE("c++ exceptions emergency pool", "[cxx] [exceptions]")
|
|||||||
void **p, **pprev = NULL;
|
void **p, **pprev = NULL;
|
||||||
int thrown_value = 0;
|
int thrown_value = 0;
|
||||||
// throw first exception to ensure that all initial allocations are made
|
// throw first exception to ensure that all initial allocations are made
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
throw 33;
|
throw 33;
|
||||||
}
|
} catch (int e) {
|
||||||
catch (int e)
|
|
||||||
{
|
|
||||||
thrown_value = e;
|
thrown_value = e;
|
||||||
}
|
}
|
||||||
TEST_ASSERT_EQUAL(33, thrown_value);
|
TEST_ASSERT_EQUAL(33, thrown_value);
|
||||||
@@ -189,12 +186,9 @@ TEST_CASE("c++ exceptions emergency pool", "[cxx] [exceptions]")
|
|||||||
}
|
}
|
||||||
pprev = p;
|
pprev = p;
|
||||||
}
|
}
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
throw 20;
|
throw 20;
|
||||||
}
|
} catch (int e) {
|
||||||
catch (int e)
|
|
||||||
{
|
|
||||||
thrown_value = e;
|
thrown_value = e;
|
||||||
}
|
}
|
||||||
#if CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE > 0
|
#if CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE > 0
|
||||||
|
@@ -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
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -28,8 +28,7 @@ extern "C" void tearDown()
|
|||||||
|
|
||||||
static const char* TAG = "cxx";
|
static const char* TAG = "cxx";
|
||||||
|
|
||||||
class NonPOD
|
class NonPOD {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
NonPOD(int a_) : a(a_) { }
|
NonPOD(int a_) : a(a_) { }
|
||||||
int 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;
|
static SemaphoreHandle_t s_slow_init_sem = NULL;
|
||||||
|
|
||||||
template<int obj>
|
template<int obj>
|
||||||
class SlowInit
|
class SlowInit {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
SlowInit(int arg) {
|
SlowInit(int arg)
|
||||||
|
{
|
||||||
ESP_LOGD(TAG, "init obj=%d start, arg=%d", obj, arg);
|
ESP_LOGD(TAG, "init obj=%d start, arg=%d", obj, arg);
|
||||||
vTaskDelay(300 / portTICK_PERIOD_MS);
|
vTaskDelay(300 / portTICK_PERIOD_MS);
|
||||||
TEST_ASSERT_EQUAL(-1, mInitBy);
|
TEST_ASSERT_EQUAL(-1, mInitBy);
|
||||||
@@ -73,7 +72,8 @@ public:
|
|||||||
ESP_LOGD(TAG, "init obj=%d done", obj);
|
ESP_LOGD(TAG, "init obj=%d done", obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void task(void* arg) {
|
static void task(void* arg)
|
||||||
|
{
|
||||||
int taskId = reinterpret_cast<int>(arg);
|
int taskId = reinterpret_cast<int>(arg);
|
||||||
ESP_LOGD(TAG, "obj=%d before static init, task=%d", obj, taskId);
|
ESP_LOGD(TAG, "obj=%d before static init, task=%d", obj, taskId);
|
||||||
static SlowInit slowinit(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
|
vTaskDelay(10); // Allow tasks to clean up, avoids race with leak detector
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GlobalInitTest
|
struct GlobalInitTest {
|
||||||
|
GlobalInitTest() : index(order++)
|
||||||
{
|
{
|
||||||
GlobalInitTest() : index(order++) {
|
|
||||||
}
|
}
|
||||||
int index;
|
int index;
|
||||||
static int order;
|
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);
|
TEST_ASSERT_EQUAL(2, g_init_test3.index);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StaticInitTestBeforeScheduler
|
struct StaticInitTestBeforeScheduler {
|
||||||
{
|
|
||||||
StaticInitTestBeforeScheduler()
|
StaticInitTestBeforeScheduler()
|
||||||
{
|
{
|
||||||
static int first_init_order = getOrder();
|
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);
|
TEST_ASSERT_EQUAL(2, StaticInitTestBeforeScheduler::order);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PriorityInitTest
|
struct PriorityInitTest {
|
||||||
{
|
|
||||||
PriorityInitTest()
|
PriorityInitTest()
|
||||||
{
|
{
|
||||||
index = getOrder();
|
index = getOrder();
|
||||||
@@ -220,15 +218,13 @@ TEST_CASE("can use new and delete", "[misc]")
|
|||||||
delete[] int_array;
|
delete[] int_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Base
|
class Base {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
virtual ~Base() = default;
|
virtual ~Base() = default;
|
||||||
virtual void foo() = 0;
|
virtual void foo() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Derived : public Base
|
class Derived : public Base {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
virtual void foo() { }
|
virtual void foo() { }
|
||||||
};
|
};
|
||||||
|
@@ -14,8 +14,7 @@ using std::endl;
|
|||||||
using std::runtime_error;
|
using std::runtime_error;
|
||||||
|
|
||||||
/* A simple class which may throw an exception from constructor */
|
/* A simple class which may throw an exception from constructor */
|
||||||
class Throwing
|
class Throwing {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
Throwing(int arg)
|
Throwing(int arg)
|
||||||
: m_arg(arg)
|
: m_arg(arg)
|
||||||
|
@@ -20,8 +20,7 @@
|
|||||||
|
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
const auto sleep_time = seconds
|
const auto sleep_time = seconds {
|
||||||
{
|
|
||||||
5
|
5
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -25,24 +25,27 @@ class DerivedB;
|
|||||||
|
|
||||||
static string demangle(const char* name);
|
static string demangle(const char* name);
|
||||||
|
|
||||||
class Base
|
class Base {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
virtual ~Base() {} ;
|
virtual ~Base() {} ;
|
||||||
virtual string name() = 0;
|
virtual string name() = 0;
|
||||||
static shared_ptr<Base> make_random_derived();
|
static shared_ptr<Base> make_random_derived();
|
||||||
};
|
};
|
||||||
|
|
||||||
class DerivedA : public Base
|
class DerivedA : public Base {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
string name() override { return "DerivedA"; }
|
string name() override
|
||||||
|
{
|
||||||
|
return "DerivedA";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DerivedB : public Base
|
class DerivedB : public Base {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
string name() override { return "DerivedB"; }
|
string name() override
|
||||||
|
{
|
||||||
|
return "DerivedB";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Creates either DerivedA or DerivedB, depending on a random number */
|
/* Creates either DerivedA or DerivedB, depending on a random number */
|
||||||
|
@@ -50,7 +50,6 @@ components_not_formatted_temporary:
|
|||||||
- "/components/bt/"
|
- "/components/bt/"
|
||||||
- "/components/cmock/"
|
- "/components/cmock/"
|
||||||
- "/components/console/"
|
- "/components/console/"
|
||||||
- "/components/cxx/"
|
|
||||||
- "/components/efuse/"
|
- "/components/efuse/"
|
||||||
- "/components/esp_coex/"
|
- "/components/esp_coex/"
|
||||||
- "/components/esp_eth/"
|
- "/components/esp_eth/"
|
||||||
@@ -102,7 +101,6 @@ components_not_formatted_temporary:
|
|||||||
- "/examples/build_system/"
|
- "/examples/build_system/"
|
||||||
- "/examples/common_components/"
|
- "/examples/common_components/"
|
||||||
- "/examples/custom_bootloader/"
|
- "/examples/custom_bootloader/"
|
||||||
- "/examples/cxx/"
|
|
||||||
- "/examples/ethernet/"
|
- "/examples/ethernet/"
|
||||||
- "/examples/get-started/"
|
- "/examples/get-started/"
|
||||||
- "/examples/mesh/"
|
- "/examples/mesh/"
|
||||||
|
Reference in New Issue
Block a user