Commit 35b194e8 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Make Init non-moveable

Summary: [Folly] Make Init non-moveable to break code that could trigger early invocation of the moved-from instance's destructor when copy elision is not applied.

Reviewed By: markisaa

Differential Revision: D14002508

fbshipit-source-id: faf8de587c0573d14d9b1082b7f531e147c48ed7
parent 7f0aea22
......@@ -49,6 +49,11 @@ class Init {
// Force ctor & dtor out of line for better stack traces even with LTO.
FOLLY_NOINLINE Init(int* argc, char*** argv, bool removeFlags = true);
FOLLY_NOINLINE ~Init();
Init(Init const&) = delete;
Init(Init&&) = delete;
Init& operator=(Init const&) = delete;
Init& operator=(Init&&) = delete;
};
} // namespace folly
......@@ -43,7 +43,7 @@ int main(int argc, char* argv[]) {
// folly::Init() will automatically initialize the logging settings based on
// the FOLLY_INIT_LOGGING_CONFIG declaration above and the --logging command
// line flag.
auto init = folly::Init(&argc, &argv);
folly::Init init(&argc, &argv);
// All XLOG() statements in this file will log to the category
// folly.logging.example.main
......
......@@ -96,7 +96,7 @@ std::string fbLogFatalCheck() {
* This is a simple helper program to exercise the LOG(FATAL) functionality.
*/
int main(int argc, char* argv[]) {
auto init = folly::Init(&argc, &argv);
folly::Init init(&argc, &argv);
if (FLAGS_check_debug) {
std::cout << "DEBUG=" << static_cast<int>(folly::kIsDebug) << "\n";
......
......@@ -26,7 +26,7 @@ LogOnDestruction d1("1");
LogOnDestruction d2("2");
int main(int argc, char* argv[]) {
auto init = folly::Init(&argc, &argv);
folly::Init init(&argc, &argv);
XLOG(INFO) << "main running";
use_log_on_shutdown();
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment