[Lldb-commits] [clang] [lldb] [clang] Split ObjectFilePCHContainerReader from ObjectFilePCHContainerWriter (PR #99599)
https://github.com/jansvoboda11 approved this pull request. LGTM sans the missing newline at the end of file and file headers not aligned to 80 columns. https://github.com/llvm/llvm-project/pull/99599 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [llvm] [lldb] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)
https://github.com/jansvoboda11 edited https://github.com/llvm/llvm-project/pull/75530 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)
https://github.com/jansvoboda11 requested changes to this pull request. This looks pretty nice, I left just a couple of notes. You might want to take a look at the CI failures. https://github.com/llvm/llvm-project/pull/75530 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [llvm] [lldb] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)
@@ -11,46 +11,13 @@ namespace clang { -CodeGenOptions::CodeGenOptions() { -#define CODEGENOPT(Name, Bits, Default) Name = Default; -#define ENUM_CODEGENOPT(Name, Type, Bits, Default) set##Name(Default); -#include "clang/Basic/CodeGenOptions.def" +CodeGenOptions::CodeGenOptions() { resetNonModularOptions(); } jansvoboda11 wrote: I find this confusing: why are we resetting only the non-modular options here? I'd expect all options to be set to default here. Maybe create extra helper function `resetAllOptions()` that will call to `resetNonModularOptions()` and explain how modular options are handled? https://github.com/llvm/llvm-project/pull/75530 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang] [llvm] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)
@@ -11,6 +11,7 @@ #include "clang/APINotes/APINotesOptions.h" #include "clang/Basic/CodeGenOptions.h" +#include "clang/Basic/DebugOptions.h" jansvoboda11 wrote: Wouldn't a forward declaration be enough in this case? https://github.com/llvm/llvm-project/pull/75530 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] [clang] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)
@@ -224,19 +233,20 @@ class CompilerInvocation : public CompilerInvocationBase { /// @{ // Note: These need to be pulled in manually. Otherwise, they get hidden by // the mutable getters with the same names. - using CompilerInvocationBase::getLangOpts; - using CompilerInvocationBase::getTargetOpts; - using CompilerInvocationBase::getDiagnosticOpts; - using CompilerInvocationBase::getHeaderSearchOpts; - using CompilerInvocationBase::getPreprocessorOpts; using CompilerInvocationBase::getAnalyzerOpts; - using CompilerInvocationBase::getMigratorOpts; using CompilerInvocationBase::getAPINotesOpts; using CompilerInvocationBase::getCodeGenOpts; + using CompilerInvocationBase::getDebugOpts; jansvoboda11 wrote: Can you undo the reordering here? Let's just add the debug options into the right place and then optionally extract this change into a separate trivially NFC commit (and maybe reorder the member variables to match). https://github.com/llvm/llvm-project/pull/75530 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang] [llvm] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)
@@ -1722,6 +1738,11 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, #include "clang/Driver/Options.inc" #undef CODEGEN_OPTION_WITH_MARSHALLING +#define DEBUG_OPTION_WITH_MARSHALLING(...) \ jansvoboda11 wrote: I'd expect this to go into separate `ParseDebugArgs()` function (which is declared in the header but not defined). https://github.com/llvm/llvm-project/pull/75530 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3f092f3 - [llvm] Extract common `OptTable` bits into macros
Author: Jan Svoboda Date: 2023-08-04T13:57:13-07:00 New Revision: 3f092f37b7362447cbb13f5502dae4bdd5762afd URL: https://github.com/llvm/llvm-project/commit/3f092f37b7362447cbb13f5502dae4bdd5762afd DIFF: https://github.com/llvm/llvm-project/commit/3f092f37b7362447cbb13f5502dae4bdd5762afd.diff LOG: [llvm] Extract common `OptTable` bits into macros All command-line tools using `llvm::opt` create an enum of option IDs and a table of `OptTable::Info` object. Most of the tools use the same ID (`OPT_##ID`), kind (`Option::KIND##Class`), group ID (`OPT_##GROUP`) and alias ID (`OPT_##ALIAS`). This patch extracts that common code into canonical macros. This results in fewer changes when tweaking the `OPTION` macros emitted by the TableGen backend. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D157028 Added: Modified: clang/include/clang/Driver/Options.h clang/lib/Driver/DriverOptions.cpp clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp clang/tools/clang-scan-deps/ClangScanDeps.cpp lld/COFF/Driver.h lld/COFF/DriverUtils.cpp lld/ELF/Driver.h lld/ELF/DriverUtils.cpp lld/MachO/Driver.h lld/MinGW/Driver.cpp lld/wasm/Driver.cpp lldb/tools/driver/Driver.cpp lldb/tools/lldb-server/lldb-gdbserver.cpp lldb/tools/lldb-vscode/lldb-vscode.cpp llvm/include/llvm/Option/OptTable.h llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.h llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp llvm/tools/dsymutil/dsymutil.cpp llvm/tools/llvm-cvtres/llvm-cvtres.cpp llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp llvm/tools/llvm-dwp/llvm-dwp.cpp llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp llvm/tools/llvm-ifs/llvm-ifs.cpp llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp llvm/tools/llvm-lipo/llvm-lipo.cpp llvm/tools/llvm-ml/llvm-ml.cpp llvm/tools/llvm-mt/llvm-mt.cpp llvm/tools/llvm-nm/llvm-nm.cpp llvm/tools/llvm-objcopy/ObjcopyOptions.cpp llvm/tools/llvm-objdump/ObjdumpOptID.h llvm/tools/llvm-objdump/llvm-objdump.cpp llvm/tools/llvm-rc/llvm-rc.cpp llvm/tools/llvm-readobj/llvm-readobj.cpp llvm/tools/llvm-size/llvm-size.cpp llvm/tools/llvm-strings/llvm-strings.cpp llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp llvm/tools/sancov/sancov.cpp llvm/unittests/Option/OptionParsingTest.cpp Removed: diff --git a/clang/include/clang/Driver/Options.h b/clang/include/clang/Driver/Options.h index 54c6f5faa37c22..fb0e536d972cbf 100644 --- a/clang/include/clang/Driver/Options.h +++ b/clang/include/clang/Driver/Options.h @@ -9,11 +9,7 @@ #ifndef LLVM_CLANG_DRIVER_OPTIONS_H #define LLVM_CLANG_DRIVER_OPTIONS_H -namespace llvm { -namespace opt { -class OptTable; -} -} +#include "llvm/Option/OptTable.h" namespace clang { namespace driver { @@ -43,9 +39,7 @@ enum ClangFlags { enum ID { OPT_INVALID = 0, // This is not an option ID. -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - OPT_##ID, +#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__), #include "clang/Driver/Options.inc" LastOption #undef OPTION diff --git a/clang/lib/Driver/DriverOptions.cpp b/clang/lib/Driver/DriverOptions.cpp index 2a6868d179159d..b25801a8f3f494 100644 --- a/clang/lib/Driver/DriverOptions.cpp +++ b/clang/lib/Driver/DriverOptions.cpp @@ -36,10 +36,7 @@ static constexpr const llvm::ArrayRef PrefixTable(PrefixTable_init, std::size(PrefixTable_init) - 1); static constexpr OptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - {PREFIX, NAME, HELPTEXT,METAVAR, OPT_##ID, Option::KIND##Class, \ - PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES}, +#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__), #include "clang/Driver/Options.inc" #undef OPTION }; diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index c553cf86da8e32..aea6792f1f3b84 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -117,9 +117,7 @@ enum WrapperFlags { enum ID { OPT_INVALID = 0, // This is not an option ID. -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - OPT_##ID, +#define
[Lldb-commits] [lldb] 2fc90af - [lldb] Fix build after 2da8f30c
Author: Jan Svoboda Date: 2023-09-29T10:01:37-07:00 New Revision: 2fc90afdac451b49d67c72bd41a99886811dd36c URL: https://github.com/llvm/llvm-project/commit/2fc90afdac451b49d67c72bd41a99886811dd36c DIFF: https://github.com/llvm/llvm-project/commit/2fc90afdac451b49d67c72bd41a99886811dd36c.diff LOG: [lldb] Fix build after 2da8f30c Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index f65192a3225edc1..aee0f1f56ec74b5 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -1077,13 +1077,14 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager, // While parsing the Sema will call this consumer with the provided // completion suggestions. if (completion_consumer) { -auto main_file = source_mgr.getFileEntryForID(source_mgr.getMainFileID()); +auto main_file = +source_mgr.getFileEntryRefForID(source_mgr.getMainFileID()); auto &PP = m_compiler->getPreprocessor(); // Lines and columns start at 1 in Clang, but code completion positions are // indexed from 0, so we need to add 1 to the line and column here. ++completion_line; ++completion_column; -PP.SetCodeCompletionPoint(main_file, completion_line, completion_column); +PP.SetCodeCompletionPoint(*main_file, completion_line, completion_column); } ASTConsumer *ast_transformer = ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 446d38c - [lldb] Fix test build failure
Author: Jan Svoboda Date: 2024-04-12T10:48:54-07:00 New Revision: 446d38c65f72fd5d242a64182b05683577f683d3 URL: https://github.com/llvm/llvm-project/commit/446d38c65f72fd5d242a64182b05683577f683d3 DIFF: https://github.com/llvm/llvm-project/commit/446d38c65f72fd5d242a64182b05683577f683d3.diff LOG: [lldb] Fix test build failure Caused by commit edd7fed9da48c0e708cce9bd4d305ae43d8bd77c Added: Modified: lldb/unittests/Host/FileSystemTest.cpp Removed: diff --git a/lldb/unittests/Host/FileSystemTest.cpp b/lldb/unittests/Host/FileSystemTest.cpp index 4ed9beff4d303c..3b5ee7c8bc2237 100644 --- a/lldb/unittests/Host/FileSystemTest.cpp +++ b/lldb/unittests/Host/FileSystemTest.cpp @@ -74,7 +74,7 @@ class DummyFileSystem : public vfs::FileSystem { } // Map any symlink to "/symlink". std::error_code getRealPath(const Twine &Path, - SmallVectorImpl &Output) const override { + SmallVectorImpl &Output) override { auto I = FilesAndDirs.find(Path.str()); if (I == FilesAndDirs.end()) return make_error_code(llvm::errc::no_such_file_or_directory); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e04fc2d - [llvm][lldb] Remove unused SmallVectorMemoryBuffer.h includes
Author: Jan Svoboda Date: 2021-12-09T11:32:13+01:00 New Revision: e04fc2d88efa60ed5527b90c15d8fc188739e989 URL: https://github.com/llvm/llvm-project/commit/e04fc2d88efa60ed5527b90c15d8fc188739e989 DIFF: https://github.com/llvm/llvm-project/commit/e04fc2d88efa60ed5527b90c15d8fc188739e989.diff LOG: [llvm][lldb] Remove unused SmallVectorMemoryBuffer.h includes Added: Modified: lldb/unittests/Expression/CppModuleConfigurationTest.cpp llvm/lib/LTO/LTOBackend.cpp llvm/lib/Object/MachOUniversalWriter.cpp Removed: diff --git a/lldb/unittests/Expression/CppModuleConfigurationTest.cpp b/lldb/unittests/Expression/CppModuleConfigurationTest.cpp index 3923f1215b340..017a0748c2243 100644 --- a/lldb/unittests/Expression/CppModuleConfigurationTest.cpp +++ b/lldb/unittests/Expression/CppModuleConfigurationTest.cpp @@ -11,7 +11,6 @@ #include "TestingSupport/SubsystemRAII.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" -#include "llvm/Support/SmallVectorMemoryBuffer.h" #include "gmock/gmock.h" #include "gtest/gtest.h" diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index be06556b0c3bf..15e20fec565f5 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -37,7 +37,6 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" -#include "llvm/Support/SmallVectorMemoryBuffer.h" #include "llvm/Support/ThreadPool.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" diff --git a/llvm/lib/Object/MachOUniversalWriter.cpp b/llvm/lib/Object/MachOUniversalWriter.cpp index 9673c97a10f01..ae1ff09a4f8f1 100644 --- a/llvm/lib/Object/MachOUniversalWriter.cpp +++ b/llvm/lib/Object/MachOUniversalWriter.cpp @@ -19,7 +19,6 @@ #include "llvm/Object/IRObjectFile.h" #include "llvm/Object/MachO.h" #include "llvm/Object/MachOUniversal.h" -#include "llvm/Support/SmallVectorMemoryBuffer.h" using namespace llvm; using namespace object; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [flang] [lldb] [llvm] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)
https://github.com/jansvoboda11 approved this pull request. LGTM once CI passes and Flang conflicts are resolved. https://github.com/llvm/llvm-project/pull/75530 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e348dbc - [lldb] Fix build after Clang API change
Author: Jan Svoboda Date: 2023-05-30T14:08:04-07:00 New Revision: e348dbc4b2766f17c251b6c305a3b34fbdb9be96 URL: https://github.com/llvm/llvm-project/commit/e348dbc4b2766f17c251b6c305a3b34fbdb9be96 DIFF: https://github.com/llvm/llvm-project/commit/e348dbc4b2766f17c251b6c305a3b34fbdb9be96.diff LOG: [lldb] Fix build after Clang API change This fixes breakage introduced by 769d282d. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp index 98c1b1a73b782..7895fc6d59ef7 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -333,7 +333,7 @@ bool ClangModulesDeclVendorImpl::AddModule(const SourceModule &module, HS.getFileMgr().getDirectory(module.search_path.GetStringRef()); if (!dir) return error(); - auto *file = HS.lookupModuleMapFile(*dir, is_framework); + auto file = HS.lookupModuleMapFile(*dir, is_framework); if (!file) return error(); if (!HS.loadModuleMapFile(file, is_system)) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 74113a4 - [lldb] Fix build error after 7bca6f45
Author: Jan Svoboda Date: 2023-06-15T11:59:47+02:00 New Revision: 74113a4150d683c9478331ae91018ab9092a634d URL: https://github.com/llvm/llvm-project/commit/74113a4150d683c9478331ae91018ab9092a634d DIFF: https://github.com/llvm/llvm-project/commit/74113a4150d683c9478331ae91018ab9092a634d.diff LOG: [lldb] Fix build error after 7bca6f45 Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp index 0af5de4702df6..5ce0d35378230 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -329,8 +329,8 @@ bool ClangModulesDeclVendorImpl::AddModule(const SourceModule &module, bool is_system = true; bool is_framework = false; - auto dir = - HS.getFileMgr().getDirectory(module.search_path.GetStringRef()); + auto dir = HS.getFileMgr().getOptionalDirectoryRef( + module.search_path.GetStringRef()); if (!dir) return error(); auto file = HS.lookupModuleMapFile(*dir, is_framework); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] bdbad3e - [lldb] Fix build after #132780
Author: Jan Svoboda Date: 2025-03-25T12:29:08-07:00 New Revision: bdbad3e4320509f632ae8b511d563136343d87d7 URL: https://github.com/llvm/llvm-project/commit/bdbad3e4320509f632ae8b511d563136343d87d7 DIFF: https://github.com/llvm/llvm-project/commit/bdbad3e4320509f632ae8b511d563136343d87d7.diff LOG: [lldb] Fix build after #132780 Added: Modified: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h Removed: diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 976cc47e5c51c..ed6297cc6f3e0 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -1217,10 +1217,11 @@ TypeSystemClang::GetOrCreateClangModule(llvm::StringRef name, // Lazily initialize the module map. if (!m_header_search_up) { -auto HSOpts = std::make_shared(); +m_header_search_opts_up = std::make_unique(); m_header_search_up = std::make_unique( -HSOpts, *m_source_manager_up, *m_diagnostics_engine_up, -*m_language_options_up, m_target_info_up.get()); +*m_header_search_opts_up, *m_source_manager_up, +*m_diagnostics_engine_up, *m_language_options_up, +m_target_info_up.get()); m_module_map_up = std::make_unique( *m_source_manager_up, *m_diagnostics_engine_up, *m_language_options_up, m_target_info_up.get(), *m_header_search_up); diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 6579f7b68a9d2..442f88a5b79ae 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -47,6 +47,7 @@ class PDBASTParser; namespace clang { class FileManager; class HeaderSearch; +class HeaderSearchOptions; class ModuleMap; } // namespace clang @@ -1203,6 +1204,7 @@ class TypeSystemClang : public TypeSystem { std::unique_ptr m_identifier_table_up; std::unique_ptr m_selector_table_up; std::unique_ptr m_builtins_up; + std::unique_ptr m_header_search_opts_up; std::unique_ptr m_header_search_up; std::unique_ptr m_module_map_up; std::unique_ptr m_dwarf_ast_parser_up; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang][frontend] Require invocation to construct `CompilerInstance` (PR #137668)
https://github.com/jansvoboda11 closed https://github.com/llvm/llvm-project/pull/137668 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Hide the `TargetOptions` pointer from `CompilerInvocation` (PR #106271)
https://github.com/jansvoboda11 edited https://github.com/llvm/llvm-project/pull/106271 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Hide the `TargetOptions` pointer from `CompilerInvocation` (PR #106271)
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/106271 >From 4431265f6be2b989b63e4562fa8def4448d336ab Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Tue, 27 Aug 2024 09:34:01 -0700 Subject: [PATCH 1/7] [clang] `TargetInfo` does not own `TargetOptions` --- clang-tools-extra/clangd/SystemIncludeExtractor.cpp | 2 +- clang-tools-extra/modularize/ModularizeUtilities.cpp | 2 +- clang/include/clang/Basic/TargetInfo.h | 7 +++ clang/include/clang/Frontend/CompilerInstance.h | 3 +++ clang/lib/Basic/Targets.cpp | 7 --- clang/lib/Frontend/ASTUnit.cpp | 2 +- clang/lib/Frontend/ChainedIncludesSource.cpp | 2 +- clang/lib/Frontend/CompilerInstance.cpp | 6 +++--- clang/lib/Interpreter/Interpreter.cpp| 2 +- clang/tools/clang-import-test/clang-import-test.cpp | 2 +- clang/unittests/Analysis/MacroExpansionContextTest.cpp | 2 +- clang/unittests/Basic/SourceManagerTest.cpp | 2 +- clang/unittests/CodeGen/TestCompiler.h | 3 +-- clang/unittests/Frontend/UtilsTest.cpp | 2 +- clang/unittests/Lex/HeaderSearchTest.cpp | 2 +- clang/unittests/Lex/LexerTest.cpp| 2 +- clang/unittests/Lex/ModuleDeclStateTest.cpp | 2 +- clang/unittests/Lex/PPCallbacksTest.cpp | 2 +- clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp | 2 +- clang/unittests/Lex/PPDependencyDirectivesTest.cpp | 2 +- clang/unittests/Lex/PPMemoryAllocationsTest.cpp | 2 +- 21 files changed, 30 insertions(+), 28 deletions(-) diff --git a/clang-tools-extra/clangd/SystemIncludeExtractor.cpp b/clang-tools-extra/clangd/SystemIncludeExtractor.cpp index d9642f1115a6d..6417bf8765622 100644 --- a/clang-tools-extra/clangd/SystemIncludeExtractor.cpp +++ b/clang-tools-extra/clangd/SystemIncludeExtractor.cpp @@ -256,7 +256,7 @@ bool isValidTarget(llvm::StringRef Triple) { DiagnosticsEngine Diags(new DiagnosticIDs, new DiagnosticOptions, new IgnoringDiagConsumer); llvm::IntrusiveRefCntPtr Target = - TargetInfo::CreateTargetInfo(Diags, TargetOpts); + TargetInfo::CreateTargetInfo(Diags, *TargetOpts); return bool(Target); } diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp index f45190f8aebec..ef57b0f5bbea5 100644 --- a/clang-tools-extra/modularize/ModularizeUtilities.cpp +++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp @@ -53,7 +53,7 @@ ModularizeUtilities::ModularizeUtilities(std::vector &InputPaths, Diagnostics( new DiagnosticsEngine(DiagIDs, DiagnosticOpts.get(), &DC, false)), TargetOpts(new ModuleMapTargetOptions()), - Target(TargetInfo::CreateTargetInfo(*Diagnostics, TargetOpts)), + Target(TargetInfo::CreateTargetInfo(*Diagnostics, *TargetOpts)), FileMgr(new FileManager(FileSystemOpts)), SourceMgr(new SourceManager(*Diagnostics, *FileMgr, false)), HSOpts(), HeaderInfo(new HeaderSearch(HSOpts, *SourceMgr, *Diagnostics, *LangOpts, diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 8c3dcda25bc8d..e4d51e298e313 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -224,7 +224,7 @@ enum OpenCLTypeKind : uint8_t { /// class TargetInfo : public TransferrableTargetInfo, public RefCountedBase { - std::shared_ptr TargetOpts; + TargetOptions *TargetOpts; llvm::Triple Triple; protected: // Target values set by the ctor of the actual target implementation. Default @@ -311,9 +311,8 @@ class TargetInfo : public TransferrableTargetInfo, /// \param Opts - The options to use to initialize the target. The target may /// modify the options to canonicalize the target feature information to match /// what the backend expects. - static TargetInfo * - CreateTargetInfo(DiagnosticsEngine &Diags, - const std::shared_ptr &Opts); + static TargetInfo *CreateTargetInfo(DiagnosticsEngine &Diags, + TargetOptions &Opts); virtual ~TargetInfo(); diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h index d8ef2691b46bb..7de4fb531d0e7 100644 --- a/clang/include/clang/Frontend/CompilerInstance.h +++ b/clang/include/clang/Frontend/CompilerInstance.h @@ -88,6 +88,9 @@ class CompilerInstance : public ModuleLoader { /// The target being compiled for. IntrusiveRefCntPtr Target; + /// Options for the auxiliary target. + std::unique_ptr AuxTargetOpts; + /// Auxiliary Target info. IntrusiveRefCntPtr AuxTarget; diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index c6d228fe98100..9889141ad2085 100644 ---
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang][modules] Lazily load by name lookups in module maps (PR #132853)
https://github.com/jansvoboda11 approved this pull request. LGTM, thank you! https://github.com/llvm/llvm-project/pull/132853 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Hide the `TargetOptions` pointer from `CompilerInvocation` (PR #106271)
https://github.com/jansvoboda11 closed https://github.com/llvm/llvm-project/pull/106271 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang][frontend] Require invocation to construct `CompilerInstance` (PR #137668)
https://github.com/jansvoboda11 created https://github.com/llvm/llvm-project/pull/137668 This PR makes it so that `CompilerInvocation` needs to be provided to `CompilerInstance` on construction. There are a couple of benefits in my view: * Making it impossible to mis-use some `CompilerInstance` APIs. For example there are cases, where `createDiagnostics()` was called before `setInvocation()`, causing the `DiagnosticEngine` to use the default-constructed `DiagnosticOptions` instead of the intended ones. * This shrinks `CompilerInstance`'s state space. * This makes it possible to access **the** invocation in `CompilerInstance`'s constructor (to be used in a follow-up). >From 7b45d9071b24f72bfa4bbbf75313470a67a70f95 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Mon, 21 Apr 2025 11:55:43 -0700 Subject: [PATCH] [clang][frontend] Require invocation for `CompilerInstance` construction --- .../clang-include-fixer/IncludeFixer.cpp | 3 +-- clang-tools-extra/clangd/Compiler.cpp | 4 +--- .../include-cleaner/unittests/RecordTest.cpp | 14 +++--- .../include/clang/Frontend/CompilerInstance.h | 12 +++- clang/lib/Frontend/ASTUnit.cpp| 19 +++ clang/lib/Frontend/ChainedIncludesSource.cpp | 5 ++--- clang/lib/Frontend/CompilerInstance.cpp | 17 +++-- clang/lib/Frontend/PrecompiledPreamble.cpp| 5 ++--- .../lib/Frontend/Rewrite/FrontendActions.cpp | 5 ++--- .../StaticAnalyzer/Frontend/ModelInjector.cpp | 4 ++-- clang/lib/Testing/TestAST.cpp | 4 +--- .../DependencyScanningWorker.cpp | 4 ++-- clang/lib/Tooling/Tooling.cpp | 3 +-- .../clang-import-test/clang-import-test.cpp | 15 +-- clang/tools/driver/cc1_main.cpp | 9 ++--- clang/unittests/AST/ExternalASTSourceTest.cpp | 13 - .../unittests/Frontend/CodeGenActionTest.cpp | 9 +++-- .../Frontend/CompilerInstanceTest.cpp | 3 +-- .../unittests/Frontend/FrontendActionTest.cpp | 18 ++ clang/unittests/Frontend/OutputStreamTest.cpp | 9 +++-- clang/unittests/Sema/SemaNoloadLookupTest.cpp | 3 +-- .../Serialization/ForceCheckFileInputTest.cpp | 6 ++ .../Serialization/LoadSpecLazilyTest.cpp | 3 +-- .../Serialization/ModuleCacheTest.cpp | 14 ++ .../Serialization/NoCommentsTest.cpp | 3 +-- .../PreambleInNamedModulesTest.cpp| 4 +--- .../Serialization/VarDeclConstantInitTest.cpp | 3 +-- clang/unittests/Support/TimeProfilerTest.cpp | 14 -- .../DependencyScannerTest.cpp | 4 ++-- clang/unittests/Tooling/Syntax/TokensTest.cpp | 3 +-- .../unittests/Tooling/Syntax/TreeTestBase.cpp | 3 +-- lldb/source/Commands/CommandObjectTarget.cpp | 6 ++ .../Clang/ClangModulesDeclVendor.cpp | 4 +--- 33 files changed, 102 insertions(+), 143 deletions(-) diff --git a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp index bba8f8acc77da..7b0e4ecda8214 100644 --- a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp +++ b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp @@ -89,8 +89,7 @@ bool IncludeFixerActionFactory::runInvocation( assert(Invocation->getFrontendOpts().Inputs.size() == 1); // Set up Clang. - clang::CompilerInstance Compiler(PCHContainerOps); - Compiler.setInvocation(std::move(Invocation)); + CompilerInstance Compiler(std::move(Invocation), std::move(PCHContainerOps)); Compiler.setFileManager(Files); // Create the compiler's actual diagnostics engine. We want to drop all diff --git a/clang-tools-extra/clangd/Compiler.cpp b/clang-tools-extra/clangd/Compiler.cpp index 161cc9ae0ca36..9be0152afd2f7 100644 --- a/clang-tools-extra/clangd/Compiler.cpp +++ b/clang-tools-extra/clangd/Compiler.cpp @@ -145,9 +145,7 @@ prepareCompilerInstance(std::unique_ptr CI, CI->getFrontendOpts().Inputs[0].getFile(), Buffer.get()); } - auto Clang = std::make_unique( - std::make_shared()); - Clang->setInvocation(std::move(CI)); + auto Clang = std::make_unique(std::move(CI)); Clang->createDiagnostics(*VFS, &DiagsClient, false); if (auto VFSWithRemapping = createVFSFromCompilerInvocation( diff --git a/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp b/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp index b1bbb2eb82414..a10c0d5a54a95 100644 --- a/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp @@ -618,14 +618,14 @@ TEST_F(PragmaIncludeTest, ExportInUnnamedBuffer) { llvm::MemoryBuffer::getMemBufferCopy(Extra.getValue(), /*BufferName=*/"")); - auto Clang = std::make_unique( - std::make_shared()); - Clang->createDiagnostics(*VFS); + auto DiagOpts = llvm::makeIntrusiveRefCn
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang][frontend] Require invocation to construct `CompilerInstance` (PR #137668)
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/137668 >From 692779413664a17287a1f34d4e3225ae8bc96ae0 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Mon, 21 Apr 2025 11:55:43 -0700 Subject: [PATCH 1/2] [clang][frontend] Require invocation for `CompilerInstance` construction --- .../clang-include-fixer/IncludeFixer.cpp | 3 +-- clang-tools-extra/clangd/Compiler.cpp | 4 +--- .../include-cleaner/unittests/RecordTest.cpp | 14 +++--- .../include/clang/Frontend/CompilerInstance.h | 12 +++- clang/lib/Frontend/ASTUnit.cpp| 19 +++ clang/lib/Frontend/ChainedIncludesSource.cpp | 5 ++--- clang/lib/Frontend/CompilerInstance.cpp | 17 +++-- clang/lib/Frontend/PrecompiledPreamble.cpp| 5 ++--- .../lib/Frontend/Rewrite/FrontendActions.cpp | 5 ++--- .../StaticAnalyzer/Frontend/ModelInjector.cpp | 4 ++-- clang/lib/Testing/TestAST.cpp | 4 +--- .../DependencyScanningWorker.cpp | 4 ++-- clang/lib/Tooling/Tooling.cpp | 3 +-- .../clang-import-test/clang-import-test.cpp | 15 +-- clang/tools/driver/cc1_main.cpp | 9 ++--- clang/unittests/AST/ExternalASTSourceTest.cpp | 13 - .../unittests/Frontend/CodeGenActionTest.cpp | 9 +++-- .../Frontend/CompilerInstanceTest.cpp | 3 +-- .../unittests/Frontend/FrontendActionTest.cpp | 18 ++ clang/unittests/Frontend/OutputStreamTest.cpp | 9 +++-- clang/unittests/Sema/SemaNoloadLookupTest.cpp | 3 +-- .../Serialization/ForceCheckFileInputTest.cpp | 6 ++ .../Serialization/LoadSpecLazilyTest.cpp | 3 +-- .../Serialization/ModuleCacheTest.cpp | 14 ++ .../Serialization/NoCommentsTest.cpp | 3 +-- .../PreambleInNamedModulesTest.cpp| 4 +--- .../Serialization/VarDeclConstantInitTest.cpp | 3 +-- clang/unittests/Support/TimeProfilerTest.cpp | 14 -- .../DependencyScannerTest.cpp | 4 ++-- clang/unittests/Tooling/Syntax/TokensTest.cpp | 3 +-- .../unittests/Tooling/Syntax/TreeTestBase.cpp | 3 +-- lldb/source/Commands/CommandObjectTarget.cpp | 6 ++ .../Clang/ClangModulesDeclVendor.cpp | 4 +--- 33 files changed, 102 insertions(+), 143 deletions(-) diff --git a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp index bba8f8acc77da..7b0e4ecda8214 100644 --- a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp +++ b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp @@ -89,8 +89,7 @@ bool IncludeFixerActionFactory::runInvocation( assert(Invocation->getFrontendOpts().Inputs.size() == 1); // Set up Clang. - clang::CompilerInstance Compiler(PCHContainerOps); - Compiler.setInvocation(std::move(Invocation)); + CompilerInstance Compiler(std::move(Invocation), std::move(PCHContainerOps)); Compiler.setFileManager(Files); // Create the compiler's actual diagnostics engine. We want to drop all diff --git a/clang-tools-extra/clangd/Compiler.cpp b/clang-tools-extra/clangd/Compiler.cpp index 161cc9ae0ca36..9be0152afd2f7 100644 --- a/clang-tools-extra/clangd/Compiler.cpp +++ b/clang-tools-extra/clangd/Compiler.cpp @@ -145,9 +145,7 @@ prepareCompilerInstance(std::unique_ptr CI, CI->getFrontendOpts().Inputs[0].getFile(), Buffer.get()); } - auto Clang = std::make_unique( - std::make_shared()); - Clang->setInvocation(std::move(CI)); + auto Clang = std::make_unique(std::move(CI)); Clang->createDiagnostics(*VFS, &DiagsClient, false); if (auto VFSWithRemapping = createVFSFromCompilerInvocation( diff --git a/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp b/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp index b1bbb2eb82414..a10c0d5a54a95 100644 --- a/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp @@ -618,14 +618,14 @@ TEST_F(PragmaIncludeTest, ExportInUnnamedBuffer) { llvm::MemoryBuffer::getMemBufferCopy(Extra.getValue(), /*BufferName=*/"")); - auto Clang = std::make_unique( - std::make_shared()); - Clang->createDiagnostics(*VFS); + auto DiagOpts = llvm::makeIntrusiveRefCnt(); + auto Diags = CompilerInstance::createDiagnostics(*VFS, DiagOpts.get()); + auto Invocation = std::make_unique(); + ASSERT_TRUE(CompilerInvocation::CreateFromArgs(*Invocation, {Filename.data()}, + *Diags, "clang")); - Clang->setInvocation(std::make_unique()); - ASSERT_TRUE(CompilerInvocation::CreateFromArgs( - Clang->getInvocation(), {Filename.data()}, Clang->getDiagnostics(), - "clang")); + auto Clang = std::make_unique(std::move(Invocation)); + Clang->createDiagnostics(*VFS); auto *FM = Clang->createFile
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
https://github.com/jansvoboda11 created https://github.com/llvm/llvm-project/pull/139584 The `DiagnosticOptions` class is currently intrusively reference-counted, which makes reasoning about its lifetime very difficult in some cases. For example, `CompilerInvocation` owns the `DiagnosticOptions` instance (wrapped in `llvm::IntrusiveRefCntPtr`) and only exposes an accessor returning `DiagnosticOptions &`. One would think this gives `CompilerInvocation` exclusive ownership of the object, but that's not the case: ```c++ void shareOwnership(CompilerInvocation &CI) { llvm::IntrusiveRefCntPtr CoOwner = &CI.getDiagnosticOptions(); // ... } ``` This is a perfectly valid pattern that is being actually used in the codebase. I would like to ensure the ownership of `DiagnosticOptions` by `CompilerInvocation` is guaranteed to be exclusive. This can be leveraged for a copy-on-write optimization later on. This PR changes usages of `DiagnosticOptions` across `clang`, `clang-tools-extra` and `lldb` to not be intrusively reference-counted. Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang][modules] Lazily load by name lookups in module maps (PR #132853)
jansvoboda11 wrote: Test change LGTM, I was probably trying to get to a minimal test-case and ended up with something that was relying on implementation details. https://github.com/llvm/llvm-project/pull/132853 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/139584 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
@@ -107,6 +107,7 @@ class ASTUnit { private: std::unique_ptr LangOpts; + std::shared_ptr DiagOpts; jansvoboda11 wrote: I was hoping it could be, but the situation is a bit weird. The documentation for `ASTUnit::LoadFromCommandLine()` says the `DiagnosticsEngine` parameter is expected to outlive the returned value. However, it's being passed in `IntrusiveRefCntPtr`, so the lifetime is not enforced, and of course some clients started to rely on `ASTUnit` taking shared ownership of that object. And the clients also use the `DiagnosticsEngine` object themselves after passing it to that function, so the ownership is indeed shared. And since `DiagnosticsEngine` now relies on `DiagnosticOptions` to live long enough, sharing ownership in `ASTUnit` was the best fit. Does that make sense? In general `ASTUnit` is a big pile of lifetime hacks which I'd like to clean up one day, but today is not the day. https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
@@ -837,6 +838,7 @@ class ASTUnit { static std::unique_ptr LoadFromCommandLine( const char **ArgBegin, const char **ArgEnd, std::shared_ptr PCHContainerOps, + std::shared_ptr DiagOpts, jansvoboda11 wrote: Explained above. https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
@@ -2032,6 +2032,7 @@ class SourceManagerForFile { // as they are created in `createSourceManagerForFile` so that they can be // deleted in the reverse order as they are created. std::unique_ptr FileMgr; + std::unique_ptr DiagOpts; jansvoboda11 wrote: I don't think I understand. Now that `DiagnosticOptions` are not intrusively reference-counted, raw pointers have clearer semantics than before (typically nullable non-owning borrow), no? I'd also argue that using values, references, raw pointers, `unique_ptr` and `shared_ptr` depending on the context is the clearest way to communicate lifetimes and ownership. Regardless, there's only one raw pointer to `DiagnosticOptions` remaining after my patch in `clang::tooling::ToolInvocation`, and that has exactly the semantics you'd expect: optional borrow where the owner is someone else and you expect them to keep the object alive long enough. https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
jansvoboda11 wrote: Are those in the upstream repo? If so, where are they coming from? I have a sparse checkout, so it's possible I missed some non-Clang and non-LLDB usages of `DiagnosticOptions`. https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
jansvoboda11 wrote: > @jansvoboda11 I've revered your PR due buildbot failures above (and my local > build failures with the same error messages). I'm happy to try your revised > patch to see if it build cleanly. Thanks! I already forward-fixed both failures: d25f95fdbc5314f30618912e18f00ad4dd720fa0 and b544853fc335bdba6edbcde33e0c284306cd08eb. https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
jansvoboda11 wrote: Reverted the revert, since the build now fails due to the forward-fixes not being reverted... https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
jansvoboda11 wrote: Thanks, I'll fix those ASAP. https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
jansvoboda11 wrote: Thanks for the concrete example! I think the key thing to realize is that the `DiagnosticsEngine` and `DiagnosticOptions` used for command-line parsing are typically throwaway and separate from those used for actual compilation. I suggest looking at how `cc1_main()` orchestrates this and why. The intent is for the `DiagnosticsEngine` used during the compilation (owned by `CompilerInstance`) to refer to the fully-formed `DiagnosticsOptions` (owned by `CompilerInvocation`). So concretely, I'd rewrite your example as: ```c++ clang::DiagnosticOptions diagnostic_options; llvm::IntrusiveRefCntPtr diagnostics_engine = clang::CompilerInstance::createDiagnostics( *file_system, diagnostic_options, new clang::TextDiagnosticPrinter(llvm::errs(), diagnostic_options)); clang::CreateInvocationOptions ci_opts; ci_opts.Diags = diagnostics_engine; // ... std::shared_ptr invocation = clang::createInvocation(args, ci_opts); auto compiler_instance = std::make_unique(invocation); compiler_instance->createDiagnostics(*file_system)); // ... return compiler_instance; ``` I agree the lifetimes shouldn't be this complicated. FWIW I'd like to get rid of the reference count of `DiagnosticsEngine` too, and make the lifetimes stricter and more explicit, but that's a lower priority compared to the `DiagnosticOptions` refactor for me. https://github.com/llvm/llvm-project/pull/139584 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits