diff --git a/include/swift/Basic/LLVMInitialize.h b/include/swift/Basic/LLVMInitialize.h index 930a44d3cb450..a27f698e8259b 100644 --- a/include/swift/Basic/LLVMInitialize.h +++ b/include/swift/Basic/LLVMInitialize.h @@ -2,7 +2,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -19,14 +19,16 @@ #ifndef SWIFT_BASIC_LLVMINITIALIZE_H #define SWIFT_BASIC_LLVMINITIALIZE_H +#include "swift/Basic/Compiler.h" #include "llvm/Support/InitLLVM.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" #include "llvm/Support/TargetSelect.h" -#define PROGRAM_START(argc, argv) \ - llvm::InitLLVM _INITIALIZE_LLVM(argc, argv) +#define PROGRAM_START(argc, argv) \ + llvm::InitLLVM _INITIALIZE_LLVM(argc, argv); \ + llvm::setBugReportMsg(SWIFT_CRASH_BUG_REPORT_MESSAGE "\n") #define INITIALIZE_LLVM() \ do { \ diff --git a/lib/DriverTool/sil_opt_main.cpp b/lib/DriverTool/sil_opt_main.cpp index 8e74ad4a7d15c..74737ddcf72d1 100644 --- a/lib/DriverTool/sil_opt_main.cpp +++ b/lib/DriverTool/sil_opt_main.cpp @@ -2,7 +2,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -664,7 +664,6 @@ getASTOverrideKind(const SILOptOptions &options) { int sil_opt_main(ArrayRef argv, void *MainAddr) { INITIALIZE_LLVM(); - llvm::setBugReportMsg(SWIFT_CRASH_BUG_REPORT_MESSAGE "\n"); llvm::EnablePrettyStackTraceOnSigInfoForThisThread(); SILOptOptions options; diff --git a/lib/FrontendTool/FrontendTool.cpp b/lib/FrontendTool/FrontendTool.cpp index 9cdf8674f4170..7544562cfe3d3 100644 --- a/lib/FrontendTool/FrontendTool.cpp +++ b/lib/FrontendTool/FrontendTool.cpp @@ -2,7 +2,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -2259,7 +2259,6 @@ int swift::performFrontend(ArrayRef Args, const char *Argv0, void *MainAddr, FrontendObserver *observer) { INITIALIZE_LLVM(); - llvm::setBugReportMsg(SWIFT_CRASH_BUG_REPORT_MESSAGE "\n"); llvm::EnablePrettyStackTraceOnSigInfoForThisThread(); std::unique_ptr Instance = diff --git a/tools/swift-def-to-strings-converter/swift-def-to-strings-converter.cpp b/tools/swift-def-to-strings-converter/swift-def-to-strings-converter.cpp index 5bb5bf7ebda07..84c5e4bf51cd7 100644 --- a/tools/swift-def-to-strings-converter/swift-def-to-strings-converter.cpp +++ b/tools/swift-def-to-strings-converter/swift-def-to-strings-converter.cpp @@ -2,7 +2,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -14,8 +14,8 @@ // //===----------------------------------------------------------------------===// -#include "swift/Basic/LLVMInitialize.h" #include "swift/Basic/Compiler.h" +#include "swift/Basic/LLVMInitialize.h" #include "swift/Localization/LocalizationFormat.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallString.h" diff --git a/tools/swift-demangle-yamldump/swift-demangle-yamldump.cpp b/tools/swift-demangle-yamldump/swift-demangle-yamldump.cpp index 68590616df193..79722e4227fdf 100644 --- a/tools/swift-demangle-yamldump/swift-demangle-yamldump.cpp +++ b/tools/swift-demangle-yamldump/swift-demangle-yamldump.cpp @@ -2,7 +2,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -20,6 +20,7 @@ //===----------------------------------------------------------------------===// #include "swift/Basic/LLVM.h" +#include "swift/Basic/LLVMInitialize.h" #include "swift/Demangling/Demangle.h" #include "swift/Demangling/ManglingMacros.h" #include "llvm/ADT/StringRef.h" @@ -191,6 +192,8 @@ int main(int argc, char **argv) { // if main()'s first function call is passing argv[0]. std::rand(); #endif + PROGRAM_START(argc, argv); + llvm::cl::ParseCommandLineOptions(argc, argv); swift::Demangle::DemangleOptions options; diff --git a/tools/swift-demangle/swift-demangle.cpp b/tools/swift-demangle/swift-demangle.cpp index 4be5c514ebfd7..759d7cbdbbaa2 100644 --- a/tools/swift-demangle/swift-demangle.cpp +++ b/tools/swift-demangle/swift-demangle.cpp @@ -2,7 +2,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -14,6 +14,7 @@ // //===----------------------------------------------------------------------===// +#include "swift/Basic/LLVMInitialize.h" #include "swift/Demangling/Demangle.h" #include "swift/Demangling/ManglingFlavor.h" #include "swift/Demangling/ManglingMacros.h" @@ -407,6 +408,8 @@ int main(int argc, char **argv) { // if main()'s first function call is passing argv[0]. std::rand(); #endif + PROGRAM_START(argc, argv); + llvm::cl::ParseCommandLineOptions(argc, argv); swift::Demangle::DemangleOptions options; diff --git a/tools/swift-scan-test/swift-scan-test.cpp b/tools/swift-scan-test/swift-scan-test.cpp index 21ef7ad000b70..7509d19c4d5e9 100644 --- a/tools/swift-scan-test/swift-scan-test.cpp +++ b/tools/swift-scan-test/swift-scan-test.cpp @@ -2,7 +2,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2022 Apple Inc. and the Swift project authors +// Copyright (c) 2022 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -17,6 +17,7 @@ #include "swift-c/DependencyScan/DependencyScan.h" #include "swift/Basic/Defer.h" #include "swift/Basic/FileTypes.h" +#include "swift/Basic/LLVMInitialize.h" #include "swift/DependencyScan/DependencyScanJSON.h" #include "swift/DependencyScan/StringUtils.h" #include "llvm/ADT/StringExtras.h" @@ -283,6 +284,8 @@ createArgs(ArrayRef Cmd, StringSaver &Saver, Actions Action) { } int main(int argc, char *argv[]) { + PROGRAM_START(argc, argv); + llvm::cl::HideUnrelatedOptions(Category); llvm::cl::ParseCommandLineOptions(argc, argv, "Test libSwiftScan interfaces\n");