[llvm] 5a1de14 - Replace `const std::string&` with StringRef in TargetRegistry APIs; NFC
Aaron Ballman via llvm-commits
llvm-commits at lists.llvm.org
Sun May 21 06:52:55 PDT 2023
Author: Ondrej Sykora
Date: 2023-05-21T09:52:21-04:00
New Revision: 5a1de140677e9138625135514fc4ed0dc969d80c
URL: https://github.com/llvm/llvm-project/commit/5a1de140677e9138625135514fc4ed0dc969d80c
DIFF: https://github.com/llvm/llvm-project/commit/5a1de140677e9138625135514fc4ed0dc969d80c.diff
LOG: Replace `const std::string&` with StringRef in TargetRegistry APIs; NFC
Differential Revision: https://reviews.llvm.org/D147592
Added:
Modified:
llvm/include/llvm/MC/TargetRegistry.h
llvm/lib/MC/TargetRegistry.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/TargetRegistry.h b/llvm/include/llvm/MC/TargetRegistry.h
index d9ecd21d03d16..3d44eaa34fbd8 100644
--- a/llvm/include/llvm/MC/TargetRegistry.h
+++ b/llvm/include/llvm/MC/TargetRegistry.h
@@ -791,8 +791,7 @@ struct TargetRegistry {
/// \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 @@ struct TargetRegistry {
/// 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
diff --git a/llvm/lib/MC/TargetRegistry.cpp b/llvm/lib/MC/TargetRegistry.cpp
index b54853a6e0d74..fa7aaccabcd61 100644
--- a/llvm/lib/MC/TargetRegistry.cpp
+++ b/llvm/lib/MC/TargetRegistry.cpp
@@ -21,7 +21,7 @@ iterator_range<TargetRegistry::iterator> TargetRegistry::targets() {
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 *TargetRegistry::lookupTarget(const std::string &ArchName,
[&](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 @@ const Target *TargetRegistry::lookupTarget(const std::string &ArchName,
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 @@ const Target *TargetRegistry::lookupTarget(const std::string &TT,
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;
}
More information about the llvm-commits
mailing list