Skip to content

Commit 2278c19

Browse files
committed
Change API to str(N)
1 parent d6878b1 commit 2278c19

File tree

18 files changed

+119
-114
lines changed

18 files changed

+119
-114
lines changed

lldb/source/API/SBDebugger.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,9 @@ 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().clone(true, false).str();
645+
const llvm::StringRef triple_str = default_arch.GetTriple().str(4);
646646
if (!triple_str.empty())
647-
::snprintf(arch_name, arch_name_len, "%s", triple_str.c_str());
647+
::snprintf(arch_name, arch_name_len, "%s", triple_str.str().c_str());
648648
else
649649
::snprintf(arch_name, arch_name_len, "%s",
650650
default_arch.GetArchitectureName());

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().clone(true, false).str());
579+
std::string triple(module_sp->GetArchitecture().GetTriple().str(4));
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().clone(true, false).str());
115+
std::string triple(m_opaque_up->GetArchitecture().GetTriple().str(4));
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().clone(true, false).str());
1579+
std::string triple(target_sp->GetArchitecture().GetTriple().str(4));
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().clone(true, false).str() << '-' << m_file.GetPath();
1615+
id_strm << m_arch.GetTriple().str(4) << '-' << 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().clone(true, false).str() << '-' << m_file.GetFilename();
1629+
strm << m_arch.GetTriple().str(4) << '-' << 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: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,12 @@ DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress(lldb::addr_t addr,
494494
} else {
495495
uuid_str = "and no LC_UUID found in load commands ";
496496
}
497-
LLDB_LOGF(
498-
log,
499-
"DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress: "
500-
"kernel binary image found at 0x%" PRIx64 " with arch '%s' %s",
501-
addr, kernel_arch.GetTriple().clone(true, false).str().c_str(), uuid_str.c_str());
497+
LLDB_LOGF(log,
498+
"DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress: "
499+
"kernel binary image found at 0x%" PRIx64
500+
" with arch '%s' %s",
501+
addr, kernel_arch.GetTriple().str(4).str().c_str(),
502+
uuid_str.c_str());
502503
}
503504
return memory_module_sp->GetUUID();
504505
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ 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().clone(true, false).str().c_str(), uuid_str.c_str());
239+
addr, kernel_arch.GetTriple().str(4),
240+
uuid_str.c_str());
240241

241242
return memory_module_sp->GetUUID();
242243
}

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().clone(true, false).str();
512+
std::string triple(target_arch.GetTriple().str(4));
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().clone(true, false).str(),
662+
arch.GetTriple().str(4).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: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ 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.clone(true, false).str().empty()) {
39-
paths.push_back("/usr/include/" + triple.clone(true, false).str());
38+
llvm::StringRef triple_no_objfmt = triple.str(4);
39+
if (!triple_no_objfmt.empty()) {
40+
paths.push_back(("/usr/include/" + triple_no_objfmt).str());
4041
if (!triple.getArchName().empty() ||
4142
triple.getOSAndEnvironmentName().empty())
4243
paths.push_back(("/usr/include/" + triple.getArchName() + "-" +
@@ -75,13 +76,14 @@ bool CppModuleConfiguration::analyzeFile(const FileSpec &f,
7576
parent_path(posix_dir, Style::posix).ends_with("c++")) {
7677
if (!m_std_inc.TrySet(posix_dir))
7778
return false;
78-
if (triple.clone(true, false).str().empty())
79+
llvm::StringRef triple_no_objfmt = triple.str(4);
80+
if (triple_no_objfmt.empty())
7981
return true;
8082

8183
posix_dir.consume_back("c++/v1");
8284
// Check if this is a target-specific libc++ include directory.
8385
return m_std_target_inc.TrySet(
84-
(posix_dir + triple.clone(true, false).str() + "/c++/v1").str());
86+
(posix_dir + triple_no_objfmt + "/c++/v1").str());
8587
}
8688

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

0 commit comments

Comments
 (0)