[PATCH] D147592: NFC: Replace `const std::string&` with StringRef in TargetRegistry APIs.
Ondrej Sykora via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat May 20 07:56:40 PDT 2023
ondrasej updated this revision to Diff 524035.
ondrasej added a comment.
Rebased to a more recent revision, and amended the commit description as requested.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147592/new/
https://reviews.llvm.org/D147592
Files:
llvm/include/llvm/MC/TargetRegistry.h
llvm/lib/MC/TargetRegistry.cpp
Index: llvm/lib/MC/TargetRegistry.cpp
===================================================================
--- llvm/lib/MC/TargetRegistry.cpp
+++ llvm/lib/MC/TargetRegistry.cpp
@@ -21,7 +21,7 @@
return make_range(iterator(FirstTarget), iterator());
}
-const Target *TargetRegistry::lookupTarget(const std::string &ArchName,
+const Target *TargetRegistry::lookupTarget(StringRef ArchName,
Triple &TheTriple,
std::string &Error) {
// Allocate target machine. First, check whether the user has explicitly
@@ -33,7 +33,7 @@
[&](const Target &T) { return ArchName == T.getName(); });
if (I == targets().end()) {
- Error = "invalid target '" + ArchName + "'.\n";
+ Error = ("invalid target '" + ArchName + "'.\n").str();
return nullptr;
}
@@ -59,8 +59,7 @@
return TheTarget;
}
-const Target *TargetRegistry::lookupTarget(const std::string &TT,
- std::string &Error) {
+const Target *TargetRegistry::lookupTarget(StringRef TT, std::string &Error) {
// Provide special warning when no targets are initialized.
if (targets().begin() == targets().end()) {
Error = "Unable to find target for this triple (no targets are registered)";
@@ -71,7 +70,8 @@
auto I = find_if(targets(), ArchMatch);
if (I == targets().end()) {
- Error = "No available targets are compatible with triple \"" + TT + "\"";
+ Error = ("No available targets are compatible with triple \"" + TT + "\"")
+ .str();
return nullptr;
}
Index: llvm/include/llvm/MC/TargetRegistry.h
===================================================================
--- llvm/include/llvm/MC/TargetRegistry.h
+++ llvm/include/llvm/MC/TargetRegistry.h
@@ -791,8 +791,7 @@
/// \param Triple - The triple to use for finding a target.
/// \param Error - On failure, an error string describing why no target was
/// found.
- static const Target *lookupTarget(const std::string &Triple,
- std::string &Error);
+ static const Target *lookupTarget(StringRef Triple, std::string &Error);
/// lookupTarget - Lookup a target based on an architecture name
/// and a target triple. If the architecture name is non-empty,
@@ -805,8 +804,8 @@
/// by architecture is done.
/// \param Error - On failure, an error string describing why no target was
/// found.
- static const Target *lookupTarget(const std::string &ArchName,
- Triple &TheTriple, std::string &Error);
+ static const Target *lookupTarget(StringRef ArchName, Triple &TheTriple,
+ std::string &Error);
/// @}
/// @name Target Registration
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147592.524035.patch
Type: text/x-patch
Size: 2814 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230520/067e1139/attachment.bin>
More information about the llvm-commits
mailing list