[Lldb-commits] [lldb] [lldb] Make argument to ConstString::AsCString explicit (PR #190183)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Apr 2 07:34:06 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-mips
Author: Michael Buch (Michael137)
<details>
<summary>Changes</summary>
This patch makes the default parameter to ConstString::AsCString explicit. Currently it defaults to `nullptr`. However, there a bunch of callsites that do `printf("%s", foo.AsCString())`, which is UB (I have at least 1 crash on me where this was the root cause).
Alternatively we could change the default to `""` instead of `nullptr`, but code that did `if (foo.AsCString())` would then change meaning.
Command I ran to generate this patch:
```
rg "\.AsCString\(\)" lldb -l | xargs sed -i '' 's/\.AsCString()/.AsCString(nullptr)/g'
```
In a follow-up PR I intend to change the callsites that do `printf("%s", foo.AsCString(nullptr)` to pass `""` as the fallback parameter.
---
Patch is 354.91 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/190183.diff
231 Files Affected:
- (modified) lldb/include/lldb/DataFormatters/FormattersContainer.h (+2-2)
- (modified) lldb/include/lldb/DataFormatters/TypeSynthetic.h (+2-2)
- (modified) lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h (+2-2)
- (modified) lldb/include/lldb/Utility/ConstString.h (+1-6)
- (modified) lldb/source/API/SBAttachInfo.cpp (+1-1)
- (modified) lldb/source/API/SBCommandInterpreter.cpp (+6-5)
- (modified) lldb/source/API/SBCommunication.cpp (+1-1)
- (modified) lldb/source/API/SBDebugger.cpp (+3-3)
- (modified) lldb/source/API/SBEvent.cpp (+1-1)
- (modified) lldb/source/API/SBFileSpec.cpp (+1-1)
- (modified) lldb/source/API/SBFunction.cpp (+7-6)
- (modified) lldb/source/API/SBLanguageRuntime.cpp (+2-2)
- (modified) lldb/source/API/SBLaunchInfo.cpp (+4-3)
- (modified) lldb/source/API/SBMemoryRegionInfo.cpp (+1-1)
- (modified) lldb/source/API/SBModule.cpp (+1-1)
- (modified) lldb/source/API/SBPlatform.cpp (+3-2)
- (modified) lldb/source/API/SBProcess.cpp (+4-4)
- (modified) lldb/source/API/SBSymbol.cpp (+5-4)
- (modified) lldb/source/API/SBTarget.cpp (+3-3)
- (modified) lldb/source/API/SBThread.cpp (+9-9)
- (modified) lldb/source/API/SBThreadPlan.cpp (+7-7)
- (modified) lldb/source/API/SBValue.cpp (+13-13)
- (modified) lldb/source/API/SBWatchpoint.cpp (+1-1)
- (modified) lldb/source/Breakpoint/Breakpoint.cpp (+2-2)
- (modified) lldb/source/Breakpoint/BreakpointIDList.cpp (+1-1)
- (modified) lldb/source/Breakpoint/BreakpointLocation.cpp (+2-2)
- (modified) lldb/source/Breakpoint/BreakpointOptions.cpp (+3-3)
- (modified) lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp (+1-1)
- (modified) lldb/source/Commands/CommandObjectBreakpoint.cpp (+15-11)
- (modified) lldb/source/Commands/CommandObjectCommands.cpp (+17-17)
- (modified) lldb/source/Commands/CommandObjectFrame.cpp (+4-3)
- (modified) lldb/source/Commands/CommandObjectMemory.cpp (+12-11)
- (modified) lldb/source/Commands/CommandObjectMemoryTag.cpp (+3-3)
- (modified) lldb/source/Commands/CommandObjectPlatform.cpp (+18-17)
- (modified) lldb/source/Commands/CommandObjectPlugin.cpp (+1-1)
- (modified) lldb/source/Commands/CommandObjectProcess.cpp (+13-11)
- (modified) lldb/source/Commands/CommandObjectRegister.cpp (+2-2)
- (modified) lldb/source/Commands/CommandObjectSettings.cpp (+10-10)
- (modified) lldb/source/Commands/CommandObjectSource.cpp (+10-9)
- (modified) lldb/source/Commands/CommandObjectTarget.cpp (+15-14)
- (modified) lldb/source/Commands/CommandObjectThread.cpp (+6-6)
- (modified) lldb/source/Commands/CommandObjectTrace.cpp (+2-2)
- (modified) lldb/source/Commands/CommandObjectType.cpp (+18-16)
- (modified) lldb/source/Commands/CommandObjectWatchpoint.cpp (+2-2)
- (modified) lldb/source/Core/Address.cpp (+1-1)
- (modified) lldb/source/Core/AddressRange.cpp (+1-1)
- (modified) lldb/source/Core/Debugger.cpp (+3-2)
- (modified) lldb/source/Core/Disassembler.cpp (+4-4)
- (modified) lldb/source/Core/DynamicLoader.cpp (+1-1)
- (modified) lldb/source/Core/FormatEntity.cpp (+6-6)
- (modified) lldb/source/Core/IOHandlerCursesGUI.cpp (+4-4)
- (modified) lldb/source/Core/Mangled.cpp (+2-2)
- (modified) lldb/source/Core/Module.cpp (+4-3)
- (modified) lldb/source/Core/ModuleList.cpp (+2-2)
- (modified) lldb/source/Core/Section.cpp (+2-2)
- (modified) lldb/source/Core/SourceManager.cpp (+1-1)
- (modified) lldb/source/DataFormatters/FormatManager.cpp (+2-1)
- (modified) lldb/source/DataFormatters/TypeSummary.cpp (+1-1)
- (modified) lldb/source/DataFormatters/TypeSynthetic.cpp (+2-2)
- (modified) lldb/source/DataFormatters/ValueObjectPrinter.cpp (+3-3)
- (modified) lldb/source/Expression/DWARFExpression.cpp (+4-4)
- (modified) lldb/source/Expression/FunctionCaller.cpp (+1-1)
- (modified) lldb/source/Expression/IRExecutionUnit.cpp (+4-4)
- (modified) lldb/source/Expression/LLVMUserExpression.cpp (+2-2)
- (modified) lldb/source/Expression/Materializer.cpp (+47-42)
- (modified) lldb/source/Expression/REPL.cpp (+8-6)
- (modified) lldb/source/Expression/UserExpression.cpp (+1-1)
- (modified) lldb/source/Host/common/NativeRegisterContext.cpp (+2-1)
- (modified) lldb/source/Host/common/Socket.cpp (+2-2)
- (modified) lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp (+3-3)
- (modified) lldb/source/Host/windows/ConnectionGenericFileWindows.cpp (+4-3)
- (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+1-1)
- (modified) lldb/source/Interpreter/CommandObject.cpp (+1-1)
- (modified) lldb/source/Interpreter/OptionValueDictionary.cpp (+1-1)
- (modified) lldb/source/Interpreter/OptionValuePathMappings.cpp (+5-3)
- (modified) lldb/source/Interpreter/OptionValueProperties.cpp (+1-1)
- (modified) lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp (+1-1)
- (modified) lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp (+3-2)
- (modified) lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp (+2-1)
- (modified) lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp (+1-1)
- (modified) lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp (+1-1)
- (modified) lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp (+2-1)
- (modified) lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp (+1-1)
- (modified) lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp (+1-1)
- (modified) lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp (+2-2)
- (modified) lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp (+2-2)
- (modified) lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp (+2-1)
- (modified) lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp (+2-2)
- (modified) lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp (+1-1)
- (modified) lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp (+1-1)
- (modified) lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp (+2-2)
- (modified) lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp (+2-2)
- (modified) lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (+2-2)
- (modified) lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp (+2-2)
- (modified) lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp (+2-2)
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp (+6-3)
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp (+7-4)
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (+7-7)
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp (+5-3)
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp (+1-1)
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (+5-4)
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp (+1-1)
- (modified) lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp (+1-1)
- (modified) lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp (+1-1)
- (modified) lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp (+1-1)
- (modified) lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp (+2-2)
- (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (+1-1)
- (modified) lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp (+1-1)
- (modified) lldb/source/Plugins/Language/CPlusPlus/GenericInitializerList.cpp (+2-2)
- (modified) lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp (+1-1)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp (+2-2)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp (+1-1)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp (+1-1)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxProxyArray.cpp (+2-2)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp (+1-1)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp (+2-2)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp (+2-2)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp (+1-1)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp (+2-2)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp (+6-6)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp (+3-3)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp (+1-1)
- (modified) lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp (+1-1)
- (modified) lldb/source/Plugins/Language/CPlusPlus/MsvcStlDeque.cpp (+2-2)
- (modified) lldb/source/Plugins/Language/CPlusPlus/MsvcStlSmartPointer.cpp (+2-2)
- (modified) lldb/source/Plugins/Language/CPlusPlus/MsvcStlSpan.cpp (+2-2)
- (modified) lldb/source/Plugins/Language/CPlusPlus/MsvcStlVector.cpp (+6-6)
- (modified) lldb/source/Plugins/Language/ObjC/Cocoa.cpp (+1-1)
- (modified) lldb/source/Plugins/Language/ObjC/NSDictionary.cpp (+1-1)
- (modified) lldb/source/Plugins/Language/ObjC/NSError.cpp (+1-1)
- (modified) lldb/source/Plugins/Language/ObjC/NSException.cpp (+1-1)
- (modified) lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp (+7-7)
- (modified) lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp (+3-3)
- (modified) lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (+1-1)
- (modified) lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (+1-1)
- (modified) lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (+8-8)
- (modified) lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp (+2-2)
- (modified) lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h (+2-2)
- (modified) lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp (+1-1)
- (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+12-10)
- (modified) lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.cpp (+1-1)
- (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (+12-10)
- (modified) lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp (+3-2)
- (modified) lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp (+9-9)
- (modified) lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (+1-1)
- (modified) lldb/source/Plugins/Platform/Android/AdbClient.cpp (+7-7)
- (modified) lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp (+4-4)
- (modified) lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp (+1-1)
- (modified) lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp (+19-19)
- (modified) lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp (+4-4)
- (modified) lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm (+1-1)
- (modified) lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (+9-9)
- (modified) lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp (+16-13)
- (modified) lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (+8-6)
- (modified) lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp (+1-1)
- (modified) lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp (+5-5)
- (modified) lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp (+1-1)
- (modified) lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (+1-1)
- (modified) lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp (+1-1)
- (modified) lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.cpp (+1-1)
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (+1-1)
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp (+12-10)
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp (+1-1)
- (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+18-15)
- (modified) lldb/source/Plugins/Process/mach-core/RegisterContextUnifiedCore.cpp (+2-2)
- (modified) lldb/source/Plugins/Process/scripted/ScriptedFrame.cpp (+4-3)
- (modified) lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp (+1-1)
- (modified) lldb/source/Plugins/Process/scripted/ScriptedThread.cpp (+2-2)
- (modified) lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp (+1-1)
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedFramePythonInterface.cpp (+5-4)
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp (+2-2)
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp (+1-1)
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h (+1-1)
- (modified) lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp (+3-2)
- (modified) lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp (+4-3)
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+11-11)
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (+3-3)
- (modified) lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp (+2-2)
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+4-4)
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (+5-5)
- (modified) lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (+2-1)
- (modified) lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (+4-3)
- (modified) lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp (+6-6)
- (modified) lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp (+1-1)
- (modified) lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp (+1-1)
- (modified) lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp (+1-1)
- (modified) lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp (+1-1)
- (modified) lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp (+1-1)
- (modified) lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp (+1-1)
- (modified) lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp (+2-1)
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+1-1)
- (modified) lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp (+2-1)
- (modified) lldb/source/Symbol/Function.cpp (+2-2)
- (modified) lldb/source/Symbol/SymbolContext.cpp (+5-3)
- (modified) lldb/source/Symbol/Symtab.cpp (+2-2)
- (modified) lldb/source/Symbol/Type.cpp (+4-4)
- (modified) lldb/source/Symbol/Variable.cpp (+2-2)
- (modified) lldb/source/Target/DynamicRegisterInfo.cpp (+16-11)
- (modified) lldb/source/Target/ModuleCache.cpp (+12-11)
- (modified) lldb/source/Target/Platform.cpp (+10-8)
- (modified) lldb/source/Target/Process.cpp (+15-13)
- (modified) lldb/source/Target/RegisterContextUnwind.cpp (+7-6)
- (modified) lldb/source/Target/SectionLoadList.cpp (+4-3)
- (modified) lldb/source/Target/StackFrame.cpp (+5-5)
- (modified) lldb/source/Target/StopInfo.cpp (+3-3)
- (modified) lldb/source/Target/Target.cpp (+10-9)
- (modified) lldb/source/Target/Thread.cpp (+5-5)
- (modified) lldb/source/Target/ThreadPlanStepInRange.cpp (+7-7)
- (modified) lldb/source/Target/ThreadPlanStepInstruction.cpp (+1-1)
- (modified) lldb/source/Target/ThreadPlanStepOverRange.cpp (+2-2)
- (modified) lldb/source/Target/Trace.cpp (+1-1)
- (modified) lldb/source/Target/TraceDumper.cpp (+4-3)
- (modified) lldb/source/Utility/Status.cpp (+1-1)
- (modified) lldb/source/ValueObject/DILEval.cpp (+8-8)
- (modified) lldb/source/ValueObject/ValueObject.cpp (+4-4)
- (modified) lldb/source/ValueObject/ValueObjectChild.cpp (+2-1)
- (modified) lldb/source/ValueObject/ValueObjectSynthetic.cpp (+18-15)
- (modified) lldb/tools/lldb-server/lldb-gdbserver.cpp (+3-3)
- (modified) lldb/tools/lldb-server/lldb-platform.cpp (+16-12)
- (modified) lldb/tools/lldb-test/lldb-test.cpp (+1-1)
- (modified) lldb/unittests/Expression/DiagnosticManagerTest.cpp (+1-1)
- (modified) lldb/unittests/Interpreter/TestCommandPaths.cpp (+1-1)
- (modified) lldb/unittests/Platform/Android/AdbClientTest.cpp (+3-2)
- (modified) lldb/unittests/Platform/Android/PlatformAndroidTest.cpp (+5-4)
- (modified) lldb/unittests/Symbol/TestTypeSystemClang.cpp (+1-1)
- (modified) lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp (+1-1)
- (modified) lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp (+3-2)
- (modified) lldb/unittests/Target/ModuleCacheTest.cpp (+1-1)
- (modified) lldb/unittests/Utility/ConstStringTest.cpp (+1-1)
- (modified) lldb/unittests/Utility/StatusTest.cpp (+6-6)
- (modified) lldb/unittests/debugserver/RNBSocketTest.cpp (+5-5)
``````````diff
diff --git a/lldb/include/lldb/DataFormatters/FormattersContainer.h b/lldb/include/lldb/DataFormatters/FormattersContainer.h
index 0761dcfcb12ea..da2db0ed38ecb 100644
--- a/lldb/include/lldb/DataFormatters/FormattersContainer.h
+++ b/lldb/include/lldb/DataFormatters/FormattersContainer.h
@@ -58,7 +58,7 @@ class TypeMatcher {
if (type.IsEmpty())
return type;
- llvm::StringRef type_lexer(type.AsCString());
+ llvm::StringRef type_lexer(type.AsCString(nullptr));
type_lexer.consume_front("class ");
type_lexer.consume_front("enum ");
@@ -104,7 +104,7 @@ class TypeMatcher {
// Skip callback matching in these cases.
if (candidate_type.GetScriptInterpreter())
return candidate_type.GetScriptInterpreter()->FormatterCallbackFunction(
- m_name.AsCString(),
+ m_name.AsCString(nullptr),
std::make_shared<TypeImpl>(candidate_type.GetType()));
}
return false;
diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index c4509206ad753..c732332a75830 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -53,7 +53,7 @@ class SyntheticChildrenFrontEnd {
/// subscripting with TypeOptions::eTypeOptionCustomSubscripting.
virtual llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) {
return llvm::createStringError("Type has no child named '%s'",
- name.AsCString());
+ name.AsCString(nullptr));
}
/// This function is assumed to always succeed and if it fails, the front-end
@@ -121,7 +121,7 @@ class SyntheticValueProviderFrontEnd : public SyntheticChildrenFrontEnd {
llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
return llvm::createStringError("Type has no child named '%s'",
- name.AsCString());
+ name.AsCString(nullptr));
}
lldb::ChildCacheState Update() override {
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index 8ace90927b582..32c94328832c7 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -62,7 +62,7 @@ class ScriptedInterface {
llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
llvm::Twine(error_msg))
.str();
- if (const char *detailed_error = error.AsCString())
+ if (const char *detailed_error = error.AsCString(nullptr))
full_error_message +=
llvm::Twine(llvm::Twine(" (") + llvm::Twine(detailed_error) +
llvm::Twine(")"))
@@ -84,7 +84,7 @@ class ScriptedInterface {
}
if (error.Fail())
- return ErrorWithMessage<bool>(caller, error.AsCString(), error);
+ return ErrorWithMessage<bool>(caller, error.AsCString(nullptr), error);
return true;
}
diff --git a/lldb/include/lldb/Utility/ConstString.h b/lldb/include/lldb/Utility/ConstString.h
index 692ecb63bd763..3d85a14a7ae39 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -178,14 +178,9 @@ class ConstString {
/// Get the string value as a C string.
///
- /// Get the value of the contained string as a NULL terminated C string
- /// value.
- ///
- /// If \a value_if_empty is nullptr, then nullptr will be returned.
- ///
/// \return Returns \a value_if_empty if the string is empty, otherwise
/// the C string value contained in this object.
- const char *AsCString(const char *value_if_empty = nullptr) const {
+ const char *AsCString(const char *value_if_empty) const {
return (IsEmpty() ? value_if_empty : m_string);
}
diff --git a/lldb/source/API/SBAttachInfo.cpp b/lldb/source/API/SBAttachInfo.cpp
index a9f712c79c7fe..df707ef988ed6 100644
--- a/lldb/source/API/SBAttachInfo.cpp
+++ b/lldb/source/API/SBAttachInfo.cpp
@@ -280,7 +280,7 @@ const char *SBAttachInfo::GetScriptedProcessClassName() const {
// Constify this string so that it is saved in the string pool. Otherwise it
// would be freed when this function goes out of scope.
ConstString class_name(metadata_sp->GetClassName().data());
- return class_name.AsCString();
+ return class_name.AsCString(nullptr);
}
void SBAttachInfo::SetScriptedProcessClassName(const char *class_name) {
diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp
index 34323bc5a2c37..ca38ecde9261f 100644
--- a/lldb/source/API/SBCommandInterpreter.cpp
+++ b/lldb/source/API/SBCommandInterpreter.cpp
@@ -526,7 +526,7 @@ const char *SBCommandInterpreter::GetBroadcasterClass() {
LLDB_INSTRUMENT();
return ConstString(CommandInterpreter::GetStaticBroadcasterClass())
- .AsCString();
+ .AsCString(nullptr);
}
const char *SBCommandInterpreter::GetArgumentTypeAsCString(
@@ -661,21 +661,22 @@ SBCommand::operator bool() const {
const char *SBCommand::GetName() {
LLDB_INSTRUMENT_VA(this);
- return (IsValid() ? ConstString(m_opaque_sp->GetCommandName()).AsCString()
- : nullptr);
+ return (IsValid()
+ ? ConstString(m_opaque_sp->GetCommandName()).AsCString(nullptr)
+ : nullptr);
}
const char *SBCommand::GetHelp() {
LLDB_INSTRUMENT_VA(this);
- return (IsValid() ? ConstString(m_opaque_sp->GetHelp()).AsCString()
+ return (IsValid() ? ConstString(m_opaque_sp->GetHelp()).AsCString(nullptr)
: nullptr);
}
const char *SBCommand::GetHelpLong() {
LLDB_INSTRUMENT_VA(this);
- return (IsValid() ? ConstString(m_opaque_sp->GetHelpLong()).AsCString()
+ return (IsValid() ? ConstString(m_opaque_sp->GetHelpLong()).AsCString(nullptr)
: nullptr);
}
diff --git a/lldb/source/API/SBCommunication.cpp b/lldb/source/API/SBCommunication.cpp
index ee33e2abd854e..565b37f52b34a 100644
--- a/lldb/source/API/SBCommunication.cpp
+++ b/lldb/source/API/SBCommunication.cpp
@@ -171,5 +171,5 @@ const char *SBCommunication::GetBroadcasterClass() {
LLDB_INSTRUMENT();
return ConstString(ThreadedCommunication::GetStaticBroadcasterClass())
- .AsCString();
+ .AsCString(nullptr);
}
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index e97fdd0e352f2..4bba1e8ad0e37 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -113,7 +113,7 @@ SBDebugger &SBDebugger::operator=(const SBDebugger &rhs) {
const char *SBDebugger::GetBroadcasterClass() {
LLDB_INSTRUMENT();
- return ConstString(Debugger::GetStaticBroadcasterClass()).AsCString();
+ return ConstString(Debugger::GetStaticBroadcasterClass()).AsCString(nullptr);
}
const char *SBDebugger::GetProgressFromEvent(const lldb::SBEvent &event,
@@ -132,7 +132,7 @@ const char *SBDebugger::GetProgressFromEvent(const lldb::SBEvent &event,
total = progress_data->GetTotal();
is_debugger_specific = progress_data->IsDebuggerSpecific();
ConstString message(progress_data->GetMessage());
- return message.AsCString();
+ return message.AsCString(nullptr);
}
lldb::SBStructuredData
@@ -1269,7 +1269,7 @@ const char *SBDebugger::GetInstanceName() {
if (!m_opaque_sp)
return nullptr;
- return ConstString(m_opaque_sp->GetInstanceName()).AsCString();
+ return ConstString(m_opaque_sp->GetInstanceName()).AsCString(nullptr);
}
SBError SBDebugger::SetInternalVariable(const char *var_name, const char *value,
diff --git a/lldb/source/API/SBEvent.cpp b/lldb/source/API/SBEvent.cpp
index aa9c0ff097d45..9f09ff85e0340 100644
--- a/lldb/source/API/SBEvent.cpp
+++ b/lldb/source/API/SBEvent.cpp
@@ -96,7 +96,7 @@ const char *SBEvent::GetBroadcasterClass() const {
const Event *lldb_event = get();
if (lldb_event)
return ConstString(lldb_event->GetBroadcaster()->GetBroadcasterClass())
- .AsCString();
+ .AsCString(nullptr);
else
return "unknown class";
}
diff --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp
index a7df9afc4b8eb..9ce3602012efd 100644
--- a/lldb/source/API/SBFileSpec.cpp
+++ b/lldb/source/API/SBFileSpec.cpp
@@ -108,7 +108,7 @@ int SBFileSpec::ResolvePath(const char *src_path, char *dst_path,
const char *SBFileSpec::GetFilename() const {
LLDB_INSTRUMENT_VA(this);
- return m_opaque_up->GetFilename().AsCString();
+ return m_opaque_up->GetFilename().AsCString(nullptr);
}
const char *SBFileSpec::GetDirectory() const {
diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index 65b02d6b309ca..752e02dc54713 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/lldb/source/API/SBFunction.cpp
@@ -57,7 +57,7 @@ const char *SBFunction::GetName() const {
LLDB_INSTRUMENT_VA(this);
if (m_opaque_ptr)
- return m_opaque_ptr->GetName().AsCString();
+ return m_opaque_ptr->GetName().AsCString(nullptr);
return nullptr;
}
@@ -66,7 +66,8 @@ const char *SBFunction::GetDisplayName() const {
LLDB_INSTRUMENT_VA(this);
if (m_opaque_ptr)
- return m_opaque_ptr->GetMangled().GetDisplayDemangledName().AsCString();
+ return m_opaque_ptr->GetMangled().GetDisplayDemangledName().AsCString(
+ nullptr);
return nullptr;
}
@@ -75,7 +76,7 @@ const char *SBFunction::GetMangledName() const {
LLDB_INSTRUMENT_VA(this);
if (m_opaque_ptr)
- return m_opaque_ptr->GetMangled().GetMangledName().AsCString();
+ return m_opaque_ptr->GetMangled().GetMangledName().AsCString(nullptr);
return nullptr;
}
@@ -85,7 +86,7 @@ const char *SBFunction::GetBaseName() const {
if (!m_opaque_ptr)
return nullptr;
- return m_opaque_ptr->GetMangled().GetBaseName().AsCString();
+ return m_opaque_ptr->GetMangled().GetBaseName().AsCString(nullptr);
}
bool SBFunction::operator==(const SBFunction &rhs) const {
@@ -105,10 +106,10 @@ bool SBFunction::GetDescription(SBStream &s) {
if (m_opaque_ptr) {
s.Printf("SBFunction: id = 0x%8.8" PRIx64 ", name = %s",
- m_opaque_ptr->GetID(), m_opaque_ptr->GetName().AsCString());
+ m_opaque_ptr->GetID(), m_opaque_ptr->GetName().AsCString(nullptr));
Type *func_type = m_opaque_ptr->GetType();
if (func_type)
- s.Printf(", type = %s", func_type->GetName().AsCString());
+ s.Printf(", type = %s", func_type->GetName().AsCString(nullptr));
return true;
}
s.Printf("No value");
diff --git a/lldb/source/API/SBLanguageRuntime.cpp b/lldb/source/API/SBLanguageRuntime.cpp
index 958652ab6f136..036a5e56e4569 100644
--- a/lldb/source/API/SBLanguageRuntime.cpp
+++ b/lldb/source/API/SBLanguageRuntime.cpp
@@ -56,13 +56,13 @@ bool SBLanguageRuntime::SupportsExceptionBreakpointsOnCatch(
const char *
SBLanguageRuntime::GetThrowKeywordForLanguage(lldb::LanguageType language) {
if (Language *lang_plugin = Language::FindPlugin(language))
- return ConstString(lang_plugin->GetThrowKeyword()).AsCString();
+ return ConstString(lang_plugin->GetThrowKeyword()).AsCString(nullptr);
return nullptr;
}
const char *
SBLanguageRuntime::GetCatchKeywordForLanguage(lldb::LanguageType language) {
if (Language *lang_plugin = Language::FindPlugin(language))
- return ConstString(lang_plugin->GetCatchKeyword()).AsCString();
+ return ConstString(lang_plugin->GetCatchKeyword()).AsCString(nullptr);
return nullptr;
}
diff --git a/lldb/source/API/SBLaunchInfo.cpp b/lldb/source/API/SBLaunchInfo.cpp
index d6b52e8a67a49..07a450dae3771 100644
--- a/lldb/source/API/SBLaunchInfo.cpp
+++ b/lldb/source/API/SBLaunchInfo.cpp
@@ -210,7 +210,8 @@ void SBLaunchInfo::Clear() {
const char *SBLaunchInfo::GetWorkingDirectory() const {
LLDB_INSTRUMENT_VA(this);
- return m_opaque_sp->GetWorkingDirectory().GetPathAsConstString().AsCString();
+ return m_opaque_sp->GetWorkingDirectory().GetPathAsConstString().AsCString(
+ nullptr);
}
void SBLaunchInfo::SetWorkingDirectory(const char *working_dir) {
@@ -249,7 +250,7 @@ const char *SBLaunchInfo::GetShell() {
// Constify this string so that it is saved in the string pool. Otherwise it
// would be freed when this function goes out of scope.
ConstString shell(m_opaque_sp->GetShell().GetPath().c_str());
- return shell.AsCString();
+ return shell.AsCString(nullptr);
}
void SBLaunchInfo::SetShell(const char *path) {
@@ -342,7 +343,7 @@ const char *SBLaunchInfo::GetScriptedProcessClassName() const {
// Constify this string so that it is saved in the string pool. Otherwise it
// would be freed when this function goes out of scope.
ConstString class_name(metadata_sp->GetClassName().data());
- return class_name.AsCString();
+ return class_name.AsCString(nullptr);
}
void SBLaunchInfo::SetScriptedProcessClassName(const char *class_name) {
diff --git a/lldb/source/API/SBMemoryRegionInfo.cpp b/lldb/source/API/SBMemoryRegionInfo.cpp
index cd25be5d52769..7e1a381b6078d 100644
--- a/lldb/source/API/SBMemoryRegionInfo.cpp
+++ b/lldb/source/API/SBMemoryRegionInfo.cpp
@@ -121,7 +121,7 @@ bool SBMemoryRegionInfo::IsMapped() {
const char *SBMemoryRegionInfo::GetName() {
LLDB_INSTRUMENT_VA(this);
- return m_opaque_up->GetName().AsCString();
+ return m_opaque_up->GetName().AsCString(nullptr);
}
bool SBMemoryRegionInfo::HasDirtyMemoryPageList() {
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index c48d1abd88c56..ea0cb2ae356b8 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -684,5 +684,5 @@ const char *SBModule::GetObjectName() const {
if (!m_opaque_sp)
return nullptr;
- return m_opaque_sp->GetObjectName().AsCString();
+ return m_opaque_sp->GetObjectName().AsCString(nullptr);
}
diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index 567744e36829f..15b000cdf3661 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -347,7 +347,7 @@ const char *SBPlatform::GetName() {
PlatformSP platform_sp(GetSP());
if (platform_sp)
- return ConstString(platform_sp->GetName()).AsCString();
+ return ConstString(platform_sp->GetName()).AsCString(nullptr);
return nullptr;
}
@@ -362,7 +362,8 @@ const char *SBPlatform::GetWorkingDirectory() {
PlatformSP platform_sp(GetSP());
if (platform_sp)
- return platform_sp->GetWorkingDirectory().GetPathAsConstString().AsCString();
+ return platform_sp->GetWorkingDirectory().GetPathAsConstString().AsCString(
+ nullptr);
return nullptr;
}
diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp
index 14aa9432eed83..14ce236b4f1b5 100644
--- a/lldb/source/API/SBProcess.cpp
+++ b/lldb/source/API/SBProcess.cpp
@@ -81,7 +81,7 @@ SBProcess::~SBProcess() = default;
const char *SBProcess::GetBroadcasterClassName() {
LLDB_INSTRUMENT();
- return ConstString(Process::GetStaticBroadcasterClass()).AsCString();
+ return ConstString(Process::GetStaticBroadcasterClass()).AsCString(nullptr);
}
const char *SBProcess::GetPluginName() {
@@ -824,7 +824,7 @@ SBBroadcaster SBProcess::GetBroadcaster() const {
const char *SBProcess::GetBroadcasterClass() {
LLDB_INSTRUMENT();
- return ConstString(Process::GetStaticBroadcasterClass()).AsCString();
+ return ConstString(Process::GetStaticBroadcasterClass()).AsCString(nullptr);
}
lldb::SBAddressRangeList SBProcess::FindRangesInMemory(
@@ -1014,7 +1014,7 @@ bool SBProcess::GetDescription(SBStream &description) {
Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer();
const char *exe_name = nullptr;
if (exe_module)
- exe_name = exe_module->GetFileSpec().GetFilename().AsCString();
+ exe_name = exe_module->GetFileSpec().GetFilename().AsCString(nullptr);
strm.Printf("SBProcess: pid = %" PRIu64 ", state = %s, threads = %d%s%s",
process_sp->GetID(), lldb_private::StateAsCString(GetState()),
@@ -1196,7 +1196,7 @@ const char *SBProcess::GetExtendedBacktraceTypeAtIndex(uint32_t idx) {
const std::vector<ConstString> &names =
runtime->GetExtendedBacktraceTypes();
if (idx < names.size()) {
- return names[idx].AsCString();
+ return names[idx].AsCString(nullptr);
}
}
return nullptr;
diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp
index bbaf074295b89..19f2f5e62fd48 100644
--- a/lldb/source/API/SBSymbol.cpp
+++ b/lldb/source/API/SBSymbol.cpp
@@ -55,7 +55,7 @@ const char *SBSymbol::GetName() const {
const char *name = nullptr;
if (m_opaque_ptr)
- name = m_opaque_ptr->GetName().AsCString();
+ name = m_opaque_ptr->GetName().AsCString(nullptr);
return name;
}
@@ -65,7 +65,8 @@ const char *SBSymbol::GetDisplayName() const {
const char *name = nullptr;
if (m_opaque_ptr)
- name = m_opaque_ptr->GetMangled().GetDisplayDemangledName().AsCString();
+ name =
+ m_opaque_ptr->GetMangled().GetDisplayDemangledName().AsCString(nullptr);
return name;
}
@@ -75,7 +76,7 @@ const char *SBSymbol::GetMangledName() const {
const char *name = nullptr;
if (m_opaque_ptr)
- name = m_opaque_ptr->GetMangled().GetMangledName().AsCString();
+ name = m_opaque_ptr->GetMangled().GetMangledName().AsCString(nullptr);
return name;
}
@@ -85,7 +86,7 @@ const char *SBSymbol::GetBaseName() const {
if (!m_opaque_ptr)
return nullptr;
- return m_opaque_ptr->GetMangled().GetBaseName().AsCString();
+ return m_opaque_ptr->GetMangled().GetBaseName().AsCString(nullptr);
}
bool SBSymbol::operator==(const SBSymbol &rhs) const {
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 32046802c5ce7..fd35208196781 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -158,7 +158,7 @@ SBModule SBTarget::GetModuleAtIndexFromEvent(const uint32_t idx,
const char *SBTarget::GetBroadcasterClassName() {
LLDB_INSTRUMENT();
- return ConstString(Target::GetStaticBroadcasterClass()).AsCString();
+ return ConstString(Target::GetStaticBroadcasterClass()).AsCString(nullptr);
}
bool SBTarget::IsValid() const {
@@ -1652,7 +1652,7 @@ const char *SBTarget::GetLabel() const {
LLDB_INSTRUMENT_VA(this);
if (TargetSP target_sp = GetSP())
- return ConstString(target_sp->GetLabel().data()).AsCString();
+ return ConstString(target_sp->GetLabel().data()).AsCString(nullptr);
return nullptr;
}
@@ -1668,7 +1668,7 @@ const char *SBTarget::GetTargetSessionName() const {
LLDB_INSTRUMENT_VA(this);
if (TargetSP target_sp = GetSP())
- return ConstString(target_sp->GetTargetSessionName()).AsCString();
+ return ConstString(target_sp->GetTargetSessionName()).AsCString(nullptr);
return nullptr;
}
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index 9efc39c70d1a4..e3a8ee6950ed5 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -54,7 +54,7 @@ using namespace lldb_private;
const char *SBThread::GetBroadcasterClassName() {
LLDB_INSTRUMENT();
- return ConstString(Thread::GetStaticBroadcasterClass()).AsCString();
+ return ConstString(Thread::GetStaticBroadcasterClass()).AsCString(nullptr);
}
// Constructors
@@ -579,7 +579,7 @@ void SBThread::StepInto(const char *target_name, uint32_t end_line,
if (new_plan_status.Success())
error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
else
- error = Status::FromErrorString(new_plan_status.AsCString());
+ error = Status::FromErrorString(new_plan_status.AsCString(nullptr));
}
void SBThread::StepOut() {
@@ -618,7 +618,7 @@ void SBThread::StepOut(SBError &error) {
if (new_plan_status.Success())
error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
else
- error = Status::FromErrorString(new_plan_status.AsCString());
+ error = Status::FromErrorString(new_plan_status.AsCString(nullptr));
}
void SBThread::StepOutOfFrame(SBFrame &sb_frame) {
@@ -666,7 +666,7 @@ void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) {
if (new_plan_status.Success())
error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
else
- error = Status::FromErrorString(new_plan_status.AsCString());
+ error = Status::FromErrorString(new_plan_status.AsCString(nullptr));
}
void SBThread::StepInstruction(bool step_over) {
@@ -699...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/190183
More information about the lldb-commits
mailing list