[Lldb-commits] [PATCH] D140030: [lldb][TypeSystemClang][NFC] Make TemplateParameterInfos members private
Michael137 updated this revision to Diff 483759. Michael137 added a comment. - Fix tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140030/new/ https://reviews.llvm.org/D140030 Files: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h lldb/unittests/Symbol/TestTypeSystemClang.cpp Index: lldb/unittests/Symbol/TestTypeSystemClang.cpp === --- lldb/unittests/Symbol/TestTypeSystemClang.cpp +++ lldb/unittests/Symbol/TestTypeSystemClang.cpp @@ -470,11 +470,10 @@ TEST_F(TestTypeSystemClang, TemplateArguments) { TypeSystemClang::TemplateParameterInfos infos; - infos.names.push_back("T"); - infos.args.push_back(TemplateArgument(m_ast->getASTContext().IntTy)); - infos.names.push_back("I"); + infos.InsertArg("T", TemplateArgument(m_ast->getASTContext().IntTy)); + llvm::APSInt arg(llvm::APInt(8, 47)); - infos.args.push_back(TemplateArgument(m_ast->getASTContext(), arg, + infos.InsertArg("I", TemplateArgument(m_ast->getASTContext(), arg, m_ast->getASTContext().IntTy)); // template struct foo; @@ -598,126 +597,143 @@ // The behaviour should follow the C++ rules for redeclaring templates // (e.g., parameter names can be changed/omitted.) - // This describes a class template *instantiation* from which we will infer - // the structure of the class template. - TypeSystemClang::TemplateParameterInfos infos; - // Test an empty template parameter list: <> - ExpectNewTemplate("<>", infos); + ExpectNewTemplate("<>", {{}, {}}); + + clang::TemplateArgument intArg1(m_ast->getASTContext().IntTy); + clang::TemplateArgument intArg2(m_ast->getASTContext(), + llvm::APSInt(llvm::APInt(32, 47)), + m_ast->getASTContext().IntTy); + clang::TemplateArgument floatArg(m_ast->getASTContext().FloatTy); + clang::TemplateArgument charArg1(m_ast->getASTContext(), + llvm::APSInt(llvm::APInt(8, 47)), + m_ast->getASTContext().SignedCharTy); + + clang::TemplateArgument charArg2(m_ast->getASTContext(), + llvm::APSInt(llvm::APInt(8, 123)), + m_ast->getASTContext().SignedCharTy); // Test that with T = int creates a new template. - infos.names = {"T"}; - infos.args = {TemplateArgument(m_ast->getASTContext().IntTy)}; - ClassTemplateDecl *single_type_arg = ExpectNewTemplate("", infos); + ClassTemplateDecl *single_type_arg = + ExpectNewTemplate("", {{"T"}, {intArg1}}); // Test that changing the parameter name doesn't create a new class template. - infos.names = {"A"}; - ExpectReusedTemplate(" (A = int)", infos, single_type_arg); + ExpectReusedTemplate(" (A = int)", {{"A"}, {intArg1}}, + single_type_arg); // Test that changing the used type doesn't create a new class template. - infos.args = {TemplateArgument(m_ast->getASTContext().FloatTy)}; - ExpectReusedTemplate(" (A = float)", infos, single_type_arg); + ExpectReusedTemplate(" (A = float)", {{"A"}, {floatArg}}, + single_type_arg); // Test that creates a new template with A = int // and I = 47; - infos.names.push_back("I"); - infos.args.push_back(TemplateArgument(m_ast->getASTContext(), -llvm::APSInt(llvm::APInt(8, 47)), -m_ast->getASTContext().SignedCharTy)); ClassTemplateDecl *type_and_char_value = - ExpectNewTemplate(" (I = 47)", infos); + ExpectNewTemplate(" (I = 47)", +{{"A", "I"}, {floatArg, charArg1}}); // Change the value of the I parameter to 123. The previously created // class template should still be reused. - infos.args.pop_back(); - infos.args.push_back(TemplateArgument(m_ast->getASTContext(), -llvm::APSInt(llvm::APInt(8, 123)), -m_ast->getASTContext().SignedCharTy)); - ExpectReusedTemplate(" (I = 123)", infos, - type_and_char_value); + ExpectReusedTemplate(" (I = 123)", + {{"A", "I"}, {floatArg, charArg2}}, type_and_char_value); // Change the type of the I parameter to int so we have . // The class template from above can't be reused. - infos.args.pop_back(); - infos.args.push_back(TemplateArgument(m_ast->getASTContext(), -llvm::APSInt(llvm::APInt(32, 47)), -m_ast->getASTContext().IntTy)); - ExpectNewTemplate(" (I = 123)", infos); + ExpectNewTemplate(" (I = 123)", +{{"A", "I"}, {floatArg, intArg2}}); // Test a second type pa
[Lldb-commits] [PATCH] D140262: [lldb][TypeSystemClang][NFC] Introduce TemplateParameterInfos::ArgumentMetadata
Michael137 created this revision. Michael137 added reviewers: aprantl, labath. Herald added a project: All. Michael137 requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. This patch creates a new aggregate type that holds information about a template argument. Currently this is only its name but in future patches we plan to add additional information. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D140262 Files: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h lldb/unittests/Symbol/TestTypeSystemClang.cpp Index: lldb/unittests/Symbol/TestTypeSystemClang.cpp === --- lldb/unittests/Symbol/TestTypeSystemClang.cpp +++ lldb/unittests/Symbol/TestTypeSystemClang.cpp @@ -615,47 +615,52 @@ // Test that with T = int creates a new template. ClassTemplateDecl *single_type_arg = - ExpectNewTemplate("", {{"T"}, {intArg1}}); + ExpectNewTemplate("", {{{"T"}}, {intArg1}}); // Test that changing the parameter name doesn't create a new class template. - ExpectReusedTemplate(" (A = int)", {{"A"}, {intArg1}}, + ExpectReusedTemplate(" (A = int)", {{{"A"}}, {intArg1}}, single_type_arg); // Test that changing the used type doesn't create a new class template. - ExpectReusedTemplate(" (A = float)", {{"A"}, {floatArg}}, + ExpectReusedTemplate(" (A = float)", {{{"A"}}, {floatArg}}, single_type_arg); // Test that creates a new template with A = int // and I = 47; ClassTemplateDecl *type_and_char_value = ExpectNewTemplate(" (I = 47)", -{{"A", "I"}, {floatArg, charArg1}}); +{{{"A"}, {"I"}}, {floatArg, charArg1}}); // Change the value of the I parameter to 123. The previously created // class template should still be reused. ExpectReusedTemplate(" (I = 123)", - {{"A", "I"}, {floatArg, charArg2}}, type_and_char_value); + {{{"A"}, {"I"}}, {floatArg, charArg2}}, + type_and_char_value); // Change the type of the I parameter to int so we have . // The class template from above can't be reused. ExpectNewTemplate(" (I = 123)", -{{"A", "I"}, {floatArg, intArg2}}); +{{{"A"}, {"I"}}, {floatArg, intArg2}}); // Test a second type parameter will also cause a new template to be created. // We now have . ClassTemplateDecl *type_and_char_value_and_type = ExpectNewTemplate("", -{{"A", "I", "B"}, {floatArg, intArg2, intArg1}}); +{{{"A"}, {"I"}, {"B"}}, {floatArg, intArg2, intArg1}}); // Remove all the names from the parameters which shouldn't influence the // way the templates get merged. ExpectReusedTemplate("", - {{"", "", ""}, {floatArg, intArg2, intArg1}}, + {{{""}, {""}, {""}}, {floatArg, intArg2, intArg1}}, type_and_char_value_and_type); } TEST_F(TestCreateClassTemplateDecl, FindExistingTemplatesWithParameterPack) { // The same as FindExistingTemplates but for templates with parameter packs. + + using ArgumentMetadata = + TypeSystemClang::TemplateParameterInfos::ArgumentMetadata; + TypeSystemClang::TemplateParameterInfos infos; clang::TemplateArgument intArg1(m_ast->getASTContext().IntTy); clang::TemplateArgument intArg2(m_ast->getASTContext(), @@ -671,7 +676,7 @@ infos.SetParameterPack( std::make_unique( - llvm::SmallVector{"", ""}, + llvm::SmallVector{{""}, {""}}, llvm::SmallVector{intArg1, intArg1})); ClassTemplateDecl *type_pack = @@ -687,42 +692,42 @@ // Change the type content of pack type values. infos.SetParameterPack( std::make_unique( - llvm::SmallVector{"", ""}, + llvm::SmallVector{{""}, {""}}, llvm::SmallVector{intArg1, longArg1})); ExpectReusedTemplate(" (int, long)", infos, type_pack); // Change the number of pack values. infos.SetParameterPack( std::make_unique( - llvm::SmallVector{""}, + llvm::SmallVector{{""}}, llvm::SmallVector{intArg1})); ExpectReusedTemplate(" (int)", infos, type_pack); // The names of the pack values shouldn't matter. infos.SetParameterPack( std::make_unique( - llvm::SmallVector{"A"}, + llvm::SmallVector{{"A"}}, llvm::SmallVector{intArg1})); ExpectReusedTemplate(" (int)", infos, type_pack); // Changing the kind of template argument will create a new template. infos.SetParameterPack( std::make_unique( - llvm::SmallVector{"A"}, + llvm::SmallVector{{"A"}}, llvm::SmallVector{intArg2})); ClassTemplateDecl *int_pack = ExpectNewTemplate(" (int = 1)",
[Lldb-commits] [PATCH] D139973: [llvm] Make llvm::Any similar to std::any
jloser added a comment. I'm +1 for the direction here; I took a brief look but will look closely either later tonight or tomorrow before I approve. Thanks for doing this! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139973/new/ https://reviews.llvm.org/D139973 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D132735: [LLDB] Recognize `std::noop_coroutine()` in `std::coroutine_handle` pretty printer
avogelsgesang added a comment. I reapplied this patch locally on top of the latest `main` and tried to reproduce the issue on my Mac using > cmake -B build -G Ninja -C lldb/cmake/caches/Apple-lldb-macOS.cmake > -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" -DLLVM_ENABLE_PROJECTS="clang;lldb" > llvm > ninja check-lldb This gives me 10 failing tests, but none of them are related to the coroutine_handle pretty printer. If I run > ./bin/llvm-lit > ../lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle I get > UNSUPPORTED: lldb-api :: > functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py > (1 of 1) No idea why this test is marked as unsupportd. Any idea how I can run this test case locally on my mac? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D132735/new/ https://reviews.llvm.org/D132735 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f43886e - [lldb] llvm::Optional::value() && => operator*/operator->
Author: Fangrui Song Date: 2022-12-17T20:37:13Z New Revision: f43886e7ba5abf9ee8c4d3f0ffbd18eee724466f URL: https://github.com/llvm/llvm-project/commit/f43886e7ba5abf9ee8c4d3f0ffbd18eee724466f DIFF: https://github.com/llvm/llvm-project/commit/f43886e7ba5abf9ee8c4d3f0ffbd18eee724466f.diff LOG: [lldb] llvm::Optional::value() && => operator*/operator-> std::optional::value() has undesired exception checking semantics and is unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The call sites block std::optional migration. Added: Modified: lldb/source/Commands/CommandObjectFrame.cpp lldb/source/Commands/CommandObjectMemory.cpp lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp lldb/source/Target/Thread.cpp lldb/tools/lldb-test/lldb-test.cpp lldb/unittests/Host/ConnectionFileDescriptorTest.cpp lldb/unittests/Utility/StringExtractorGDBRemoteTest.cpp Removed: diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 64bd2c3ddf207..a09fe64c7ac72 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -144,10 +144,10 @@ class CommandObjectFrameDiagnose : public CommandObjectParsed { "`frame diagnose --address` is incompatible with other arguments."); return false; } - valobj_sp = frame_sp->GuessValueForAddress(m_options.address.value()); + valobj_sp = frame_sp->GuessValueForAddress(*m_options.address); } else if (m_options.reg) { valobj_sp = frame_sp->GuessValueForRegisterAndOffset( - m_options.reg.value(), m_options.offset.value_or(0)); + *m_options.reg, m_options.offset.value_or(0)); } else { StopInfoSP stop_info_sp = thread->GetStopInfo(); if (!stop_info_sp) { diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index e42665b974156..646747ec3758b 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -1739,7 +1739,7 @@ class CommandObjectMemoryRegion : public CommandObjectParsed { const llvm::Optional> &dirty_page_list = range_info.GetDirtyPageList(); if (dirty_page_list) { - const size_t page_count = dirty_page_list.value().size(); + const size_t page_count = dirty_page_list->size(); result.AppendMessageWithFormat( "Modified memory (dirty) page list provided, %zu entries.\n", page_count); diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp index 1af60d25f7bc2..b78fbf7b750e6 100644 --- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp +++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp @@ -1214,8 +1214,7 @@ class Executor { return transformOptional(inst.rs1.Read(m_emu), [&](auto &&rs1) { uint64_t addr = rs1 + uint64_t(inst.imm); - uint64_t bits = - m_emu.ReadMem(addr).value(); + uint64_t bits = *m_emu.ReadMem(addr); APFloat f(semantics(), APInt(numBits, bits)); return inst.rd.WriteAPFloat(m_emu, f); }) diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp index cf543ce48439f..70adc1d5a8a3d 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp @@ -55,8 +55,8 @@ Optional CPlusPlusNameParser::ParseAsFullName() { if (HasMoreTokens()) return std::nullopt; ParsedName result; - result.basename = GetTextForRange(name_ranges.value().basename_range); - result.context = GetTextForRange(name_ranges.value().context_range); + result.basename = GetTextForRange(name_ranges->basename_range); + result.context = GetTextForRange(name_ranges->context_range); return result; } @@ -130,8 +130,8 @@ CPlusPlusNameParser::ParseFunctionImpl(bool expect_return_type) { SkipFunctionQualifiers(); size_t end_position = GetCurrentPosition(); - result.name.basename = GetTextForRange(maybe_name.value().basename_range); - result.name.context = GetTextForRange(maybe_name.value().context_range); + result.name.basename = GetTextForRange(maybe_name->basename_range); + result.name.context = GetTextForRange(maybe_name->context_range); result.arguments = GetTextForRange(Range(argument_start, qualifiers_start)); result.qualifiers = GetTextForRange(Range(qualifiers_
[Lldb-commits] [lldb] fbaf48b - [lldb] Remove redundant .c_str() and .get() calls
Author: Fangrui Song Date: 2022-12-18T01:15:25Z New Revision: fbaf48be0ff6fb24b9aa8fe9c2284fe88a8798dd URL: https://github.com/llvm/llvm-project/commit/fbaf48be0ff6fb24b9aa8fe9c2284fe88a8798dd DIFF: https://github.com/llvm/llvm-project/commit/fbaf48be0ff6fb24b9aa8fe9c2284fe88a8798dd.diff LOG: [lldb] Remove redundant .c_str() and .get() calls Removing .c_str() has a semantics difference, but the use scenarios likely do not matter as we don't have NUL in the strings. Added: Modified: lldb/include/lldb/Target/Process.h lldb/source/API/SBCommandReturnObject.cpp lldb/source/API/SBExpressionOptions.cpp lldb/source/API/SBSourceManager.cpp lldb/source/Breakpoint/BreakpointResolverScripted.cpp lldb/source/Commands/CommandObjectBreakpoint.cpp lldb/source/Commands/CommandObjectExpression.cpp lldb/source/Commands/CommandObjectHelp.cpp lldb/source/Commands/CommandObjectMultiword.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Commands/CommandObjectThread.cpp lldb/source/Core/Disassembler.cpp lldb/source/Core/FormatEntity.cpp lldb/source/Core/IOHandlerCursesGUI.cpp lldb/source/Expression/REPL.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/OptionArgParser.cpp lldb/source/Interpreter/OptionValueArch.cpp lldb/source/Interpreter/ScriptInterpreter.cpp lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp lldb/source/Plugins/Language/ObjC/Cocoa.cpp lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp lldb/source/Plugins/Platform/Android/AdbClient.cpp lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.h lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h lldb/source/Symbol/LocateSymbolFileMacOSX.cpp lldb/source/Target/LanguageRuntime.cpp lldb/source/Target/TargetList.cpp lldb/source/Target/Thread.cpp lldb/source/Target/ThreadPlanStack.cpp lldb/tools/debugserver/source/DNBTimer.h lldb/tools/lldb-vscode/BreakpointBase.cpp Removed: diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 47040137078f..8bb8b85e22fb 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -2704,7 +2704,7 @@ void PruneThreadPlans(); }; void SetNextEventAction(Process::NextEventAction *next_event_action) { -if (m_next_event_action_up.get()) +if (m_next_event_action_up) m_next_event_action_up->HandleBeingUnshipped(); m_next_event_action_up.reset(next_event_action); diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp index 7d2c102b3d8c..bf9c66453c90 100644 --- a/lldb/source/API/SBCommandReturnObject.cpp +++ b/lldb/source/API/SBCommandReturnObject.cpp @@ -292,7 +292,7 @@ void SBCommandReturnObject::PutCString(const char *string, int len) { return; } else if (len > 0) { std::string buffer(string, len); -ref().AppendMessage(buffer.c_str()); +ref().AppendMessage(buffer); } else ref().AppendMessage(string); } diff --git a/lldb/source/API/SBExpressionOptions.cpp b/lldb/source/API/SBExpressionOptions.cpp index d07acbc0aa2d..6ae57f24606a 100644 --- a/lldb/source/API/SBExpressionOptions.cpp +++ b/lldb/source/API/SBExpressionOptions.cpp @@ -254,5 +254,5 @@ EvaluateExpressionOptions *SBExpressionOptions::get() const { } EvaluateExpressionOptions &SBExpressionOptions::ref() const { - return *(m_opaque_up.get()); + return *m_opaque_up; } diff --git a/lldb/source/API/SBSourceManager.cpp b/lldb/so