Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port member default initialization from constructor to declaration (C++11) #38697

Merged
merged 1 commit into from
May 14, 2020

Conversation

akien-mga
Copy link
Member

@akien-mga akien-mga commented May 12, 2020

Using clang-tidy's modernize-use-default-member-init check and
manual review of the changes, and some extra manual changes that
clang-tidy failed to do.

The changes were initially done by calling run-clang-tidy.py -fix with the provided config, and using the newly merged feature that gives us a compilation database (#32848). It's not perfect though, it made some bogus changes which led to compilation errors which I had to fix manually.

@akien-mga akien-mga added this to the 4.0 milestone May 12, 2020
@akien-mga akien-mga force-pushed the member-init-c++11 branch from e85b4cf to 0c85c3b Compare May 13, 2020 09:23
@akien-mga akien-mga requested review from neikeq and reduz as code owners May 13, 2020 09:23
@akien-mga akien-mga force-pushed the member-init-c++11 branch from 0c85c3b to ae73181 Compare May 13, 2020 09:45
@akien-mga akien-mga changed the title [WIP] Port member default initialization from constructor to declaration (C++11) Port member default initialization from constructor to declaration (C++11) May 13, 2020
@akien-mga akien-mga force-pushed the member-init-c++11 branch 5 times, most recently from 451d99c to d16b94e Compare May 13, 2020 13:38
@akien-mga
Copy link
Member Author

Alright, I went through all of core/ manually to move everything I could find to default initialization on declaration. clang-tidy only handled the cases ported to list initializers already, so there was a lot of manual work left.

Which also mean probably one or two PEBKACs that may result in a broken engine... we'll see :)

@akien-mga akien-mga force-pushed the member-init-c++11 branch from d16b94e to 03cdfff Compare May 13, 2020 13:47
@akien-mga akien-mga changed the title Port member default initialization from constructor to declaration (C++11) [WIP] Port member default initialization from constructor to declaration (C++11) May 13, 2020
@akien-mga
Copy link
Member Author

Marking as WIP again as it needs more testing, I spotted a few regressions:

  • Some text is missing in the project manager (welp)

  • Project manager crashes on exit with:

Thread 1 "godot-git" received signal SIGSEGV, Segmentation fault.
0x00000000045822bf in OS::print_error (this=0x0, p_function=0x58acd01 "unref", p_file=0x58acc80 "core/string_name.cpp", p_line=102, p_code=0x58acd07 "BUG!", p_rationale=0x58a21f0 "", p_type=Logger::ERR_ERROR)
    at core/os/os.cpp:120
120             _logger->log_error(p_function, p_file, p_line, p_code, p_rationale, p_type);
(gdb) bt
#0  0x00000000045822bf in OS::print_error (this=0x0, p_function=0x58acd01 "unref", p_file=0x58acc80 "core/string_name.cpp", p_line=102, p_code=0x58acd07 "BUG!", p_rationale=0x58a21f0 "", 
    p_type=Logger::ERR_ERROR) at core/os/os.cpp:120
#1  0x00000000044026e8 in _err_print_error (p_function=0x58acd01 "unref", p_file=0x58acc80 "core/string_name.cpp", p_line=102, p_error=0x58acd07 "BUG!", p_message=0x58a21f0 "", p_type=ERR_HANDLER_ERROR)
    at core/error_macros.cpp:81
#2  0x000000000440260f in _err_print_error (p_function=0x58acd01 "unref", p_file=0x58acc80 "core/string_name.cpp", p_line=102, p_error=0x58acd07 "BUG!", p_type=ERR_HANDLER_ERROR) at core/error_macros.cpp:72
#3  0x00000000044ac554 in StringName::unref (this=0x7f37cf0) at core/string_name.cpp:102
#4  0x00000000044adb88 in StringName::~StringName (this=0x7f37cf0, __in_chrg=<optimized out>) at core/string_name.cpp:392
#5  0x0000000002df8a7e in Map<StringName, EditorDebuggerServer* (*)(String const&), Comparator<StringName>, DefaultAllocator>::Element::~Element (this=0x7f37cc0, __in_chrg=<optimized out>) at ./core/map.h:50
#6  0x0000000002df8aad in memdelete_allocator<Map<StringName, EditorDebuggerServer* (*)(String const&), Comparator<StringName>, DefaultAllocator>::Element, DefaultAllocator> (p_class=0x7f37cc0)
    at ./core/os/memory.h:128
#7  0x0000000002df86a6 in Map<StringName, EditorDebuggerServer* (*)(String const&), Comparator<StringName>, DefaultAllocator>::_cleanup_tree (this=0x69fb620 <EditorDebuggerServer::protocols>, 
    p_element=0x7f37cc0) at ./core/map.h:496
#8  0x0000000002df8486 in Map<StringName, EditorDebuggerServer* (*)(String const&), Comparator<StringName>, DefaultAllocator>::clear (this=0x69fb620 <EditorDebuggerServer::protocols>) at ./core/map.h:651
#9  0x0000000002df90a8 in Map<StringName, EditorDebuggerServer* (*)(String const&), Comparator<StringName>, DefaultAllocator>::~Map (this=0x69fb620 <EditorDebuggerServer::protocols>, __in_chrg=<optimized out>)
    at ./core/map.h:671
#10 0x00007ffff779b867 in __run_exit_handlers () from /lib64/libc.so.6
#11 0x00007ffff779ba0a in exit () from /lib64/libc.so.6
#12 0x00007ffff7785ce1 in __libc_start_main () from /lib64/libc.so.6
#13 0x00000000019d158a in _start () at ../sysdeps/x86_64/start.S:120

@akien-mga akien-mga force-pushed the member-init-c++11 branch from 03cdfff to 8a74530 Compare May 13, 2020 14:22
@Xrayez
Copy link
Contributor

Xrayez commented May 13, 2020

Just to note, I've made some similar changes while developing some custom module in C++, and I've had linker errors related to undefined constructors, then after scons --clean which then forces full rebuild I managed to compile everything again (MSVC 14.2, Godot 3.2 branch).

@akien-mga
Copy link
Member Author

Taking some notes for myself:

  • Some text is missing in the project manager (welp)

Reverting changes to scene fixes it, so I'll have to dig in there for the regression.

  • Project manager crashes on exit with:

After reverting all my changes... turns out it's a bug in the master branch and not this PR? 😿

@akien-mga akien-mga force-pushed the member-init-c++11 branch from 8a74530 to 7ee7406 Compare May 13, 2020 20:33
@akien-mga akien-mga changed the title [WIP] Port member default initialization from constructor to declaration (C++11) Port member default initialization from constructor to declaration (C++11) May 13, 2020
@akien-mga
Copy link
Member Author

Some text is missing in the project manager (welp)

I had removed too much stuff from the Label constructor by mistake, should now be fixed.

Project manager crashes on exit

Confirmed in the master branch, so it's not this PR. I opened #38729.

Using `clang-tidy`'s `modernize-use-default-member-init` check and
manual review of the changes, and some extra manual changes that
`clang-tidy` failed to do.

Also went manually through all of `core` to find occurrences that
`clang-tidy` couldn't handle, especially all initializations done
in a constructor without using initializer lists.
@akien-mga akien-mga force-pushed the member-init-c++11 branch from 7ee7406 to 1f6f364 Compare May 14, 2020 08:02
@akien-mga
Copy link
Member Author

It seems to work well in my tests, so I'll merge. I'd still welcome a review by senior devs on the changes in core as my C++-fu is not the most extensive, but it should be fairly enough to fix any potential mistake that sneaked into this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants