================ @@ -463,6 +463,27 @@ class Triple { const std::string &str() const { return Data; } + /// Return the triple string but only keep the first \p N components. + /// + /// The returned string will preserve the first \p N components exactly the + /// same as the original (including the leading "-" and the value, empty or + /// not). + /// + /// E.g. Triple("arm64-apple-ios").str(5) == "arm64-apple-ios" + /// E.g. Triple("arm64-apple-ios--").str(5) == "arm64-apple-ios--" + /// E.g. Triple("arm64-apple-ios--").str(4) == "arm64-apple-ios-" + /// E.g. Triple("arm64-apple-ios--").str(3) == "arm64-apple-ios" + /// E.g. Triple("arm64-apple-ios--").str(2) == "arm64-apple" + /// E.g. Triple("arm64-apple-ios--").str(1) == "arm64" + /// E.g. Triple("arm64-apple-ios--").str(0) == "" + /// + /// This method does not normalize any triple strings. Clients that need to + /// handle the non-canonical triples that users often specify should use the + /// normalize method. + /// + /// \returns the (shorterned) triple string. + StringRef str(size_t N) const; ---------------- dmpots wrote:
It looks like we already have this capability in the `normalize` method https://github.com/llvm/llvm-project/blob/3ea1296b3724ec5c05f616c98dd883b54b672ff9/llvm/include/llvm/TargetParser/Triple.h#L388 For the use cases in this PR we could do `triple.normalize(CanonicalForm::FOUR_IDENT)` https://github.com/llvm/llvm-project/pull/145157 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits