Use StringRef in Registry API (NFC)

llvm-svn: 283039
This commit is contained in:
Mehdi Amini 2016-10-01 15:44:54 +00:00
parent ae17cf20ce
commit 7410717a62
3 changed files with 9 additions and 10 deletions

View File

@ -49,7 +49,7 @@ CompilationDatabase::loadFromDirectory(StringRef BuildDirectory,
if (std::unique_ptr<CompilationDatabase> DB =
Plugin->loadFromDirectory(BuildDirectory, DatabaseErrorMessage))
return DB;
ErrorStream << It->getName() << ": " << DatabaseErrorMessage << "\n";
ErrorStream << It->getName().data() << ": " << DatabaseErrorMessage << "\n";
}
ErrorMessage = ErrorStream.str();
return nullptr;

View File

@ -25,16 +25,15 @@ namespace llvm {
/// no-argument constructor.
template <typename T>
class SimpleRegistryEntry {
const char *Name, *Desc;
StringRef Name, Desc;
std::unique_ptr<T> (*Ctor)();
public:
SimpleRegistryEntry(const char *N, const char *D, std::unique_ptr<T> (*C)())
: Name(N), Desc(D), Ctor(C)
{}
SimpleRegistryEntry(StringRef N, StringRef D, std::unique_ptr<T> (*C)())
: Name(N), Desc(D), Ctor(C) {}
const char *getName() const { return Name; }
const char *getDesc() const { return Desc; }
StringRef getName() const { return Name; }
StringRef getDesc() const { return Desc; }
std::unique_ptr<T> instantiate() const { return Ctor(); }
};
@ -119,7 +118,7 @@ namespace llvm {
static std::unique_ptr<T> CtorFn() { return make_unique<V>(); }
public:
Add(const char *Name, const char *Desc)
Add(StringRef Name, StringRef Desc)
: Entry(Name, Desc, CtorFn), Node(Entry) {
add_node(&Node);
}

View File

@ -2575,12 +2575,12 @@ GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy &S) {
if (GCPI != GCMap.end())
return GCPI->second.get();
const char *Name = S.getName().c_str();
auto Name = S.getName();
for (GCMetadataPrinterRegistry::iterator
I = GCMetadataPrinterRegistry::begin(),
E = GCMetadataPrinterRegistry::end(); I != E; ++I)
if (strcmp(Name, I->getName()) == 0) {
if (Name == I->getName()) {
std::unique_ptr<GCMetadataPrinter> GMP = I->instantiate();
GMP->S = &S;
auto IterBool = GCMap.insert(std::make_pair(&S, std::move(GMP)));