diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp index 6f95bf01f690..614870e2f285 100644 --- a/clang/lib/Tooling/CompilationDatabase.cpp +++ b/clang/lib/Tooling/CompilationDatabase.cpp @@ -49,7 +49,7 @@ CompilationDatabase::loadFromDirectory(StringRef BuildDirectory, if (std::unique_ptr DB = Plugin->loadFromDirectory(BuildDirectory, DatabaseErrorMessage)) return DB; - ErrorStream << It->getName() << ": " << DatabaseErrorMessage << "\n"; + ErrorStream << It->getName().data() << ": " << DatabaseErrorMessage << "\n"; } ErrorMessage = ErrorStream.str(); return nullptr; diff --git a/llvm/include/llvm/Support/Registry.h b/llvm/include/llvm/Support/Registry.h index 5d08629749a6..810712a6bf2e 100644 --- a/llvm/include/llvm/Support/Registry.h +++ b/llvm/include/llvm/Support/Registry.h @@ -25,16 +25,15 @@ namespace llvm { /// no-argument constructor. template class SimpleRegistryEntry { - const char *Name, *Desc; + StringRef Name, Desc; std::unique_ptr (*Ctor)(); public: - SimpleRegistryEntry(const char *N, const char *D, std::unique_ptr (*C)()) - : Name(N), Desc(D), Ctor(C) - {} + SimpleRegistryEntry(StringRef N, StringRef D, std::unique_ptr (*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 instantiate() const { return Ctor(); } }; @@ -119,7 +118,7 @@ namespace llvm { static std::unique_ptr CtorFn() { return make_unique(); } public: - Add(const char *Name, const char *Desc) + Add(StringRef Name, StringRef Desc) : Entry(Name, Desc, CtorFn), Node(Entry) { add_node(&Node); } diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 27b69c1e21e9..e24aca754997 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -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 GMP = I->instantiate(); GMP->S = &S; auto IterBool = GCMap.insert(std::make_pair(&S, std::move(GMP)));