[llvm] r283017 - Use StringRef instead of raw pointer in TargetRegistry API (NFC)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 30 23:25:30 PDT 2016
Author: mehdi_amini
Date: Sat Oct 1 01:25:30 2016
New Revision: 283017
URL: http://llvm.org/viewvc/llvm-project?rev=283017&view=rev
Log:
Use StringRef instead of raw pointer in TargetRegistry API (NFC)
Modified:
llvm/trunk/include/llvm/Support/TargetRegistry.h
llvm/trunk/lib/Support/TargetRegistry.cpp
llvm/trunk/lib/Target/TargetMachineC.cpp
llvm/trunk/tools/llc/llc.cpp
Modified: llvm/trunk/include/llvm/Support/TargetRegistry.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetRegistry.h?rev=283017&r1=283016&r2=283017&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/TargetRegistry.h (original)
+++ llvm/trunk/include/llvm/Support/TargetRegistry.h Sat Oct 1 01:25:30 2016
@@ -165,10 +165,10 @@ private:
ArchMatchFnTy ArchMatchFn;
/// Name - The target name.
- const char *Name;
+ StringRef Name;
/// ShortDesc - A short description of the target.
- const char *ShortDesc;
+ StringRef ShortDesc;
/// HasJIT - Whether this target supports the JIT.
bool HasJIT;
@@ -262,10 +262,10 @@ public:
const Target *getNext() const { return Next; }
/// getName - Get the target name.
- const char *getName() const { return Name; }
+ StringRef getName() const { return Name; }
/// getShortDescription - Get a short description of the target.
- const char *getShortDescription() const { return ShortDesc; }
+ StringRef getShortDescription() const { return ShortDesc; }
/// @}
/// @name Feature Predicates
@@ -624,7 +624,7 @@ struct TargetRegistry {
/// @param ArchMatchFn - The arch match checking function for this target.
/// @param HasJIT - Whether the target supports JIT code
/// generation.
- static void RegisterTarget(Target &T, const char *Name, const char *ShortDesc,
+ static void RegisterTarget(Target &T, StringRef Name, StringRef ShortDesc,
Target::ArchMatchFnTy ArchMatchFn,
bool HasJIT = false);
@@ -857,7 +857,7 @@ struct TargetRegistry {
template <Triple::ArchType TargetArchType = Triple::UnknownArch,
bool HasJIT = false>
struct RegisterTarget {
- RegisterTarget(Target &T, const char *Name, const char *Desc) {
+ RegisterTarget(Target &T, StringRef Name, StringRef Desc) {
TargetRegistry::RegisterTarget(T, Name, Desc, &getArchMatch, HasJIT);
}
Modified: llvm/trunk/lib/Support/TargetRegistry.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/TargetRegistry.cpp?rev=283017&r1=283016&r2=283017&view=diff
==============================================================================
--- llvm/trunk/lib/Support/TargetRegistry.cpp (original)
+++ llvm/trunk/lib/Support/TargetRegistry.cpp Sat Oct 1 01:25:30 2016
@@ -78,8 +78,8 @@ const Target *TargetRegistry::lookupTarg
auto J = std::find_if(std::next(I), targets().end(), ArchMatch);
if (J != targets().end()) {
- Error = std::string("Cannot choose between targets \"") + I->Name +
- "\" and \"" + J->Name + "\"";
+ Error = ("Cannot choose between targets \"" + I->Name +
+ "\" a nd \"" + J->Name + "\"").str();
return nullptr;
}
@@ -87,16 +87,16 @@ const Target *TargetRegistry::lookupTarg
}
void TargetRegistry::RegisterTarget(Target &T,
- const char *Name,
- const char *ShortDesc,
+ StringRef Name,
+ StringRef ShortDesc,
Target::ArchMatchFnTy ArchMatchFn,
bool HasJIT) {
- assert(Name && ShortDesc && ArchMatchFn &&
+ assert(!Name.empty() && !ShortDesc.empty() && ArchMatchFn &&
"Missing required target information!");
// Check if this target has already been initialized, we allow this as a
// convenience to some clients.
- if (T.Name)
+ if (!T.Name.empty())
return;
// Add to the list of targets.
Modified: llvm/trunk/lib/Target/TargetMachineC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachineC.cpp?rev=283017&r1=283016&r2=283017&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetMachineC.cpp (original)
+++ llvm/trunk/lib/Target/TargetMachineC.cpp Sat Oct 1 01:25:30 2016
@@ -81,11 +81,11 @@ LLVMBool LLVMGetTargetFromTriple(const c
}
const char * LLVMGetTargetName(LLVMTargetRef T) {
- return unwrap(T)->getName();
+ return unwrap(T)->getName().data();
}
const char * LLVMGetTargetDescription(LLVMTargetRef T) {
- return unwrap(T)->getShortDescription();
+ return unwrap(T)->getShortDescription().data();
}
LLVMBool LLVMTargetHasJIT(LLVMTargetRef T) {
Modified: llvm/trunk/tools/llc/llc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=283017&r1=283016&r2=283017&view=diff
==============================================================================
--- llvm/trunk/tools/llc/llc.cpp (original)
+++ llvm/trunk/tools/llc/llc.cpp Sat Oct 1 01:25:30 2016
@@ -159,7 +159,7 @@ static cl::opt<RunPassOption, true, cl::
static int compileModule(char **, LLVMContext &);
static std::unique_ptr<tool_output_file>
-GetOutputStream(const char *TargetName, Triple::OSType OS,
+GetOutputStream(StringRef TargetName, Triple::OSType OS,
const char *ProgName) {
// If we don't yet have an output filename, make one.
if (OutputFilename.empty()) {
More information about the llvm-commits
mailing list