[clang] [lldb] [llvm] [lldb] Fix object format in the Triple of Mach-O files (approach 4) (PR #145157)

David Peixotto via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 27 17:04:35 PDT 2025


================
@@ -642,9 +642,9 @@ bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) {
     ArchSpec default_arch = Target::GetDefaultArchitecture();
 
     if (default_arch.IsValid()) {
-      const std::string &triple_str = default_arch.GetTriple().str();
+      const llvm::StringRef triple_str = default_arch.GetTriple().str(4);
----------------
dmpots wrote:

I think it would be good to add a couple of methods to `ArchSpec` so that we have a single place that specifies how we format the triple.

```
class ArchSpec {
    ...
    static std::string GetTripleStr(const llvm::Triple &triple) {
        return triple.normalize(CanonicalForm::FOUR_IDENT);
    }
    
    std::string GetTripleStr() {
        return GetTripleStr(GetTriple());
    }
};
```

Then if we have an `ArchSpec` we can just call the `GetTripleStr()` function on it and if we just have the `Triple` we can still use the static version.

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


More information about the llvm-commits mailing list