Skip to content

Commit d6878b1

Browse files
committed
Implement clone and update lldb files
1 parent d2514d7 commit d6878b1

File tree

18 files changed

+160
-24
lines changed

18 files changed

+160
-24
lines changed

lldb/source/API/SBDebugger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) {
642642
ArchSpec default_arch = Target::GetDefaultArchitecture();
643643

644644
if (default_arch.IsValid()) {
645-
const std::string &triple_str = default_arch.GetTriple().str(false);
645+
const std::string &triple_str = default_arch.GetTriple().clone(true, false).str();
646646
if (!triple_str.empty())
647647
::snprintf(arch_name, arch_name_len, "%s", triple_str.c_str());
648648
else

lldb/source/API/SBModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ const char *SBModule::GetTriple() {
576576
if (!module_sp)
577577
return nullptr;
578578

579-
std::string triple(module_sp->GetArchitecture().GetTriple().str(false));
579+
std::string triple(module_sp->GetArchitecture().GetTriple().clone(true, false).str());
580580
// Unique the string so we don't run into ownership issues since the const
581581
// strings put the string into the string pool once and the strings never
582582
// comes out

lldb/source/API/SBModuleSpec.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void SBModuleSpec::SetObjectName(const char *name) {
112112
const char *SBModuleSpec::GetTriple() {
113113
LLDB_INSTRUMENT_VA(this);
114114

115-
std::string triple(m_opaque_up->GetArchitecture().GetTriple().str(false));
115+
std::string triple(m_opaque_up->GetArchitecture().GetTriple().clone(true, false).str());
116116
// Unique the string so we don't run into ownership issues since the const
117117
// strings put the string into the string pool once and the strings never
118118
// comes out

lldb/source/API/SBTarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,7 @@ const char *SBTarget::GetTriple() {
15761576
LLDB_INSTRUMENT_VA(this);
15771577

15781578
if (TargetSP target_sp = GetSP()) {
1579-
std::string triple(target_sp->GetArchitecture().GetTriple().str(false));
1579+
std::string triple(target_sp->GetArchitecture().GetTriple().clone(true, false).str());
15801580
// Unique the string so we don't run into ownership issues since the const
15811581
// strings put the string into the string pool once and the strings never
15821582
// comes out

lldb/source/Core/Module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,7 @@ bool Module::GetIsDynamicLinkEditor() {
16121612
uint32_t Module::Hash() {
16131613
std::string identifier;
16141614
llvm::raw_string_ostream id_strm(identifier);
1615-
id_strm << m_arch.GetTriple().str(false) << '-' << m_file.GetPath();
1615+
id_strm << m_arch.GetTriple().clone(true, false).str() << '-' << m_file.GetPath();
16161616
if (m_object_name)
16171617
id_strm << '(' << m_object_name << ')';
16181618
if (m_object_offset > 0)
@@ -1626,7 +1626,7 @@ uint32_t Module::Hash() {
16261626
std::string Module::GetCacheKey() {
16271627
std::string key;
16281628
llvm::raw_string_ostream strm(key);
1629-
strm << m_arch.GetTriple().str(false) << '-' << m_file.GetFilename();
1629+
strm << m_arch.GetTriple().clone(true, false).str() << '-' << m_file.GetFilename();
16301630
if (m_object_name)
16311631
strm << '(' << m_object_name << ')';
16321632
strm << '-' << llvm::format_hex(Hash(), 10);

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress(lldb::addr_t addr,
498498
log,
499499
"DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress: "
500500
"kernel binary image found at 0x%" PRIx64 " with arch '%s' %s",
501-
addr, kernel_arch.GetTriple().str(false).c_str(), uuid_str.c_str());
501+
addr, kernel_arch.GetTriple().clone(true, false).str().c_str(), uuid_str.c_str());
502502
}
503503
return memory_module_sp->GetUUID();
504504
}

lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ lldb_private::UUID DynamicLoaderFreeBSDKernel::CheckForKernelImageAtAddress(
236236
LLDB_LOGF(log,
237237
"DynamicLoaderFreeBSDKernel::CheckForKernelImageAtAddress: "
238238
"kernel binary image found at 0x%" PRIx64 " with arch '%s' %s",
239-
addr, kernel_arch.GetTriple().str(false).c_str(), uuid_str.c_str());
239+
addr, kernel_arch.GetTriple().clone(true, false).str().c_str(), uuid_str.c_str());
240240

241241
return memory_module_sp->GetUUID();
242242
}

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ static void SetupTargetOpts(CompilerInstance &compiler,
509509

510510
const auto target_machine = target_arch.GetMachine();
511511
if (target_arch.IsValid()) {
512-
std::string triple = target_arch.GetTriple().str(false);
512+
std::string triple = target_arch.GetTriple().clone(true, false).str();
513513
compiler.getTargetOpts().Triple = triple;
514514
LLDB_LOGF(log, "Using %s as the target triple",
515515
compiler.getTargetOpts().Triple.c_str());

lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ ClangModulesDeclVendor::Create(Target &target) {
659659
"-fsyntax-only",
660660
"-femit-all-decls",
661661
"-target",
662-
arch.GetTriple().str(false),
662+
arch.GetTriple().clone(true, false).str(),
663663
"-fmodules-validate-system-headers",
664664
"-Werror=non-modular-include-in-framework-module",
665665
"-Xclang=-fincremental-extensions",

lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ bool CppModuleConfiguration::SetOncePath::TrySet(llvm::StringRef path) {
3535
static llvm::SmallVector<std::string, 2>
3636
getTargetIncludePaths(const llvm::Triple &triple) {
3737
llvm::SmallVector<std::string, 2> paths;
38-
if (!triple.str(false).empty()) {
39-
paths.push_back("/usr/include/" + triple.str(false));
38+
if (!triple.clone(true, false).str().empty()) {
39+
paths.push_back("/usr/include/" + triple.clone(true, false).str());
4040
if (!triple.getArchName().empty() ||
4141
triple.getOSAndEnvironmentName().empty())
4242
paths.push_back(("/usr/include/" + triple.getArchName() + "-" +
@@ -75,13 +75,13 @@ bool CppModuleConfiguration::analyzeFile(const FileSpec &f,
7575
parent_path(posix_dir, Style::posix).ends_with("c++")) {
7676
if (!m_std_inc.TrySet(posix_dir))
7777
return false;
78-
if (triple.str(false).empty())
78+
if (triple.clone(true, false).str().empty())
7979
return true;
8080

8181
posix_dir.consume_back("c++/v1");
8282
// Check if this is a target-specific libc++ include directory.
8383
return m_std_target_inc.TrySet(
84-
(posix_dir + triple.str(false) + "/c++/v1").str());
84+
(posix_dir + triple.clone(true, false).str() + "/c++/v1").str());
8585
}
8686

8787
std::optional<llvm::StringRef> inc_path;

0 commit comments

Comments
 (0)