[Lldb-commits] [lldb] [lldb] [scripting bridge] 167388 chore: add api to return arch name for target (PR #168273)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Sun Nov 16 10:36:26 PST 2025


================
@@ -1614,6 +1614,19 @@ const char *SBTarget::GetTriple() {
   return nullptr;
 }
 
+const char *SBTarget::GetArchName() {
+  LLDB_INSTRUMENT_VA(this);
+
+  if (TargetSP target_sp = GetSP()) {
+    std::string arch_name =
+        target_sp->GetArchitecture().GetTriple().getArchName().str();
+    ConstString const_arch_name(arch_name.c_str());
----------------
JDevlieghere wrote:

There's no need to allocate a temporary `std::string` here, `getArchName` returns a StringRef that you can pass directly to the `ConstString` ctor.
```suggestion
    llvm::StringRef arch_name =
        target_sp->GetArchitecture().GetTriple().getArchName();
    ConstString const_arch_name(arch_name);
```

https://github.com/llvm/llvm-project/pull/168273


More information about the lldb-commits mailing list