Author: Fangrui Song Date: 2023-02-24T13:43:12-08:00 New Revision: 1c417da0f0605e027eb02fb4108d08397b566c3b
URL: https://github.com/llvm/llvm-project/commit/1c417da0f0605e027eb02fb4108d08397b566c3b DIFF: https://github.com/llvm/llvm-project/commit/1c417da0f0605e027eb02fb4108d08397b566c3b.diff LOG: Remove uses of ATOMIC_VAR_INIT ATOMIC_VAR_INIT has a trivial definition `#define ATOMIC_VAR_INIT(value) (value)`, is deprecated in C17/C++20, and will be removed in newer standards. Added: Modified: lldb/test/API/tools/lldb-server/vCont-threads/main.cpp llvm/lib/Support/PrettyStackTrace.cpp llvm/lib/Support/Unix/Signals.inc Removed: ################################################################################ diff --git a/lldb/test/API/tools/lldb-server/vCont-threads/main.cpp b/lldb/test/API/tools/lldb-server/vCont-threads/main.cpp index 77b6aacc7d4d8..ffc1489dfeb8d 100644 --- a/lldb/test/API/tools/lldb-server/vCont-threads/main.cpp +++ b/lldb/test/API/tools/lldb-server/vCont-threads/main.cpp @@ -14,7 +14,7 @@ pseudo_barrier_t barrier; std::mutex print_mutex; -std::atomic<bool> can_work = ATOMIC_VAR_INIT(false); +std::atomic<bool> can_work = false; thread_local volatile sig_atomic_t can_exit_now = false; static void sigint_handler(int signo) {} diff --git a/llvm/lib/Support/PrettyStackTrace.cpp b/llvm/lib/Support/PrettyStackTrace.cpp index fa91405fee10a..f9f1b8a419b82 100644 --- a/llvm/lib/Support/PrettyStackTrace.cpp +++ b/llvm/lib/Support/PrettyStackTrace.cpp @@ -64,8 +64,7 @@ static LLVM_THREAD_LOCAL PrettyStackTraceEntry *PrettyStackTraceHead = nullptr; // the current thread". If the user happens to overflow an 'unsigned' with // SIGINFO requests, it's possible that some threads will stop responding to it, // but the program won't crash. -static volatile std::atomic<unsigned> GlobalSigInfoGenerationCounter = - ATOMIC_VAR_INIT(1); +static volatile std::atomic<unsigned> GlobalSigInfoGenerationCounter = 1; static LLVM_THREAD_LOCAL unsigned ThreadLocalSigInfoGenerationCounter = 0; namespace llvm { diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index 05a7335216f43..ce093d5a4dc07 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -84,13 +84,11 @@ static void InfoSignalHandler(int Sig); // defined below. using SignalHandlerFunctionType = void (*)(); /// The function to call if ctrl-c is pressed. -static std::atomic<SignalHandlerFunctionType> InterruptFunction = - ATOMIC_VAR_INIT(nullptr); -static std::atomic<SignalHandlerFunctionType> InfoSignalFunction = - ATOMIC_VAR_INIT(nullptr); +static std::atomic<SignalHandlerFunctionType> InterruptFunction = nullptr; +static std::atomic<SignalHandlerFunctionType> InfoSignalFunction = nullptr; /// The function to call on SIGPIPE (one-time use only). static std::atomic<SignalHandlerFunctionType> OneShotPipeSignalFunction = - ATOMIC_VAR_INIT(nullptr); + nullptr; namespace { /// Signal-safe removal of files. @@ -98,8 +96,8 @@ namespace { /// themselves is signal-safe. Memory is freed when the head is freed, deletion /// is therefore not signal-safe either. class FileToRemoveList { - std::atomic<char *> Filename = ATOMIC_VAR_INIT(nullptr); - std::atomic<FileToRemoveList *> Next = ATOMIC_VAR_INIT(nullptr); + std::atomic<char *> Filename = nullptr; + std::atomic<FileToRemoveList *> Next = nullptr; FileToRemoveList() = default; // Not signal-safe. @@ -188,7 +186,7 @@ public: Head.exchange(OldHead); } }; -static std::atomic<FileToRemoveList *> FilesToRemove = ATOMIC_VAR_INIT(nullptr); +static std::atomic<FileToRemoveList *> FilesToRemove = nullptr; /// Clean up the list in a signal-friendly manner. /// Recall that signals can fire during llvm_shutdown. If this occurs we should @@ -248,7 +246,7 @@ static const int InfoSigs[] = {SIGUSR1 static const size_t NumSigs = std::size(IntSigs) + std::size(KillSigs) + std::size(InfoSigs) + 1 /* SIGPIPE */; -static std::atomic<unsigned> NumRegisteredSignals = ATOMIC_VAR_INIT(0); +static std::atomic<unsigned> NumRegisteredSignals = 0; static struct { struct sigaction SA; int SigNo; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits