refactor(cxx): formatted according to IDF astyle rules

pull/13338/head
Jakob Hasse 2024-03-05 14:07:05 +08:00
rodzic 5f85aefe0d
commit 0c01c5965e
10 zmienionych plików z 90 dodań i 103 usunięć

Wyświetl plik

@ -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
*/
@ -40,45 +40,44 @@ extern "C" void __wrap__Unwind_SetEnableExceptionFdeSorting(unsigned char enable
abort();
}
extern "C" void __wrap___register_frame_info_bases (const void *begin, struct object *ob, void *tbase, void *dbase)
extern "C" void __wrap___register_frame_info_bases(const void *begin, struct object *ob, void *tbase, void *dbase)
{
abort();
}
extern "C" void __wrap___register_frame_info (const void *begin, struct object *ob)
extern "C" void __wrap___register_frame_info(const void *begin, struct object *ob)
{
abort();
}
extern "C" void __wrap___register_frame_info_table_bases (void *begin, struct object *ob, void *tbase, void *dbase)
extern "C" void __wrap___register_frame_info_table_bases(void *begin, struct object *ob, void *tbase, void *dbase)
{
abort();
}
extern "C" void __wrap___register_frame_info_table (void *begin, struct object *ob)
extern "C" void __wrap___register_frame_info_table(void *begin, struct object *ob)
{
abort();
}
extern "C" void __wrap___register_frame(void *begin)
__attribute__((alias("abort_expect_void")));
extern "C" void __wrap___register_frame (void *begin)
__attribute__((alias("abort_expect_void")));
extern "C" void __wrap___register_frame_table(void *begin)
__attribute__((alias("abort_expect_void")));
extern "C" void __wrap___register_frame_table (void *begin)
__attribute__((alias("abort_expect_void")));
extern "C" void *__wrap___deregister_frame_info_bases(const void *begin)
__attribute__((alias("abort_expect_void_and_return")));
extern "C" void *__wrap___deregister_frame_info_bases (const void *begin)
__attribute__((alias("abort_expect_void_and_return")));
extern "C" void *__wrap___deregister_frame_info(const void *begin)
__attribute__((alias("abort_expect_void_and_return")));
extern "C" void *__wrap___deregister_frame_info (const void *begin)
__attribute__((alias("abort_expect_void_and_return")));
extern "C" void __wrap___deregister_frame (void *begin)
__attribute__((alias("abort_expect_void")));
extern "C" void __wrap___deregister_frame(void *begin)
__attribute__((alias("abort_expect_void")));
typedef void* fde;
extern "C" const fde * __wrap__Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases)
extern "C" const fde * __wrap__Unwind_Find_FDE(void *pc, struct dwarf_eh_bases *bases)
{
return abort_return<fde*>();
}
@ -87,50 +86,50 @@ extern "C" const fde * __wrap__Unwind_Find_FDE (void *pc, struct dwarf_eh_bases
typedef void* _Unwind_Ptr;
typedef int _Unwind_Word;
extern "C" _Unwind_Word __wrap__Unwind_GetGR (struct _Unwind_Context *context, int index)
extern "C" _Unwind_Word __wrap__Unwind_GetGR(struct _Unwind_Context *context, int index)
{
return abort_return<_Unwind_Word>();
}
extern "C" _Unwind_Word __wrap__Unwind_GetCFA (struct _Unwind_Context *context)
extern "C" _Unwind_Word __wrap__Unwind_GetCFA(struct _Unwind_Context *context)
{
return abort_return<_Unwind_Word>();
}
extern "C" void __wrap__Unwind_SetIP (struct _Unwind_Context *context, _Unwind_Ptr val)
extern "C" void __wrap__Unwind_SetIP(struct _Unwind_Context *context, _Unwind_Ptr val)
{
abort();
}
extern "C" void __wrap__Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word val)
extern "C" void __wrap__Unwind_SetGR(struct _Unwind_Context *context, int index, _Unwind_Word val)
{
abort();
}
extern "C" _Unwind_Ptr __wrap__Unwind_GetIPInfo (struct _Unwind_Context *context, int *ip_before_insn)
extern "C" _Unwind_Ptr __wrap__Unwind_GetIPInfo(struct _Unwind_Context *context, int *ip_before_insn)
{
return abort_return<_Unwind_Ptr>();
}
extern "C" _Unwind_Ptr __wrap__Unwind_GetIP (struct _Unwind_Context *context)
__attribute__((alias("forward_abort_uw_ctx")));
extern "C" _Unwind_Ptr __wrap__Unwind_GetIP(struct _Unwind_Context *context)
__attribute__((alias("forward_abort_uw_ctx")));
extern "C" _Unwind_Ptr __wrap__Unwind_GetRegionStart (struct _Unwind_Context *context)
__attribute__((alias("forward_abort_uw_ctx")));
extern "C" _Unwind_Ptr __wrap__Unwind_GetRegionStart(struct _Unwind_Context *context)
__attribute__((alias("forward_abort_uw_ctx")));
extern "C" _Unwind_Ptr __wrap__Unwind_GetDataRelBase (struct _Unwind_Context *context)
__attribute__((alias("forward_abort_uw_ctx")));
extern "C" _Unwind_Ptr __wrap__Unwind_GetDataRelBase(struct _Unwind_Context *context)
__attribute__((alias("forward_abort_uw_ctx")));
extern "C" _Unwind_Ptr __wrap__Unwind_GetTextRelBase (struct _Unwind_Context *context)
__attribute__((alias("forward_abort_uw_ctx")));
extern "C" _Unwind_Ptr __wrap__Unwind_GetTextRelBase(struct _Unwind_Context *context)
__attribute__((alias("forward_abort_uw_ctx")));
extern "C" void *__wrap__Unwind_GetLanguageSpecificData (struct _Unwind_Context *context)
__attribute__((alias("forward_abort_uw_ctx")));
extern "C" void *__wrap__Unwind_GetLanguageSpecificData(struct _Unwind_Context *context)
__attribute__((alias("forward_abort_uw_ctx")));
extern "C" void *__wrap__Unwind_FindEnclosingFunction (void *pc)
__attribute__((alias("abort_expect_void_and_return")));
extern "C" void *__wrap__Unwind_FindEnclosingFunction(void *pc)
__attribute__((alias("abort_expect_void_and_return")));
struct frame_state *__frame_state_for (void *pc_target, struct frame_state *state_in)
struct frame_state *__frame_state_for(void *pc_target, struct frame_state *state_in)
{
return abort_return<struct frame_state *>();
}
@ -142,27 +141,26 @@ typedef int _Unwind_Exception_Class;
typedef int* _Unwind_Trace_Fn;
typedef int* _Unwind_Stop_Fn;
extern "C" void __wrap__Unwind_Resume (struct _Unwind_Exception *exc)
extern "C" void __wrap__Unwind_Resume(struct _Unwind_Exception *exc)
{
abort();
}
extern "C" void __wrap__Unwind_DeleteException (struct _Unwind_Exception *exc)
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>();
}
extern "C" _Unwind_Reason_Code __wrap__Unwind_Resume_or_Rethrow (struct _Unwind_Exception *exc)
__attribute__((alias("__wrap__Unwind_RaiseException")));
extern "C" _Unwind_Reason_Code __wrap__Unwind_Resume_or_Rethrow(struct _Unwind_Exception *exc)
__attribute__((alias("__wrap__Unwind_RaiseException")));
extern "C" _Unwind_Reason_Code __wrap__Unwind_ForcedUnwind (struct _Unwind_Exception *exc,
_Unwind_Stop_Fn stop, void * stop_argument)
extern "C" _Unwind_Reason_Code __wrap__Unwind_ForcedUnwind(struct _Unwind_Exception *exc,
_Unwind_Stop_Fn stop, void * stop_argument)
{
return abort_return<_Unwind_Reason_Code>();
}
@ -173,14 +171,14 @@ extern "C" _Unwind_Reason_Code __wrap__Unwind_Backtrace(_Unwind_Trace_Fn trace,
}
// eh_personality.o
extern "C" void __wrap___cxa_call_unexpected (void *exc_obj_in)
__attribute__((alias("abort_expect_void")));
extern "C" void __wrap___cxa_call_unexpected(void *exc_obj_in)
__attribute__((alias("abort_expect_void")));
extern "C" _Unwind_Reason_Code __wrap___gxx_personality_v0 (int version,
_Unwind_Action actions,
_Unwind_Exception_Class exception_class,
struct _Unwind_Exception *ue_header,
struct _Unwind_Context *context)
extern "C" _Unwind_Reason_Code __wrap___gxx_personality_v0(int version,
_Unwind_Action actions,
_Unwind_Exception_Class exception_class,
struct _Unwind_Exception *ue_header,
struct _Unwind_Context *context)
{
return abort_return<_Unwind_Reason_Code>();
}

Wyświetl plik

@ -68,7 +68,7 @@ static void wait_for_guard_obj(guard_t* g)
s_static_init_waiting_count++;
#ifndef _NDEBUG
s_static_init_max_waiting_count = std::max(s_static_init_waiting_count,
s_static_init_max_waiting_count);
s_static_init_max_waiting_count);
#endif
do {
@ -91,7 +91,7 @@ static void wait_for_guard_obj(guard_t* g)
/* Semaphore may have been given because some other guard object became ready.
* Check the guard object we need and wait again if it is still pending.
*/
} while(g->pending);
} while (g->pending);
s_static_init_waiting_count--;
}

Wyświetl plik

@ -9,7 +9,7 @@
#include "esp_private/startup_internal.h"
namespace {
const char *TAG = "C++ init";
const char *TAG = "C++ init";
}
#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS

Wyświetl plik

@ -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

Wyświetl plik

@ -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,12 +59,12 @@ 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);
vTaskDelay(300 / portTICK_PERIOD_MS);
TEST_ASSERT_EQUAL(-1, mInitBy);
TEST_ASSERT_EQUAL(0, mInitCount);
mInitBy = arg;
@ -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);
@ -95,7 +95,7 @@ template<int obj>
static int start_slow_init_task(int id, int affinity)
{
return xTaskCreatePinnedToCore(&SlowInit<obj>::task, "slow_init", 2048,
reinterpret_cast<void*>(id), 3, NULL, affinity) ? 1 : 0;
reinterpret_cast<void*>(id), 3, NULL, affinity) ? 1 : 0;
}
TEST_CASE("static initialization guards work as expected", "[misc]")
@ -122,16 +122,16 @@ TEST_CASE("static initialization guards work as expected", "[misc]")
// All tasks should
for (int i = 0; i < task_count; ++i) {
TEST_ASSERT_TRUE(xSemaphoreTake(s_slow_init_sem, 500/portTICK_PERIOD_MS));
TEST_ASSERT_TRUE(xSemaphoreTake(s_slow_init_sem, 500 / portTICK_PERIOD_MS));
}
vSemaphoreDelete(s_slow_init_sem);
vTaskDelay(10); // Allow tasks to clean up, avoids race with leak detector
}
struct GlobalInitTest
{
GlobalInitTest() : index(order++) {
struct GlobalInitTest {
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() { }
};
@ -236,7 +232,7 @@ public:
TEST_CASE("can call virtual functions", "[misc]")
{
Derived d;
Base& b = static_cast<Base&>(d);
Base &b = static_cast<Base &>(d);
b.foo();
}
@ -278,7 +274,7 @@ static void recur_and_smash_cxx()
{
static int cnt;
volatile uint8_t buf[50];
volatile int num = sizeof(buf)+10;
volatile int num = sizeof(buf) + 10;
if (cnt++ < 1) {
recur_and_smash_cxx();

Wyświetl plik

@ -101,7 +101,7 @@ TEST_CASE("unsuccessful dynamic cast on reference throws exception", "[cxx]")
DerivedA derived_a;
Base &base = derived_a;
try {
DerivedB &derived_b = dynamic_cast<DerivedB&>(base);
DerivedB &derived_b = dynamic_cast<DerivedB &>(base);
derived_b.name(); // suppress warning
} catch (bad_cast &e) {
thrown = true;

Wyświetl plik

@ -14,11 +14,10 @@ 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)
: m_arg(arg)
{
cout << "In constructor, arg=" << arg << endl;
if (arg == 0) {

Wyświetl plik

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

Wyświetl plik

@ -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 */
@ -70,7 +73,7 @@ extern "C" void app_main()
std::vector<shared_ptr<Base>> objects(5);
cout << "Generating " << objects.size() << " random objects and printing their types:" << endl;
std::generate(objects.begin(), objects.end(), Base::make_random_derived);
for (auto &obj: objects) {
for (auto &obj : objects) {
cout << "obj->name() is: " << obj->name() << endl << '\t';
cout << "typeid(*obj).name() is: " << demangle(typeid(*obj).name()) << endl << '\t';

Wyświetl plik

@ -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/"