1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

Make llvm::StringRef to std::string conversions explicit.

This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.

This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.

This doesn't actually modify StringRef yet, I'll do that in a follow-up.
This commit is contained in:
Benjamin Kramer 2020-01-28 20:23:46 +01:00
parent c32dde6058
commit 87d13166c7
348 changed files with 1088 additions and 998 deletions

View File

@ -272,9 +272,7 @@ namespace llvm {
/// @name Type Conversions /// @name Type Conversions
/// @{ /// @{
operator std::string() const { operator std::string() const { return str(); }
return str();
}
#if __cplusplus > 201402L #if __cplusplus > 201402L
operator std::string_view() const { operator std::string_view() const {

View File

@ -1375,7 +1375,7 @@ struct BFIDOTGraphTraitsBase : public DefaultDOTGraphTraits {
explicit BFIDOTGraphTraitsBase(bool isSimple = false) explicit BFIDOTGraphTraitsBase(bool isSimple = false)
: DefaultDOTGraphTraits(isSimple) {} : DefaultDOTGraphTraits(isSimple) {}
static std::string getGraphName(const BlockFrequencyInfoT *G) { static StringRef getGraphName(const BlockFrequencyInfoT *G) {
return G->getFunction()->getName(); return G->getFunction()->getName();
} }

View File

@ -236,7 +236,7 @@ std::string RegionBase<Tr>::getNameStr() const {
getEntry()->printAsOperand(OS, false); getEntry()->printAsOperand(OS, false);
} else } else
entryName = getEntry()->getName(); entryName = std::string(getEntry()->getName());
if (getExit()) { if (getExit()) {
if (getExit()->getName().empty()) { if (getExit()->getName().empty()) {
@ -244,7 +244,7 @@ std::string RegionBase<Tr>::getNameStr() const {
getExit()->printAsOperand(OS, false); getExit()->printAsOperand(OS, false);
} else } else
exitName = getExit()->getName(); exitName = std::string(getExit()->getName());
} else } else
exitName = "<Function Return>"; exitName = "<Function Return>";

View File

@ -129,7 +129,7 @@ public:
void setAvailableWithName(LibFunc F, StringRef Name) { void setAvailableWithName(LibFunc F, StringRef Name) {
if (StandardNames[F] != Name) { if (StandardNames[F] != Name) {
setState(F, CustomName); setState(F, CustomName);
CustomNames[F] = Name; CustomNames[F] = std::string(Name);
assert(CustomNames.find(F) != CustomNames.end()); assert(CustomNames.find(F) != CustomNames.end());
} else { } else {
setState(F, StandardName); setState(F, StandardName);

View File

@ -331,8 +331,7 @@ LLVM_ATTRIBUTE_UNUSED static std::string getCPUStr() {
// If user asked for the 'native' CPU, autodetect here. If autodection fails, // If user asked for the 'native' CPU, autodetect here. If autodection fails,
// this will set the CPU to an empty string which tells the target to // this will set the CPU to an empty string which tells the target to
// pick a basic default. // pick a basic default.
if (MCPU == "native") if (MCPU == "native") return std::string(sys::getHostCPUName());
return sys::getHostCPUName();
return MCPU; return MCPU;
} }

View File

@ -338,12 +338,13 @@ public:
for (auto &KV : LogicalDylibs) { for (auto &KV : LogicalDylibs) {
if (auto Sym = KV.second.StubsMgr->findStub(Name, ExportedSymbolsOnly)) if (auto Sym = KV.second.StubsMgr->findStub(Name, ExportedSymbolsOnly))
return Sym; return Sym;
if (auto Sym = findSymbolIn(KV.first, Name, ExportedSymbolsOnly)) if (auto Sym =
findSymbolIn(KV.first, std::string(Name), ExportedSymbolsOnly))
return Sym; return Sym;
else if (auto Err = Sym.takeError()) else if (auto Err = Sym.takeError())
return std::move(Err); return std::move(Err);
} }
return BaseLayer.findSymbol(Name, ExportedSymbolsOnly); return BaseLayer.findSymbol(std::string(Name), ExportedSymbolsOnly);
} }
/// Get the address of a symbol provided by this layer, or some layer /// Get the address of a symbol provided by this layer, or some layer
@ -511,11 +512,11 @@ private:
} }
// Build a resolver for the globals module and add it to the base layer. // Build a resolver for the globals module and add it to the base layer.
auto LegacyLookup = [this, &LD](const std::string &Name) -> JITSymbol { auto LegacyLookup = [this, &LD](StringRef Name) -> JITSymbol {
if (auto Sym = LD.StubsMgr->findStub(Name, false)) if (auto Sym = LD.StubsMgr->findStub(Name, false))
return Sym; return Sym;
if (auto Sym = LD.findSymbol(BaseLayer, Name, false)) if (auto Sym = LD.findSymbol(BaseLayer, std::string(Name), false))
return Sym; return Sym;
else if (auto Err = Sym.takeError()) else if (auto Err = Sym.takeError())
return std::move(Err); return std::move(Err);
@ -631,7 +632,7 @@ private:
Module &SrcM = LD.getSourceModule(LMId); Module &SrcM = LD.getSourceModule(LMId);
// Create the module. // Create the module.
std::string NewName = SrcM.getName(); std::string NewName(SrcM.getName());
for (auto *F : Part) { for (auto *F : Part) {
NewName += "."; NewName += ".";
NewName += F->getName(); NewName += F->getName();
@ -688,8 +689,8 @@ private:
auto K = ES.allocateVModule(); auto K = ES.allocateVModule();
auto LegacyLookup = [this, &LD](const std::string &Name) -> JITSymbol { auto LegacyLookup = [this, &LD](StringRef Name) -> JITSymbol {
return LD.findSymbol(BaseLayer, Name, false); return LD.findSymbol(BaseLayer, std::string(Name), false);
}; };
// Create memory manager and symbol resolver. // Create memory manager and symbol resolver.

View File

@ -78,7 +78,7 @@ private:
// RuntimeDyld that did the lookup), so just return a nullptr here. // RuntimeDyld that did the lookup), so just return a nullptr here.
return nullptr; return nullptr;
case Emitted: case Emitted:
return B.findSymbolIn(K, Name, ExportedSymbolsOnly); return B.findSymbolIn(K, std::string(Name), ExportedSymbolsOnly);
} }
llvm_unreachable("Invalid emit-state."); llvm_unreachable("Invalid emit-state.");
} }

View File

@ -170,7 +170,7 @@ protected:
if (!SymEntry->second.getFlags().isExported() && ExportedSymbolsOnly) if (!SymEntry->second.getFlags().isExported() && ExportedSymbolsOnly)
return nullptr; return nullptr;
if (!Finalized) if (!Finalized)
return JITSymbol(getSymbolMaterializer(Name), return JITSymbol(getSymbolMaterializer(std::string(Name)),
SymEntry->second.getFlags()); SymEntry->second.getFlags());
return JITSymbol(SymEntry->second); return JITSymbol(SymEntry->second);
} }

View File

@ -1066,7 +1066,7 @@ public:
: Tag(std::move(Tag)), Inputs(Inputs) {} : Tag(std::move(Tag)), Inputs(Inputs) {}
explicit OperandBundleDefT(const OperandBundleUse &OBU) { explicit OperandBundleDefT(const OperandBundleUse &OBU) {
Tag = OBU.getTagName(); Tag = std::string(OBU.getTagName());
Inputs.insert(Inputs.end(), OBU.Inputs.begin(), OBU.Inputs.end()); Inputs.insert(Inputs.end(), OBU.Inputs.begin(), OBU.Inputs.end());
} }

View File

@ -273,22 +273,22 @@ public:
/// @{ /// @{
/// Set the module identifier. /// Set the module identifier.
void setModuleIdentifier(StringRef ID) { ModuleID = ID; } void setModuleIdentifier(StringRef ID) { ModuleID = std::string(ID); }
/// Set the module's original source file name. /// Set the module's original source file name.
void setSourceFileName(StringRef Name) { SourceFileName = Name; } void setSourceFileName(StringRef Name) { SourceFileName = std::string(Name); }
/// Set the data layout /// Set the data layout
void setDataLayout(StringRef Desc); void setDataLayout(StringRef Desc);
void setDataLayout(const DataLayout &Other); void setDataLayout(const DataLayout &Other);
/// Set the target triple. /// Set the target triple.
void setTargetTriple(StringRef T) { TargetTriple = T; } void setTargetTriple(StringRef T) { TargetTriple = std::string(T); }
/// Set the module-scope inline assembly blocks. /// Set the module-scope inline assembly blocks.
/// A trailing newline is added if the input doesn't have one. /// A trailing newline is added if the input doesn't have one.
void setModuleInlineAsm(StringRef Asm) { void setModuleInlineAsm(StringRef Asm) {
GlobalScopeAsm = Asm; GlobalScopeAsm = std::string(Asm);
if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n') if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n')
GlobalScopeAsm += '\n'; GlobalScopeAsm += '\n';
} }

View File

@ -1295,7 +1295,7 @@ public:
NewName += ".llvm."; NewName += ".llvm.";
NewName += utostr((uint64_t(ModHash[0]) << 32) | NewName += utostr((uint64_t(ModHash[0]) << 32) |
ModHash[1]); // Take the first 64 bits ModHash[1]); // Take the first 64 bits
return NewName.str(); return std::string(NewName.str());
} }
/// Helper to obtain the unpromoted name for a global value (or the original /// Helper to obtain the unpromoted name for a global value (or the original
@ -1341,7 +1341,7 @@ public:
if (It->second.first == TypeId) if (It->second.first == TypeId)
return It->second.second; return It->second.second;
auto It = TypeIdMap.insert( auto It = TypeIdMap.insert(
{GlobalValue::getGUID(TypeId), {TypeId, TypeIdSummary()}}); {GlobalValue::getGUID(TypeId), {std::string(TypeId), TypeIdSummary()}});
return It->second.second; return It->second.second;
} }
@ -1371,14 +1371,14 @@ public:
/// the ThinLTO backends. /// the ThinLTO backends.
TypeIdCompatibleVtableInfo & TypeIdCompatibleVtableInfo &
getOrInsertTypeIdCompatibleVtableSummary(StringRef TypeId) { getOrInsertTypeIdCompatibleVtableSummary(StringRef TypeId) {
return TypeIdCompatibleVtableMap[TypeId]; return TypeIdCompatibleVtableMap[std::string(TypeId)];
} }
/// For the given \p TypeId, this returns the TypeIdCompatibleVtableMap /// For the given \p TypeId, this returns the TypeIdCompatibleVtableMap
/// entry if present in the summary map. This may be used when importing. /// entry if present in the summary map. This may be used when importing.
Optional<TypeIdCompatibleVtableInfo> Optional<TypeIdCompatibleVtableInfo>
getTypeIdCompatibleVtableSummary(StringRef TypeId) const { getTypeIdCompatibleVtableSummary(StringRef TypeId) const {
auto I = TypeIdCompatibleVtableMap.find(TypeId); auto I = TypeIdCompatibleVtableMap.find(std::string(TypeId));
if (I == TypeIdCompatibleVtableMap.end()) if (I == TypeIdCompatibleVtableMap.end())
return None; return None;
return I->second; return I->second;

View File

@ -262,7 +262,7 @@ template <> struct CustomMappingTraits<TypeIdSummaryMapTy> {
static void inputOne(IO &io, StringRef Key, TypeIdSummaryMapTy &V) { static void inputOne(IO &io, StringRef Key, TypeIdSummaryMapTy &V) {
TypeIdSummary TId; TypeIdSummary TId;
io.mapRequired(Key.str().c_str(), TId); io.mapRequired(Key.str().c_str(), TId);
V.insert({GlobalValue::getGUID(Key), {Key, TId}}); V.insert({GlobalValue::getGUID(Key), {std::string(Key), TId}});
} }
static void output(IO &io, TypeIdSummaryMapTy &V) { static void output(IO &io, TypeIdSummaryMapTy &V) {
for (auto TidIter = V.begin(); TidIter != V.end(); TidIter++) for (auto TidIter = V.begin(); TidIter != V.end(); TidIter++)

View File

@ -92,8 +92,8 @@ struct LTOCodeGenerator {
/// The default is CGFT_ObjectFile. /// The default is CGFT_ObjectFile.
void setFileType(CodeGenFileType FT) { FileType = FT; } void setFileType(CodeGenFileType FT) { FileType = FT; }
void setCpu(StringRef MCpu) { this->MCpu = MCpu; } void setCpu(StringRef MCpu) { this->MCpu = std::string(MCpu); }
void setAttr(StringRef MAttr) { this->MAttr = MAttr; } void setAttr(StringRef MAttr) { this->MAttr = std::string(MAttr); }
void setOptLevel(unsigned OptLevel); void setOptLevel(unsigned OptLevel);
void setShouldInternalize(bool Value) { ShouldInternalize = Value; } void setShouldInternalize(bool Value) { ShouldInternalize = Value; }

View File

@ -440,7 +440,7 @@ public:
void addFileName(StringRef FileName) { void addFileName(StringRef FileName) {
if (!is_contained(FileNames, FileName)) if (!is_contained(FileNames, FileName))
FileNames.push_back(FileName); FileNames.push_back(std::string(FileName));
} }
/// Write the necessary bundle padding to \p OS. /// Write the necessary bundle padding to \p OS.

View File

@ -541,7 +541,7 @@ namespace llvm {
const std::string &getMainFileName() const { return MainFileName; } const std::string &getMainFileName() const { return MainFileName; }
/// Set the main file name and override the default. /// Set the main file name and override the default.
void setMainFileName(StringRef S) { MainFileName = S; } void setMainFileName(StringRef S) { MainFileName = std::string(S); }
/// Creates an entry in the dwarf file and directory tables. /// Creates an entry in the dwarf file and directory tables.
Expected<unsigned> getDwarfFile(StringRef Directory, StringRef FileName, Expected<unsigned> getDwarfFile(StringRef Directory, StringRef FileName,

View File

@ -252,8 +252,8 @@ public:
void setRootFile(StringRef Directory, StringRef FileName, void setRootFile(StringRef Directory, StringRef FileName,
Optional<MD5::MD5Result> Checksum, Optional<MD5::MD5Result> Checksum,
Optional<StringRef> Source) { Optional<StringRef> Source) {
CompilationDir = Directory; CompilationDir = std::string(Directory);
RootFile.Name = FileName; RootFile.Name = std::string(FileName);
RootFile.DirIndex = 0; RootFile.DirIndex = 0;
RootFile.Checksum = Checksum; RootFile.Checksum = Checksum;
RootFile.Source = Source; RootFile.Source = Source;
@ -325,8 +325,8 @@ public:
void setRootFile(StringRef Directory, StringRef FileName, void setRootFile(StringRef Directory, StringRef FileName,
Optional<MD5::MD5Result> Checksum, Optional<StringRef> Source) { Optional<MD5::MD5Result> Checksum, Optional<StringRef> Source) {
Header.CompilationDir = Directory; Header.CompilationDir = std::string(Directory);
Header.RootFile.Name = FileName; Header.RootFile.Name = std::string(FileName);
Header.RootFile.DirIndex = 0; Header.RootFile.DirIndex = 0;
Header.RootFile.Checksum = Checksum; Header.RootFile.Checksum = Checksum;
Header.RootFile.Source = Source; Header.RootFile.Source = Source;

View File

@ -77,7 +77,9 @@ public:
} }
return "env"; return "env";
} }
void setImportModule(StringRef Name) { ImportModule = Name; } void setImportModule(StringRef Name) {
ImportModule = std::string(std::string(Name));
}
bool hasImportName() const { return ImportName.hasValue(); } bool hasImportName() const { return ImportName.hasValue(); }
const StringRef getImportName() const { const StringRef getImportName() const {
@ -86,11 +88,15 @@ public:
} }
return getName(); return getName();
} }
void setImportName(StringRef Name) { ImportName = Name; } void setImportName(StringRef Name) {
ImportName = std::string(std::string(Name));
}
bool hasExportName() const { return ExportName.hasValue(); } bool hasExportName() const { return ExportName.hasValue(); }
const StringRef getExportName() const { return ExportName.getValue(); } const StringRef getExportName() const { return ExportName.getValue(); }
void setExportName(StringRef Name) { ExportName = Name; } void setExportName(StringRef Name) {
ExportName = std::string(std::string(Name));
}
void setUsedInGOT() const { IsUsedInGOT = true; } void setUsedInGOT() const { IsUsedInGOT = true; }
bool isUsedInGOT() const { return IsUsedInGOT; } bool isUsedInGOT() const { return IsUsedInGOT; }

View File

@ -214,7 +214,7 @@ public:
} }
/// Return string stripped of flag. /// Return string stripped of flag.
static std::string StripFlag(StringRef Feature) { static StringRef StripFlag(StringRef Feature) {
return hasFlag(Feature) ? Feature.substr(1) : Feature; return hasFlag(Feature) ? Feature.substr(1) : Feature;
} }

View File

@ -644,7 +644,7 @@ public:
Version = utostr(major) + "." + utostr(minor); Version = utostr(major) + "." + utostr(minor);
if (update != 0) if (update != 0)
Version += "." + utostr(update); Version += "." + utostr(update);
return Version.str(); return std::string(std::string(Version.str()));
} }
private: private:

View File

@ -51,7 +51,7 @@ public:
return Result.second; return Result.second;
} }
std::string getArchFlagName() const { StringRef getArchFlagName() const {
return MachO::getArchitectureName(Parent->Architectures[Index]); return MachO::getArchitectureName(Parent->Architectures[Index]);
} }

View File

@ -130,7 +130,7 @@ public:
/// Get the name of this option with the default prefix. /// Get the name of this option with the default prefix.
std::string getPrefixedName() const { std::string getPrefixedName() const {
std::string Ret = getPrefix(); std::string Ret(getPrefix());
Ret += getName(); Ret += getName();
return Ret; return Ret;
} }

View File

@ -562,7 +562,7 @@ StringRef InstrProfSymtab::getFuncName(uint64_t FuncMD5Hash) {
finalizeSymtab(); finalizeSymtab();
auto Result = auto Result =
std::lower_bound(MD5NameMap.begin(), MD5NameMap.end(), FuncMD5Hash, std::lower_bound(MD5NameMap.begin(), MD5NameMap.end(), FuncMD5Hash,
[](const std::pair<uint64_t, std::string> &LHS, [](const std::pair<uint64_t, StringRef> &LHS,
uint64_t RHS) { return LHS.first < RHS; }); uint64_t RHS) { return LHS.first < RHS; });
if (Result != MD5NameMap.end() && Result->first == FuncMD5Hash) if (Result != MD5NameMap.end() && Result->first == FuncMD5Hash)
return Result->second; return Result->second;

View File

@ -68,7 +68,7 @@ public:
// line option parsing. The main reason to register counters is to produce a // line option parsing. The main reason to register counters is to produce a
// nice list of them on the command line, but i'm not sure this is worth it. // nice list of them on the command line, but i'm not sure this is worth it.
static unsigned registerCounter(StringRef Name, StringRef Desc) { static unsigned registerCounter(StringRef Name, StringRef Desc) {
return instance().addCounter(Name, Desc); return instance().addCounter(std::string(Name), std::string(Desc));
} }
inline static bool shouldExecute(unsigned CounterName) { inline static bool shouldExecute(unsigned CounterName) {
if (!isCountingEnabled()) if (!isCountingEnabled())

View File

@ -126,7 +126,7 @@ public:
} }
void writeHeader(const std::string &Title) { void writeHeader(const std::string &Title) {
std::string GraphName = DTraits.getGraphName(G); std::string GraphName(DTraits.getGraphName(G));
if (!Title.empty()) if (!Title.empty())
O << "digraph \"" << DOT::EscapeString(Title) << "\" {\n"; O << "digraph \"" << DOT::EscapeString(Title) << "\" {\n";

View File

@ -565,7 +565,7 @@ inline bool Object::erase(StringRef K) {
// See comments on Value. // See comments on Value.
inline bool fromJSON(const Value &E, std::string &Out) { inline bool fromJSON(const Value &E, std::string &Out) {
if (auto S = E.getAsString()) { if (auto S = E.getAsString()) {
Out = *S; Out = std::string(*S);
return true; return true;
} }
return false; return false;
@ -632,7 +632,7 @@ bool fromJSON(const Value &E, std::map<std::string, T> &Out) {
if (auto *O = E.getAsObject()) { if (auto *O = E.getAsObject()) {
Out.clear(); Out.clear();
for (const auto &KV : *O) for (const auto &KV : *O)
if (!fromJSON(KV.second, Out[llvm::StringRef(KV.first)])) if (!fromJSON(KV.second, Out[std::string(llvm::StringRef(KV.first))]))
return false; return false;
return true; return true;
} }

View File

@ -44,7 +44,7 @@ public:
/// Construct a named SmallVectorMemoryBuffer from the given /// Construct a named SmallVectorMemoryBuffer from the given
/// SmallVector r-value and StringRef. /// SmallVector r-value and StringRef.
SmallVectorMemoryBuffer(SmallVectorImpl<char> &&SV, StringRef Name) SmallVectorMemoryBuffer(SmallVectorImpl<char> &&SV, StringRef Name)
: SV(std::move(SV)), BufferName(Name) { : SV(std::move(SV)), BufferName(std::string(Name)) {
init(this->SV.begin(), this->SV.end(), false); init(this->SV.begin(), this->SV.end(), false);
} }

View File

@ -1936,7 +1936,7 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
using map_type = std::map<std::string, T>; using map_type = std::map<std::string, T>;
static void inputOne(IO &io, StringRef key, map_type &v) { static void inputOne(IO &io, StringRef key, map_type &v) {
io.mapRequired(key.str().c_str(), v[key]); io.mapRequired(key.str().c_str(), v[std::string(key)]);
} }
static void output(IO &io, map_type &v) { static void output(IO &io, map_type &v) {

View File

@ -614,7 +614,9 @@ public:
bool isConcrete() const override { return true; } bool isConcrete() const override { return true; }
std::string getAsString() const override { return "\"" + Value.str() + "\""; } std::string getAsString() const override { return "\"" + Value.str() + "\""; }
std::string getAsUnquotedString() const override { return Value; } std::string getAsUnquotedString() const override {
return std::string(Value);
}
Init *getBit(unsigned Bit) const override { Init *getBit(unsigned Bit) const override {
llvm_unreachable("Illegal bit reference off string"); llvm_unreachable("Illegal bit reference off string");
@ -649,7 +651,9 @@ public:
return "[{" + Value.str() + "}]"; return "[{" + Value.str() + "}]";
} }
std::string getAsUnquotedString() const override { return Value; } std::string getAsUnquotedString() const override {
return std::string(Value);
}
Init *getBit(unsigned Bit) const override { Init *getBit(unsigned Bit) const override {
llvm_unreachable("Illegal bit reference off string"); llvm_unreachable("Illegal bit reference off string");
@ -1098,7 +1102,7 @@ public:
Init *getBit(unsigned Bit) const override; Init *getBit(unsigned Bit) const override;
std::string getAsString() const override { return getName(); } std::string getAsString() const override { return std::string(getName()); }
}; };
/// Opcode{0} - Represent access to one bit of a variable or field. /// Opcode{0} - Represent access to one bit of a variable or field.

View File

@ -45,7 +45,7 @@ public:
// Escape the string. // Escape the string.
SmallString<256> Str; SmallString<256> Str;
raw_svector_ostream(Str).write_escaped(AggregateString); raw_svector_ostream(Str).write_escaped(AggregateString);
AggregateString = Str.str(); AggregateString = std::string(Str.str());
O << " \""; O << " \"";
unsigned CharsPrinted = 0; unsigned CharsPrinted = 0;

View File

@ -158,7 +158,7 @@ public:
/// Set the path from which this file was generated (if applicable). /// Set the path from which this file was generated (if applicable).
/// ///
/// \param Path_ The path to the source file. /// \param Path_ The path to the source file.
void setPath(StringRef Path_) { Path = Path_; } void setPath(StringRef Path_) { Path = std::string(Path_); }
/// Get the path from which this file was generated (if applicable). /// Get the path from which this file was generated (if applicable).
/// ///
@ -217,7 +217,9 @@ public:
const_filtered_target_range targets(ArchitectureSet Archs) const; const_filtered_target_range targets(ArchitectureSet Archs) const;
/// Set the install name of the library. /// Set the install name of the library.
void setInstallName(StringRef InstallName_) { InstallName = InstallName_; } void setInstallName(StringRef InstallName_) {
InstallName = std::string(InstallName_);
}
/// Get the install name of the library. /// Get the install name of the library.
StringRef getInstallName() const { return InstallName; } StringRef getInstallName() const { return InstallName; }

View File

@ -29,7 +29,7 @@ template <> struct DOTGraphTraits<CallGraph *> : public DefaultDOTGraphTraits {
std::string getNodeLabel(CallGraphNode *Node, CallGraph *Graph) { std::string getNodeLabel(CallGraphNode *Node, CallGraph *Graph) {
if (Function *Func = Node->getFunction()) if (Function *Func = Node->getFunction())
return Func->getName(); return std::string(Func->getName());
return "external node"; return "external node";
} }

View File

@ -1801,11 +1801,12 @@ LazyCallGraphDOTPrinterPass::LazyCallGraphDOTPrinterPass(raw_ostream &OS)
: OS(OS) {} : OS(OS) {}
static void printNodeDOT(raw_ostream &OS, LazyCallGraph::Node &N) { static void printNodeDOT(raw_ostream &OS, LazyCallGraph::Node &N) {
std::string Name = "\"" + DOT::EscapeString(N.getFunction().getName()) + "\""; std::string Name =
"\"" + DOT::EscapeString(std::string(N.getFunction().getName())) + "\"";
for (LazyCallGraph::Edge &E : N.populate()) { for (LazyCallGraph::Edge &E : N.populate()) {
OS << " " << Name << " -> \"" OS << " " << Name << " -> \""
<< DOT::EscapeString(E.getFunction().getName()) << "\""; << DOT::EscapeString(std::string(E.getFunction().getName())) << "\"";
if (!E.isCall()) // It is a ref edge. if (!E.isCall()) // It is a ref edge.
OS << " [style=dashed,label=\"ref\"]"; OS << " [style=dashed,label=\"ref\"]";
OS << ";\n"; OS << ";\n";

View File

@ -403,7 +403,7 @@ Optional<VFInfo> VFABI::tryDemangleForVFABI(StringRef MangledName) {
"The global predicate must be the last parameter"); "The global predicate must be the last parameter");
const VFShape Shape({VF, IsScalable, Parameters}); const VFShape Shape({VF, IsScalable, Parameters});
return VFInfo({Shape, ScalarName, VectorName, ISA}); return VFInfo({Shape, std::string(ScalarName), std::string(VectorName), ISA});
} }
VFParamKind VFABI::getVFParamKindFromString(const StringRef Token) { VFParamKind VFABI::getVFParamKindFromString(const StringRef Token) {

View File

@ -1180,7 +1180,7 @@ void VFABI::getVectorVariantNames(
assert(CI.getModule()->getFunction(Info.getValue().VectorName) && assert(CI.getModule()->getFunction(Info.getValue().VectorName) &&
"Vector function is missing."); "Vector function is missing.");
#endif #endif
VariantMappings.push_back(S); VariantMappings.push_back(std::string(S));
} }
} }

View File

@ -3695,7 +3695,7 @@ bool LLParser::parseOptionalComdat(StringRef GlobalName, Comdat *&C) {
} else { } else {
if (GlobalName.empty()) if (GlobalName.empty())
return TokError("comdat cannot be unnamed"); return TokError("comdat cannot be unnamed");
C = getComdat(GlobalName, KwLoc); C = getComdat(std::string(GlobalName), KwLoc);
} }
return false; return false;
@ -5546,7 +5546,7 @@ bool LLParser::PerFunctionState::resolveForwardRefBlockAddresses() {
ValID ID; ValID ID;
if (FunctionNumber == -1) { if (FunctionNumber == -1) {
ID.Kind = ValID::t_GlobalName; ID.Kind = ValID::t_GlobalName;
ID.StrVal = F.getName(); ID.StrVal = std::string(F.getName());
} else { } else {
ID.Kind = ValID::t_GlobalID; ID.Kind = ValID::t_GlobalID;
ID.UIntVal = FunctionNumber; ID.UIntVal = FunctionNumber;

View File

@ -859,7 +859,7 @@ BitcodeReader::BitcodeReader(BitstreamCursor Stream, StringRef Strtab,
LLVMContext &Context) LLVMContext &Context)
: BitcodeReaderBase(std::move(Stream), Strtab), Context(Context), : BitcodeReaderBase(std::move(Stream), Strtab), Context(Context),
ValueList(Context, Stream.SizeInBytes()) { ValueList(Context, Stream.SizeInBytes()) {
this->ProducerIdentification = ProducerIdentification; this->ProducerIdentification = std::string(ProducerIdentification);
} }
Error BitcodeReader::materializeForwardReferencedFunctions() { Error BitcodeReader::materializeForwardReferencedFunctions() {

View File

@ -1174,7 +1174,7 @@ void ModuleBitcodeWriter::writeModuleInfo() {
MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV.getValueType())); MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV.getValueType()));
if (GV.hasSection()) { if (GV.hasSection()) {
// Give section names unique ID's. // Give section names unique ID's.
unsigned &Entry = SectionMap[GV.getSection()]; unsigned &Entry = SectionMap[std::string(GV.getSection())];
if (!Entry) { if (!Entry) {
writeStringRecord(Stream, bitc::MODULE_CODE_SECTIONNAME, GV.getSection(), writeStringRecord(Stream, bitc::MODULE_CODE_SECTIONNAME, GV.getSection(),
0 /*TODO*/); 0 /*TODO*/);
@ -1186,7 +1186,7 @@ void ModuleBitcodeWriter::writeModuleInfo() {
MaxAlignment = std::max(MaxAlignment, F.getAlignment()); MaxAlignment = std::max(MaxAlignment, F.getAlignment());
if (F.hasSection()) { if (F.hasSection()) {
// Give section names unique ID's. // Give section names unique ID's.
unsigned &Entry = SectionMap[F.getSection()]; unsigned &Entry = SectionMap[std::string(F.getSection())];
if (!Entry) { if (!Entry) {
writeStringRecord(Stream, bitc::MODULE_CODE_SECTIONNAME, F.getSection(), writeStringRecord(Stream, bitc::MODULE_CODE_SECTIONNAME, F.getSection(),
0 /*TODO*/); 0 /*TODO*/);
@ -1276,7 +1276,8 @@ void ModuleBitcodeWriter::writeModuleInfo() {
(VE.getValueID(GV.getInitializer()) + 1)); (VE.getValueID(GV.getInitializer()) + 1));
Vals.push_back(getEncodedLinkage(GV)); Vals.push_back(getEncodedLinkage(GV));
Vals.push_back(Log2_32(GV.getAlignment())+1); Vals.push_back(Log2_32(GV.getAlignment())+1);
Vals.push_back(GV.hasSection() ? SectionMap[GV.getSection()] : 0); Vals.push_back(GV.hasSection() ? SectionMap[std::string(GV.getSection())]
: 0);
if (GV.isThreadLocal() || if (GV.isThreadLocal() ||
GV.getVisibility() != GlobalValue::DefaultVisibility || GV.getVisibility() != GlobalValue::DefaultVisibility ||
GV.getUnnamedAddr() != GlobalValue::UnnamedAddr::None || GV.getUnnamedAddr() != GlobalValue::UnnamedAddr::None ||
@ -1321,7 +1322,8 @@ void ModuleBitcodeWriter::writeModuleInfo() {
Vals.push_back(getEncodedLinkage(F)); Vals.push_back(getEncodedLinkage(F));
Vals.push_back(VE.getAttributeListID(F.getAttributes())); Vals.push_back(VE.getAttributeListID(F.getAttributes()));
Vals.push_back(Log2_32(F.getAlignment())+1); Vals.push_back(Log2_32(F.getAlignment())+1);
Vals.push_back(F.hasSection() ? SectionMap[F.getSection()] : 0); Vals.push_back(F.hasSection() ? SectionMap[std::string(F.getSection())]
: 0);
Vals.push_back(getEncodedVisibility(F)); Vals.push_back(getEncodedVisibility(F));
Vals.push_back(F.hasGC() ? GCMap[F.getGC()] : 0); Vals.push_back(F.hasGC() ? GCMap[F.getGC()] : 0);
Vals.push_back(getEncodedUnnamedAddr(F)); Vals.push_back(getEncodedUnnamedAddr(F));

View File

@ -3152,7 +3152,7 @@ void AsmPrinter::emitXRayTable() {
std::string GroupName; std::string GroupName;
if (F.hasComdat()) { if (F.hasComdat()) {
Flags |= ELF::SHF_GROUP; Flags |= ELF::SHF_GROUP;
GroupName = F.getComdat()->getName(); GroupName = std::string(F.getComdat()->getName());
} }
auto UniqueID = ++XRayFnUniqueID; auto UniqueID = ++XRayFnUniqueID;
@ -3232,7 +3232,7 @@ void AsmPrinter::emitPatchableFunctionEntries() {
std::string GroupName; std::string GroupName;
if (F.hasComdat()) { if (F.hasComdat()) {
Flags |= ELF::SHF_GROUP; Flags |= ELF::SHF_GROUP;
GroupName = F.getComdat()->getName(); GroupName = std::string(F.getComdat()->getName());
} }
MCSection *Section = getObjFileLowering().SectionForGlobal(&F, TM); MCSection *Section = getObjFileLowering().SectionForGlobal(&F, TM);
unsigned UniqueID = unsigned UniqueID =

View File

@ -119,9 +119,9 @@ public:
std::string TypeName; std::string TypeName;
if (!TI.isNoneType()) { if (!TI.isNoneType()) {
if (TI.isSimple()) if (TI.isSimple())
TypeName = TypeIndex::simpleTypeName(TI); TypeName = std::string(TypeIndex::simpleTypeName(TI));
else else
TypeName = TypeTable.getTypeName(TI); TypeName = std::string(TypeTable.getTypeName(TI));
} }
return TypeName; return TypeName;
} }
@ -183,7 +183,7 @@ StringRef CodeViewDebug::getFullFilepath(const DIFile *File) {
if (Dir.startswith("/") || Filename.startswith("/")) { if (Dir.startswith("/") || Filename.startswith("/")) {
if (llvm::sys::path::is_absolute(Filename, llvm::sys::path::Style::posix)) if (llvm::sys::path::is_absolute(Filename, llvm::sys::path::Style::posix))
return Filename; return Filename;
Filepath = Dir; Filepath = std::string(Dir);
if (Dir.back() != '/') if (Dir.back() != '/')
Filepath += '/'; Filepath += '/';
Filepath += Filename; Filepath += Filename;
@ -195,7 +195,7 @@ StringRef CodeViewDebug::getFullFilepath(const DIFile *File) {
// that would increase the IR size and probably not needed for other users. // that would increase the IR size and probably not needed for other users.
// For now, just concatenate and canonicalize the path here. // For now, just concatenate and canonicalize the path here.
if (Filename.find(':') == 1) if (Filename.find(':') == 1)
Filepath = Filename; Filepath = std::string(Filename);
else else
Filepath = (Dir + "\\" + Filename).str(); Filepath = (Dir + "\\" + Filename).str();
@ -322,10 +322,10 @@ static std::string getQualifiedName(ArrayRef<StringRef> QualifiedNameComponents,
std::string FullyQualifiedName; std::string FullyQualifiedName;
for (StringRef QualifiedNameComponent : for (StringRef QualifiedNameComponent :
llvm::reverse(QualifiedNameComponents)) { llvm::reverse(QualifiedNameComponents)) {
FullyQualifiedName.append(QualifiedNameComponent); FullyQualifiedName.append(std::string(QualifiedNameComponent));
FullyQualifiedName.append("::"); FullyQualifiedName.append("::");
} }
FullyQualifiedName.append(TypeName); FullyQualifiedName.append(std::string(TypeName));
return FullyQualifiedName; return FullyQualifiedName;
} }
@ -943,7 +943,8 @@ void CodeViewDebug::switchToDebugSectionForSymbol(const MCSymbol *GVSym) {
void CodeViewDebug::emitDebugInfoForThunk(const Function *GV, void CodeViewDebug::emitDebugInfoForThunk(const Function *GV,
FunctionInfo &FI, FunctionInfo &FI,
const MCSymbol *Fn) { const MCSymbol *Fn) {
std::string FuncName = GlobalValue::dropLLVMManglingEscape(GV->getName()); std::string FuncName =
std::string(GlobalValue::dropLLVMManglingEscape(GV->getName()));
const ThunkOrdinal ordinal = ThunkOrdinal::Standard; // Only supported kind. const ThunkOrdinal ordinal = ThunkOrdinal::Standard; // Only supported kind.
OS.AddComment("Symbol subsection for " + Twine(FuncName)); OS.AddComment("Symbol subsection for " + Twine(FuncName));
@ -1006,7 +1007,7 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV,
// If our DISubprogram name is empty, use the mangled name. // If our DISubprogram name is empty, use the mangled name.
if (FuncName.empty()) if (FuncName.empty())
FuncName = GlobalValue::dropLLVMManglingEscape(GV->getName()); FuncName = std::string(GlobalValue::dropLLVMManglingEscape(GV->getName()));
// Emit FPO data, but only on 32-bit x86. No other platforms use it. // Emit FPO data, but only on 32-bit x86. No other platforms use it.
if (Triple(MMI->getModule()->getTargetTriple()).getArch() == Triple::x86) if (Triple(MMI->getModule()->getTargetTriple()).getArch() == Triple::x86)

View File

@ -35,8 +35,8 @@ struct FEntryInserter : public MachineFunctionPass {
} }
bool FEntryInserter::runOnMachineFunction(MachineFunction &MF) { bool FEntryInserter::runOnMachineFunction(MachineFunction &MF) {
const std::string FEntryName = const std::string FEntryName = std::string(
MF.getFunction().getFnAttribute("fentry-call").getValueAsString(); MF.getFunction().getFnAttribute("fentry-call").getValueAsString());
if (FEntryName != "true") if (FEntryName != "true")
return false; return false;

View File

@ -153,7 +153,7 @@ GCStrategy *GCModuleInfo::getGCStrategy(const StringRef Name) {
for (auto& Entry : GCRegistry::entries()) { for (auto& Entry : GCRegistry::entries()) {
if (Name == Entry.getName()) { if (Name == Entry.getName()) {
std::unique_ptr<GCStrategy> S = Entry.instantiate(); std::unique_ptr<GCStrategy> S = Entry.instantiate();
S->Name = Name; S->Name = std::string(Name);
GCStrategyMap[Name] = S.get(); GCStrategyMap[Name] = S.get();
GCStrategyList.push_back(std::move(S)); GCStrategyList.push_back(std::move(S));
return GCStrategyList.back().get(); return GCStrategyList.back().get();

View File

@ -523,7 +523,7 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals,
const StructLayout *MergedLayout = DL.getStructLayout(MergedTy); const StructLayout *MergedLayout = DL.getStructLayout(MergedTy);
for (ssize_t k = i, idx = 0; k != j; k = GlobalSet.find_next(k), ++idx) { for (ssize_t k = i, idx = 0; k != j; k = GlobalSet.find_next(k), ++idx) {
GlobalValue::LinkageTypes Linkage = Globals[k]->getLinkage(); GlobalValue::LinkageTypes Linkage = Globals[k]->getLinkage();
std::string Name = Globals[k]->getName(); std::string Name(Globals[k]->getName());
GlobalValue::VisibilityTypes Visibility = Globals[k]->getVisibility(); GlobalValue::VisibilityTypes Visibility = Globals[k]->getVisibility();
GlobalValue::DLLStorageClassTypes DLLStorage = GlobalValue::DLLStorageClassTypes DLLStorage =
Globals[k]->getDLLStorageClass(); Globals[k]->getDLLStorageClass();

View File

@ -2334,7 +2334,7 @@ bool MIParser::parseIntrinsicOperand(MachineOperand &Dest) {
if (Token.isNot(MIToken::NamedGlobalValue)) if (Token.isNot(MIToken::NamedGlobalValue))
return error("expected syntax intrinsic(@llvm.whatever)"); return error("expected syntax intrinsic(@llvm.whatever)");
std::string Name = Token.stringValue(); std::string Name = std::string(Token.stringValue());
lex(); lex();
if (expectAndConsume(MIToken::rparen)) if (expectAndConsume(MIToken::rparen))
@ -3149,7 +3149,7 @@ MCSymbol *MIParser::getOrCreateMCSymbol(StringRef Name) {
bool MIParser::parseStringConstant(std::string &Result) { bool MIParser::parseStringConstant(std::string &Result) {
if (Token.isNot(MIToken::StringConstant)) if (Token.isNot(MIToken::StringConstant))
return error("expected string constant"); return error("expected string constant");
Result = Token.stringValue(); Result = std::string(Token.stringValue());
lex(); lex();
return false; return false;
} }

View File

@ -390,8 +390,8 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF,
yaml::MachineStackObject YamlObject; yaml::MachineStackObject YamlObject;
YamlObject.ID = ID; YamlObject.ID = ID;
if (const auto *Alloca = MFI.getObjectAllocation(I)) if (const auto *Alloca = MFI.getObjectAllocation(I))
YamlObject.Name.Value = YamlObject.Name.Value = std::string(
Alloca->hasName() ? Alloca->getName() : "<unnamed alloca>"; Alloca->hasName() ? Alloca->getName() : "<unnamed alloca>");
YamlObject.Type = MFI.isSpillSlotObjectIndex(I) YamlObject.Type = MFI.isSpillSlotObjectIndex(I)
? yaml::MachineStackObject::SpillSlot ? yaml::MachineStackObject::SpillSlot
: MFI.isVariableSizedObjectIndex(I) : MFI.isVariableSizedObjectIndex(I)

View File

@ -24,7 +24,7 @@ using namespace llvm;
DiagnosticInfoMIROptimization::MachineArgument::MachineArgument( DiagnosticInfoMIROptimization::MachineArgument::MachineArgument(
StringRef MKey, const MachineInstr &MI) StringRef MKey, const MachineInstr &MI)
: Argument() { : Argument() {
Key = MKey; Key = std::string(MKey);
raw_string_ostream OS(Val); raw_string_ostream OS(Val);
MI.print(OS, /*IsStandalone=*/true, /*SkipOpers=*/false, MI.print(OS, /*IsStandalone=*/true, /*SkipOpers=*/false,

View File

@ -1377,7 +1377,7 @@ void MachineOutliner::emitInstrCountChangedRemark(
if (!MF) if (!MF)
continue; continue;
std::string Fname = F.getName(); std::string Fname = std::string(F.getName());
unsigned FnCountAfter = MF->getInstructionCount(); unsigned FnCountAfter = MF->getInstructionCount();
unsigned FnCountBefore = 0; unsigned FnCountBefore = 0;

View File

@ -3695,7 +3695,7 @@ struct DOTGraphTraits<ScheduleDAGMI*> : public DefaultDOTGraphTraits {
DOTGraphTraits(bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {} DOTGraphTraits(bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {}
static std::string getGraphName(const ScheduleDAG *G) { static std::string getGraphName(const ScheduleDAG *G) {
return G->MF.getName(); return std::string(G->MF.getName());
} }
static bool renderGraphFromBottomUp() { static bool renderGraphFromBottomUp() {

View File

@ -28,7 +28,7 @@ namespace llvm {
DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {} DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
static std::string getGraphName(const ScheduleDAG *G) { static std::string getGraphName(const ScheduleDAG *G) {
return G->MF.getName(); return std::string(G->MF.getName());
} }
static bool renderGraphFromBottomUp() { static bool renderGraphFromBottomUp() {

View File

@ -65,7 +65,7 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
if (G) if (G)
if (const TargetInstrInfo *TII = G->getSubtarget().getInstrInfo()) if (const TargetInstrInfo *TII = G->getSubtarget().getInstrInfo())
if (getMachineOpcode() < TII->getNumOpcodes()) if (getMachineOpcode() < TII->getNumOpcodes())
return TII->getName(getMachineOpcode()); return std::string(TII->getName(getMachineOpcode()));
return "<<Unknown Machine Node #" + utostr(getOpcode()) + ">>"; return "<<Unknown Machine Node #" + utostr(getOpcode()) + ">>";
} }
if (G) { if (G) {

View File

@ -70,7 +70,7 @@ namespace llvm {
} }
static std::string getGraphName(const SelectionDAG *G) { static std::string getGraphName(const SelectionDAG *G) {
return G->getMachineFunction().getName(); return std::string(G->getMachineFunction().getName());
} }
static bool renderGraphFromBottomUp() { static bool renderGraphFromBottomUp() {

View File

@ -888,7 +888,7 @@ void TargetLoweringObjectFileMachO::emitModuleMetadata(MCStreamer &Streamer,
for (const auto *Option : LinkerOptions->operands()) { for (const auto *Option : LinkerOptions->operands()) {
SmallVector<std::string, 4> StrOptions; SmallVector<std::string, 4> StrOptions;
for (const auto &Piece : cast<MDNode>(Option)->operands()) for (const auto &Piece : cast<MDNode>(Option)->operands())
StrOptions.push_back(cast<MDString>(Piece)->getString()); StrOptions.push_back(std::string(cast<MDString>(Piece)->getString()));
Streamer.EmitLinkerOptions(StrOptions); Streamer.EmitLinkerOptions(StrOptions);
} }
} }
@ -1453,7 +1453,7 @@ void TargetLoweringObjectFileCOFF::emitModuleMetadata(MCStreamer &Streamer,
for (const auto &Piece : cast<MDNode>(Option)->operands()) { for (const auto &Piece : cast<MDNode>(Option)->operands()) {
// Lead with a space for consistency with our dllexport implementation. // Lead with a space for consistency with our dllexport implementation.
std::string Directive(" "); std::string Directive(" ");
Directive.append(cast<MDString>(Piece)->getString()); Directive.append(std::string(cast<MDString>(Piece)->getString()));
Streamer.EmitBytes(Directive); Streamer.EmitBytes(Directive);
} }
} }

View File

@ -185,7 +185,7 @@ static void analyzeImportedModule(
Twine("Conflicting parseable interfaces for Swift Module ") + Twine("Conflicting parseable interfaces for Swift Module ") +
*Name + ": " + Entry + " and " + Path, *Name + ": " + Entry + " and " + Path,
DIE); DIE);
Entry = ResolvedPath.str(); Entry = std::string(ResolvedPath.str());
} }
} }
@ -1180,7 +1180,7 @@ void DWARFLinker::DIECloner::addObjCAccelerator(CompileUnit &Unit,
std::string MethodNameNoCategory(Name.getString().data(), OpenParens + 2); std::string MethodNameNoCategory(Name.getString().data(), OpenParens + 2);
// FIXME: The missing space here may be a bug, but // FIXME: The missing space here may be a bug, but
// dsymutil-classic also does it this way. // dsymutil-classic also does it this way.
MethodNameNoCategory.append(SelectorStart); MethodNameNoCategory.append(std::string(SelectorStart));
Unit.addNameAccelerator(Die, StringPool.getEntry(MethodNameNoCategory), Unit.addNameAccelerator(Die, StringPool.getEntry(MethodNameNoCategory),
SkipPubSection); SkipPubSection);
} }

View File

@ -253,7 +253,7 @@ std::string llvm::codeview::computeTypeName(TypeCollection &Types,
consumeError(std::move(EC)); consumeError(std::move(EC));
return "<unknown UDT>"; return "<unknown UDT>";
} }
return Computer.name(); return std::string(Computer.name());
} }
static int getSymbolNameOffset(CVSymbol Sym) { static int getSymbolNameOffset(CVSymbol Sym) {

View File

@ -99,12 +99,12 @@ static std::string getMemberAttributes(CodeViewRecordIO &IO,
MethodOptions Options) { MethodOptions Options) {
if (!IO.isStreaming()) if (!IO.isStreaming())
return ""; return "";
std::string AccessSpecifier = std::string AccessSpecifier = std::string(
getEnumName(IO, uint8_t(Access), makeArrayRef(getMemberAccessNames())); getEnumName(IO, uint8_t(Access), makeArrayRef(getMemberAccessNames())));
std::string MemberAttrs(AccessSpecifier); std::string MemberAttrs(AccessSpecifier);
if (Kind != MethodKind::Vanilla) { if (Kind != MethodKind::Vanilla) {
std::string MethodKind = std::string MethodKind = std::string(
getEnumName(IO, unsigned(Kind), makeArrayRef(getMemberKindNames())); getEnumName(IO, unsigned(Kind), makeArrayRef(getMemberKindNames())));
MemberAttrs += ", " + MethodKind; MemberAttrs += ", " + MethodKind;
} }
if (Options != MethodOptions::None) { if (Options != MethodOptions::None) {
@ -201,8 +201,8 @@ Error TypeRecordMapping::visitTypeBegin(CVType &CVR) {
if (IO.isStreaming()) { if (IO.isStreaming()) {
auto RecordKind = CVR.kind(); auto RecordKind = CVR.kind();
uint16_t RecordLen = CVR.length() - 2; uint16_t RecordLen = CVR.length() - 2;
std::string RecordKindName = std::string RecordKindName = std::string(
getEnumName(IO, unsigned(RecordKind), makeArrayRef(LeafTypeNames)); getEnumName(IO, unsigned(RecordKind), makeArrayRef(LeafTypeNames)));
error(IO.mapInteger(RecordLen, "Record length")); error(IO.mapInteger(RecordLen, "Record length"));
error(IO.mapEnum(RecordKind, "Record kind: " + RecordKindName)); error(IO.mapEnum(RecordKind, "Record kind: " + RecordKindName));
} }
@ -241,7 +241,7 @@ Error TypeRecordMapping::visitMemberBegin(CVMemberRecord &Record) {
MemberKind = Record.Kind; MemberKind = Record.Kind;
if (IO.isStreaming()) { if (IO.isStreaming()) {
std::string MemberKindName = getLeafTypeName(Record.Kind); std::string MemberKindName = std::string(getLeafTypeName(Record.Kind));
MemberKindName += MemberKindName +=
" ( " + " ( " +
(getEnumName(IO, unsigned(Record.Kind), makeArrayRef(LeafTypeNames))) (getEnumName(IO, unsigned(Record.Kind), makeArrayRef(LeafTypeNames)))
@ -277,8 +277,8 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ModifierRecord &Record) {
Error TypeRecordMapping::visitKnownRecord(CVType &CVR, Error TypeRecordMapping::visitKnownRecord(CVType &CVR,
ProcedureRecord &Record) { ProcedureRecord &Record) {
std::string CallingConvName = getEnumName( std::string CallingConvName = std::string(getEnumName(
IO, uint8_t(Record.CallConv), makeArrayRef(getCallingConventions())); IO, uint8_t(Record.CallConv), makeArrayRef(getCallingConventions())));
std::string FuncOptionNames = std::string FuncOptionNames =
getFlagNames(IO, static_cast<uint16_t>(Record.Options), getFlagNames(IO, static_cast<uint16_t>(Record.Options),
makeArrayRef(getFunctionOptionEnum())); makeArrayRef(getFunctionOptionEnum()));
@ -293,8 +293,8 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR,
Error TypeRecordMapping::visitKnownRecord(CVType &CVR, Error TypeRecordMapping::visitKnownRecord(CVType &CVR,
MemberFunctionRecord &Record) { MemberFunctionRecord &Record) {
std::string CallingConvName = getEnumName( std::string CallingConvName = std::string(getEnumName(
IO, uint8_t(Record.CallConv), makeArrayRef(getCallingConventions())); IO, uint8_t(Record.CallConv), makeArrayRef(getCallingConventions())));
std::string FuncOptionNames = std::string FuncOptionNames =
getFlagNames(IO, static_cast<uint16_t>(Record.Options), getFlagNames(IO, static_cast<uint16_t>(Record.Options),
makeArrayRef(getFunctionOptionEnum())); makeArrayRef(getFunctionOptionEnum()));
@ -337,12 +337,13 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, PointerRecord &Record) {
SmallString<128> Attr("Attrs: "); SmallString<128> Attr("Attrs: ");
if (IO.isStreaming()) { if (IO.isStreaming()) {
std::string PtrType = getEnumName(IO, unsigned(Record.getPointerKind()), std::string PtrType =
makeArrayRef(getPtrKindNames())); std::string(getEnumName(IO, unsigned(Record.getPointerKind()),
makeArrayRef(getPtrKindNames())));
Attr += "[ Type: " + PtrType; Attr += "[ Type: " + PtrType;
std::string PtrMode = getEnumName(IO, unsigned(Record.getMode()), std::string PtrMode = std::string(getEnumName(
makeArrayRef(getPtrModeNames())); IO, unsigned(Record.getMode()), makeArrayRef(getPtrModeNames())));
Attr += ", Mode: " + PtrMode; Attr += ", Mode: " + PtrMode;
auto PtrSizeOf = Record.getSize(); auto PtrSizeOf = Record.getSize();
@ -374,8 +375,8 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, PointerRecord &Record) {
MemberPointerInfo &M = *Record.MemberInfo; MemberPointerInfo &M = *Record.MemberInfo;
error(IO.mapInteger(M.ContainingType, "ClassType")); error(IO.mapInteger(M.ContainingType, "ClassType"));
std::string PtrMemberGetRepresentation = getEnumName( std::string PtrMemberGetRepresentation = std::string(getEnumName(
IO, uint16_t(M.Representation), makeArrayRef(getPtrMemberRepNames())); IO, uint16_t(M.Representation), makeArrayRef(getPtrMemberRepNames())));
error(IO.mapEnum(M.Representation, error(IO.mapEnum(M.Representation,
"Representation: " + PtrMemberGetRepresentation)); "Representation: " + PtrMemberGetRepresentation));
} }
@ -581,8 +582,8 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR,
} }
Error TypeRecordMapping::visitKnownRecord(CVType &CVR, LabelRecord &Record) { Error TypeRecordMapping::visitKnownRecord(CVType &CVR, LabelRecord &Record) {
std::string ModeName = std::string ModeName = std::string(
getEnumName(IO, uint16_t(Record.Mode), makeArrayRef(getLabelTypeEnum())); getEnumName(IO, uint16_t(Record.Mode), makeArrayRef(getLabelTypeEnum())));
error(IO.mapEnum(Record.Mode, "Mode: " + ModeName)); error(IO.mapEnum(Record.Mode, "Mode: " + ModeName));
return Error::success(); return Error::success();
} }

View File

@ -871,13 +871,14 @@ void DWARFDebugNames::ValueIterator::next() {
DWARFDebugNames::ValueIterator::ValueIterator(const DWARFDebugNames &AccelTable, DWARFDebugNames::ValueIterator::ValueIterator(const DWARFDebugNames &AccelTable,
StringRef Key) StringRef Key)
: CurrentIndex(AccelTable.NameIndices.begin()), IsLocal(false), Key(Key) { : CurrentIndex(AccelTable.NameIndices.begin()), IsLocal(false),
Key(std::string(Key)) {
searchFromStartOfCurrentIndex(); searchFromStartOfCurrentIndex();
} }
DWARFDebugNames::ValueIterator::ValueIterator( DWARFDebugNames::ValueIterator::ValueIterator(
const DWARFDebugNames::NameIndex &NI, StringRef Key) const DWARFDebugNames::NameIndex &NI, StringRef Key)
: CurrentIndex(&NI), IsLocal(true), Key(Key) { : CurrentIndex(&NI), IsLocal(true), Key(std::string(Key)) {
if (!findInCurrentIndex()) if (!findInCurrentIndex())
setEnd(); setEnd();
} }

View File

@ -1063,7 +1063,7 @@ bool DWARFDebugLine::Prologue::getFileNameByIndex(
StringRef FileName = *Name; StringRef FileName = *Name;
if (Kind != FileLineInfoKind::AbsoluteFilePath || if (Kind != FileLineInfoKind::AbsoluteFilePath ||
isPathAbsoluteOnWindowsOrPosix(FileName)) { isPathAbsoluteOnWindowsOrPosix(FileName)) {
Result = FileName; Result = std::string(FileName);
return true; return true;
} }
@ -1087,7 +1087,7 @@ bool DWARFDebugLine::Prologue::getFileNameByIndex(
// sys::path::append skips empty strings. // sys::path::append skips empty strings.
sys::path::append(FilePath, Style, IncludeDir, FileName); sys::path::append(FilePath, Style, IncludeDir, FileName);
Result = FilePath.str(); Result = std::string(FilePath.str());
return true; return true;
} }

View File

@ -21,7 +21,7 @@ std::string LookupResult::getSourceFile(uint32_t Index) const {
if (Index < Locations.size()) { if (Index < Locations.size()) {
if (!Locations[Index].Dir.empty()) { if (!Locations[Index].Dir.empty()) {
if (Locations[Index].Base.empty()) { if (Locations[Index].Base.empty()) {
Fullpath = Locations[Index].Dir; Fullpath = std::string(Locations[Index].Dir);
} else { } else {
llvm::SmallString<64> Storage; llvm::SmallString<64> Storage;
llvm::sys::path::append(Storage, Locations[Index].Dir, llvm::sys::path::append(Storage, Locations[Index].Dir,
@ -29,7 +29,7 @@ std::string LookupResult::getSourceFile(uint32_t Index) const {
Fullpath.assign(Storage.begin(), Storage.end()); Fullpath.assign(Storage.begin(), Storage.end());
} }
} else if (!Locations[Index].Base.empty()) } else if (!Locations[Index].Base.empty())
Fullpath = Locations[Index].Base; Fullpath = std::string(Locations[Index].Base);
} }
return Fullpath; return Fullpath;
} }

View File

@ -39,7 +39,7 @@ static uint32_t calculateDiSymbolStreamSize(uint32_t SymbolByteSize,
DbiModuleDescriptorBuilder::DbiModuleDescriptorBuilder(StringRef ModuleName, DbiModuleDescriptorBuilder::DbiModuleDescriptorBuilder(StringRef ModuleName,
uint32_t ModIndex, uint32_t ModIndex,
msf::MSFBuilder &Msf) msf::MSFBuilder &Msf)
: MSF(Msf), ModuleName(ModuleName) { : MSF(Msf), ModuleName(std::string(ModuleName)) {
::memset(&Layout, 0, sizeof(Layout)); ::memset(&Layout, 0, sizeof(Layout));
Layout.Mod = ModIndex; Layout.Mod = ModIndex;
} }
@ -51,7 +51,7 @@ uint16_t DbiModuleDescriptorBuilder::getStreamIndex() const {
} }
void DbiModuleDescriptorBuilder::setObjFileName(StringRef Name) { void DbiModuleDescriptorBuilder::setObjFileName(StringRef Name) {
ObjFileName = Name; ObjFileName = std::string(Name);
} }
void DbiModuleDescriptorBuilder::setPdbFilePathNI(uint32_t NI) { void DbiModuleDescriptorBuilder::setPdbFilePathNI(uint32_t NI) {
@ -83,7 +83,7 @@ void DbiModuleDescriptorBuilder::addSymbolsInBulk(
} }
void DbiModuleDescriptorBuilder::addSourceFile(StringRef Path) { void DbiModuleDescriptorBuilder::addSourceFile(StringRef Path) {
SourceFiles.push_back(Path); SourceFiles.push_back(std::string(Path));
} }
uint32_t DbiModuleDescriptorBuilder::calculateC13DebugInfoSize() const { uint32_t DbiModuleDescriptorBuilder::calculateC13DebugInfoSize() const {

View File

@ -49,11 +49,11 @@ SymIndexId NativeCompilandSymbol::getLexicalParentId() const { return 0; }
// this potential confusion. // this potential confusion.
std::string NativeCompilandSymbol::getLibraryName() const { std::string NativeCompilandSymbol::getLibraryName() const {
return Module.getObjFileName(); return std::string(Module.getObjFileName());
} }
std::string NativeCompilandSymbol::getName() const { std::string NativeCompilandSymbol::getName() const {
return Module.getModuleName(); return std::string(Module.getModuleName());
} }
} // namespace pdb } // namespace pdb

View File

@ -48,19 +48,19 @@ public:
std::string getFileName() const override { std::string getFileName() const override {
StringRef Ret = cantFail(Strings.getStringForID(Entry.FileNI), StringRef Ret = cantFail(Strings.getStringForID(Entry.FileNI),
"InjectedSourceStream should have rejected this"); "InjectedSourceStream should have rejected this");
return Ret; return std::string(Ret);
} }
std::string getObjectFileName() const override { std::string getObjectFileName() const override {
StringRef Ret = cantFail(Strings.getStringForID(Entry.ObjNI), StringRef Ret = cantFail(Strings.getStringForID(Entry.ObjNI),
"InjectedSourceStream should have rejected this"); "InjectedSourceStream should have rejected this");
return Ret; return std::string(Ret);
} }
std::string getVirtualFileName() const override { std::string getVirtualFileName() const override {
StringRef Ret = cantFail(Strings.getStringForID(Entry.VFileNI), StringRef Ret = cantFail(Strings.getStringForID(Entry.VFileNI),
"InjectedSourceStream should have rejected this"); "InjectedSourceStream should have rejected this");
return Ret; return std::string(Ret);
} }
uint32_t getCompression() const override { return Entry.Compression; } uint32_t getCompression() const override { return Entry.Compression; }

View File

@ -73,7 +73,7 @@ uint32_t NativeExeSymbol::getAge() const {
} }
std::string NativeExeSymbol::getSymbolsFileName() const { std::string NativeExeSymbol::getSymbolsFileName() const {
return Session.getPDBFile().getFilePath(); return std::string(Session.getPDBFile().getFilePath());
} }
codeview::GUID NativeExeSymbol::getGuid() const { codeview::GUID NativeExeSymbol::getGuid() const {

View File

@ -51,7 +51,9 @@ SymIndexId NativeSymbolEnumerator::getClassParentId() const {
SymIndexId NativeSymbolEnumerator::getLexicalParentId() const { return 0; } SymIndexId NativeSymbolEnumerator::getLexicalParentId() const { return 0; }
std::string NativeSymbolEnumerator::getName() const { return Record.Name; } std::string NativeSymbolEnumerator::getName() const {
return std::string(Record.Name);
}
SymIndexId NativeSymbolEnumerator::getTypeId() const { SymIndexId NativeSymbolEnumerator::getTypeId() const {
return Parent.getTypeId(); return Parent.getTypeId();

View File

@ -305,7 +305,7 @@ std::string NativeTypeEnum::getName() const {
if (UnmodifiedType) if (UnmodifiedType)
return UnmodifiedType->getName(); return UnmodifiedType->getName();
return Record->getName(); return std::string(Record->getName());
} }
bool NativeTypeEnum::isNested() const { bool NativeTypeEnum::isNested() const {

View File

@ -20,7 +20,9 @@ void NativeTypeTypedef::dump(raw_ostream &OS, int Indent,
PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields); PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
} }
std::string NativeTypeTypedef::getName() const { return Record.Name; } std::string NativeTypeTypedef::getName() const {
return std::string(Record.Name);
}
SymIndexId NativeTypeTypedef::getTypeId() const { SymIndexId NativeTypeTypedef::getTypeId() const {
return Session.getSymbolCache().findSymbolByTypeIndex(Record.Type); return Session.getSymbolCache().findSymbolByTypeIndex(Record.Type);

View File

@ -74,7 +74,7 @@ std::string NativeTypeUDT::getName() const {
if (UnmodifiedType) if (UnmodifiedType)
return UnmodifiedType->getName(); return UnmodifiedType->getName();
return Tag->getName(); return std::string(Tag->getName());
} }
SymIndexId NativeTypeUDT::getLexicalParentId() const { return 0; } SymIndexId NativeTypeUDT::getLexicalParentId() const { return 0; }

View File

@ -41,7 +41,8 @@ typedef FixedStreamArray<support::ulittle32_t> ulittle_array;
PDBFile::PDBFile(StringRef Path, std::unique_ptr<BinaryStream> PdbFileBuffer, PDBFile::PDBFile(StringRef Path, std::unique_ptr<BinaryStream> PdbFileBuffer,
BumpPtrAllocator &Allocator) BumpPtrAllocator &Allocator)
: FilePath(Path), Allocator(Allocator), Buffer(std::move(PdbFileBuffer)) {} : FilePath(std::string(Path)), Allocator(Allocator),
Buffer(std::move(PdbFileBuffer)) {}
PDBFile::~PDBFile() = default; PDBFile::~PDBFile() = default;

View File

@ -95,7 +95,7 @@ Error PDBFileBuilder::addNamedStream(StringRef Name, StringRef Data) {
if (!ExpectedIndex) if (!ExpectedIndex)
return ExpectedIndex.takeError(); return ExpectedIndex.takeError();
assert(NamedStreamData.count(*ExpectedIndex) == 0); assert(NamedStreamData.count(*ExpectedIndex) == 0);
NamedStreamData[*ExpectedIndex] = Data; NamedStreamData[*ExpectedIndex] = std::string(Data);
return Error::success(); return Error::success();
} }

View File

@ -74,7 +74,7 @@ void DIPrinter::print(const DILineInfo &Info, bool Inlined) {
if (Filename == DILineInfo::BadString) if (Filename == DILineInfo::BadString)
Filename = DILineInfo::Addr2LineBadString; Filename = DILineInfo::Addr2LineBadString;
else if (Basenames) else if (Basenames)
Filename = llvm::sys::path::filename(Filename); Filename = std::string(llvm::sys::path::filename(Filename));
if (!Verbose) { if (!Verbose) {
OS << Filename << ":" << Info.Line; OS << Filename << ":" << Info.Line;
if (Style == OutputStyle::LLVM) if (Style == OutputStyle::LLVM)

View File

@ -62,7 +62,7 @@ Expected<DILineInfo>
LLVMSymbolizer::symbolizeCode(const ObjectFile &Obj, LLVMSymbolizer::symbolizeCode(const ObjectFile &Obj,
object::SectionedAddress ModuleOffset) { object::SectionedAddress ModuleOffset) {
StringRef ModuleName = Obj.getFileName(); StringRef ModuleName = Obj.getFileName();
auto I = Modules.find(ModuleName); auto I = Modules.find(std::string(ModuleName));
if (I != Modules.end()) if (I != Modules.end())
return symbolizeCodeCommon(I->second.get(), ModuleOffset); return symbolizeCodeCommon(I->second.get(), ModuleOffset);
@ -184,7 +184,7 @@ std::string getDarwinDWARFResourceForPath(
} }
sys::path::append(ResourceName, "Contents", "Resources", "DWARF"); sys::path::append(ResourceName, "Contents", "Resources", "DWARF");
sys::path::append(ResourceName, Basename); sys::path::append(ResourceName, Basename);
return ResourceName.str(); return std::string(ResourceName.str());
} }
bool checkFileCRC(StringRef Path, uint32_t CRCHash) { bool checkFileCRC(StringRef Path, uint32_t CRCHash) {
@ -205,14 +205,14 @@ bool findDebugBinary(const std::string &OrigPath,
// Try relative/path/to/original_binary/debuglink_name // Try relative/path/to/original_binary/debuglink_name
llvm::sys::path::append(DebugPath, DebuglinkName); llvm::sys::path::append(DebugPath, DebuglinkName);
if (checkFileCRC(DebugPath, CRCHash)) { if (checkFileCRC(DebugPath, CRCHash)) {
Result = DebugPath.str(); Result = std::string(DebugPath.str());
return true; return true;
} }
// Try relative/path/to/original_binary/.debug/debuglink_name // Try relative/path/to/original_binary/.debug/debuglink_name
DebugPath = OrigDir; DebugPath = OrigDir;
llvm::sys::path::append(DebugPath, ".debug", DebuglinkName); llvm::sys::path::append(DebugPath, ".debug", DebuglinkName);
if (checkFileCRC(DebugPath, CRCHash)) { if (checkFileCRC(DebugPath, CRCHash)) {
Result = DebugPath.str(); Result = std::string(DebugPath.str());
return true; return true;
} }
// Make the path absolute so that lookups will go to // Make the path absolute so that lookups will go to
@ -234,7 +234,7 @@ bool findDebugBinary(const std::string &OrigPath,
llvm::sys::path::append(DebugPath, llvm::sys::path::relative_path(OrigDir), llvm::sys::path::append(DebugPath, llvm::sys::path::relative_path(OrigDir),
DebuglinkName); DebuglinkName);
if (checkFileCRC(DebugPath, CRCHash)) { if (checkFileCRC(DebugPath, CRCHash)) {
Result = DebugPath.str(); Result = std::string(DebugPath.str());
return true; return true;
} }
return false; return false;
@ -342,7 +342,7 @@ bool findDebugBinary(const std::vector<std::string> &DebugFileDirectory,
#endif #endif
); );
if (llvm::sys::fs::exists(Path)) { if (llvm::sys::fs::exists(Path)) {
Result = Path.str(); Result = std::string(Path.str());
return true; return true;
} }
} else { } else {
@ -350,7 +350,7 @@ bool findDebugBinary(const std::vector<std::string> &DebugFileDirectory,
// Try <debug-file-directory>/.build-id/../... // Try <debug-file-directory>/.build-id/../...
SmallString<128> Path = getDebugPath(Directory); SmallString<128> Path = getDebugPath(Directory);
if (llvm::sys::fs::exists(Path)) { if (llvm::sys::fs::exists(Path)) {
Result = Path.str(); Result = std::string(Path.str());
return true; return true;
} }
} }
@ -366,9 +366,11 @@ ObjectFile *LLVMSymbolizer::lookUpDsymFile(const std::string &ExePath,
// resource directory. // resource directory.
std::vector<std::string> DsymPaths; std::vector<std::string> DsymPaths;
StringRef Filename = sys::path::filename(ExePath); StringRef Filename = sys::path::filename(ExePath);
DsymPaths.push_back(getDarwinDWARFResourceForPath(ExePath, Filename)); DsymPaths.push_back(
getDarwinDWARFResourceForPath(ExePath, std::string(Filename)));
for (const auto &Path : Opts.DsymHints) { for (const auto &Path : Opts.DsymHints) {
DsymPaths.push_back(getDarwinDWARFResourceForPath(Path, Filename)); DsymPaths.push_back(
getDarwinDWARFResourceForPath(Path, std::string(Filename)));
} }
for (const auto &Path : DsymPaths) { for (const auto &Path : DsymPaths) {
auto DbgObjOrErr = getOrCreateObject(Path, ArchName); auto DbgObjOrErr = getOrCreateObject(Path, ArchName);

View File

@ -200,7 +200,7 @@ std::string ExecutionEngine::getMangledName(const GlobalValue *GV) {
: GV->getParent()->getDataLayout(); : GV->getParent()->getDataLayout();
Mangler::getNameWithPrefix(FullName, GV->getName(), DL); Mangler::getNameWithPrefix(FullName, GV->getName(), DL);
return FullName.str(); return std::string(FullName.str());
} }
void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) { void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) {
@ -223,7 +223,7 @@ void ExecutionEngine::addGlobalMapping(StringRef Name, uint64_t Addr) {
std::string &V = EEState.getGlobalAddressReverseMap()[CurVal]; std::string &V = EEState.getGlobalAddressReverseMap()[CurVal];
assert((!V.empty() || !Name.empty()) && assert((!V.empty() || !Name.empty()) &&
"GlobalMapping already established!"); "GlobalMapping already established!");
V = Name; V = std::string(Name);
} }
} }
@ -269,7 +269,7 @@ uint64_t ExecutionEngine::updateGlobalMapping(StringRef Name, uint64_t Addr) {
std::string &V = EEState.getGlobalAddressReverseMap()[CurVal]; std::string &V = EEState.getGlobalAddressReverseMap()[CurVal];
assert((!V.empty() || !Name.empty()) && assert((!V.empty() || !Name.empty()) &&
"GlobalMapping already established!"); "GlobalMapping already established!");
V = Name; V = std::string(Name);
} }
return OldVal; return OldVal;
} }
@ -1200,8 +1200,8 @@ void ExecutionEngine::emitGlobals() {
GV.hasAppendingLinkage() || !GV.hasName()) GV.hasAppendingLinkage() || !GV.hasName())
continue;// Ignore external globals and globals with internal linkage. continue;// Ignore external globals and globals with internal linkage.
const GlobalValue *&GVEntry = const GlobalValue *&GVEntry = LinkedGlobalsMap[std::make_pair(
LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())]; std::string(GV.getName()), GV.getType())];
// If this is the first time we've seen this global, it is the canonical // If this is the first time we've seen this global, it is the canonical
// version. // version.
@ -1228,8 +1228,8 @@ void ExecutionEngine::emitGlobals() {
for (const auto &GV : M.globals()) { for (const auto &GV : M.globals()) {
// In the multi-module case, see what this global maps to. // In the multi-module case, see what this global maps to.
if (!LinkedGlobalsMap.empty()) { if (!LinkedGlobalsMap.empty()) {
if (const GlobalValue *GVEntry = if (const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair(
LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())]) { std::string(GV.getName()), GV.getType())]) {
// If something else is the canonical global, ignore this one. // If something else is the canonical global, ignore this one.
if (GVEntry != &GV) { if (GVEntry != &GV) {
NonCanonicalGlobals.push_back(&GV); NonCanonicalGlobals.push_back(&GV);
@ -1243,8 +1243,8 @@ void ExecutionEngine::emitGlobals() {
} else { } else {
// External variable reference. Try to use the dynamic loader to // External variable reference. Try to use the dynamic loader to
// get a pointer to it. // get a pointer to it.
if (void *SymAddr = if (void *SymAddr = sys::DynamicLibrary::SearchForAddressOfSymbol(
sys::DynamicLibrary::SearchForAddressOfSymbol(GV.getName())) std::string(GV.getName())))
addGlobalMapping(&GV, SymAddr); addGlobalMapping(&GV, SymAddr);
else { else {
report_fatal_error("Could not resolve external global address: " report_fatal_error("Could not resolve external global address: "
@ -1258,8 +1258,8 @@ void ExecutionEngine::emitGlobals() {
if (!NonCanonicalGlobals.empty()) { if (!NonCanonicalGlobals.empty()) {
for (unsigned i = 0, e = NonCanonicalGlobals.size(); i != e; ++i) { for (unsigned i = 0, e = NonCanonicalGlobals.size(); i != e; ++i) {
const GlobalValue *GV = NonCanonicalGlobals[i]; const GlobalValue *GV = NonCanonicalGlobals[i];
const GlobalValue *CGV = const GlobalValue *CGV = LinkedGlobalsMap[std::make_pair(
LinkedGlobalsMap[std::make_pair(GV->getName(), GV->getType())]; std::string(GV->getName()), GV->getType())];
void *Ptr = getPointerToGlobalIfAvailable(CGV); void *Ptr = getPointerToGlobalIfAvailable(CGV);
assert(Ptr && "Canonical global wasn't codegen'd!"); assert(Ptr && "Canonical global wasn't codegen'd!");
addGlobalMapping(GV, Ptr); addGlobalMapping(GV, Ptr);
@ -1271,8 +1271,8 @@ void ExecutionEngine::emitGlobals() {
for (const auto &GV : M.globals()) { for (const auto &GV : M.globals()) {
if (!GV.isDeclaration()) { if (!GV.isDeclaration()) {
if (!LinkedGlobalsMap.empty()) { if (!LinkedGlobalsMap.empty()) {
if (const GlobalValue *GVEntry = if (const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair(
LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())]) std::string(GV.getName()), GV.getType())])
if (GVEntry != &GV) // Not the canonical variable. if (GVEntry != &GV) // Not the canonical variable.
continue; continue;
} }

View File

@ -47,8 +47,8 @@ Expected<std::unique_ptr<LinkGraph>> MachOLinkGraphBuilder::buildGraph() {
MachOLinkGraphBuilder::MachOLinkGraphBuilder(const object::MachOObjectFile &Obj) MachOLinkGraphBuilder::MachOLinkGraphBuilder(const object::MachOObjectFile &Obj)
: Obj(Obj), : Obj(Obj),
G(std::make_unique<LinkGraph>(Obj.getFileName(), getPointerSize(Obj), G(std::make_unique<LinkGraph>(std::string(Obj.getFileName()),
getEndianness(Obj))) {} getPointerSize(Obj), getEndianness(Obj))) {}
void MachOLinkGraphBuilder::addCustomSectionParser( void MachOLinkGraphBuilder::addCustomSectionParser(
StringRef SectionName, SectionParserFunction Parser) { StringRef SectionName, SectionParserFunction Parser) {

View File

@ -609,7 +609,7 @@ GenericValue MCJIT::runFunction(Function *F, ArrayRef<GenericValue> ArgValues) {
void *MCJIT::getPointerToNamedFunction(StringRef Name, bool AbortOnFailure) { void *MCJIT::getPointerToNamedFunction(StringRef Name, bool AbortOnFailure) {
if (!isSymbolSearchingDisabled()) { if (!isSymbolSearchingDisabled()) {
if (auto Sym = Resolver.findSymbol(Name)) { if (auto Sym = Resolver.findSymbol(std::string(Name))) {
if (auto AddrOrErr = Sym.getAddress()) if (auto AddrOrErr = Sym.getAddress())
return reinterpret_cast<void*>( return reinterpret_cast<void*>(
static_cast<uintptr_t>(*AddrOrErr)); static_cast<uintptr_t>(*AddrOrErr));
@ -619,7 +619,7 @@ void *MCJIT::getPointerToNamedFunction(StringRef Name, bool AbortOnFailure) {
/// If a LazyFunctionCreator is installed, use it to get/create the function. /// If a LazyFunctionCreator is installed, use it to get/create the function.
if (LazyFunctionCreator) if (LazyFunctionCreator)
if (void *RP = LazyFunctionCreator(Name)) if (void *RP = LazyFunctionCreator(std::string(Name)))
return RP; return RP;
if (AbortOnFailure) { if (AbortOnFailure) {

View File

@ -35,7 +35,7 @@ static ThreadSafeModule extractSubModule(ThreadSafeModule &TSM,
Constant *Aliasee = A.getAliasee(); Constant *Aliasee = A.getAliasee();
assert(A.hasName() && "Anonymous alias?"); assert(A.hasName() && "Anonymous alias?");
assert(Aliasee->hasName() && "Anonymous aliasee"); assert(Aliasee->hasName() && "Anonymous aliasee");
std::string AliasName = A.getName(); std::string AliasName = std::string(A.getName());
if (isa<Function>(Aliasee)) { if (isa<Function>(Aliasee)) {
auto *F = cloneFunctionDecl(*A.getParent(), *cast<Function>(Aliasee)); auto *F = cloneFunctionDecl(*A.getParent(), *cast<Function>(Aliasee));

View File

@ -838,7 +838,7 @@ JITDylib::defineMaterializing(SymbolFlagsMap SymbolFlags) {
Symbols.erase(SI); Symbols.erase(SI);
// FIXME: Return all duplicates. // FIXME: Return all duplicates.
return make_error<DuplicateDefinition>(*Name); return make_error<DuplicateDefinition>(std::string(*Name));
} }
// Otherwise just make a note to discard this symbol after the loop. // Otherwise just make a note to discard this symbol after the loop.
@ -1815,7 +1815,7 @@ Error JITDylib::defineImpl(MaterializationUnit &MU) {
// If there were any duplicate definitions then bail out. // If there were any duplicate definitions then bail out.
if (!Duplicates.empty()) if (!Duplicates.empty())
return make_error<DuplicateDefinition>(**Duplicates.begin()); return make_error<DuplicateDefinition>(std::string(**Duplicates.begin()));
// Discard any overridden defs in this MU. // Discard any overridden defs in this MU.
for (auto &S : MUDefsOverridden) for (auto &S : MUDefsOverridden)

View File

@ -33,7 +33,7 @@ Expected<JITTargetMachineBuilder> JITTargetMachineBuilder::detectHost() {
for (auto &Feature : FeatureMap) for (auto &Feature : FeatureMap)
TMBuilder.getFeatures().AddFeature(Feature.first(), Feature.second); TMBuilder.getFeatures().AddFeature(Feature.first(), Feature.second);
TMBuilder.setCPU(llvm::sys::getHostCPUName()); TMBuilder.setCPU(std::string(llvm::sys::getHostCPUName()));
return TMBuilder; return TMBuilder;
} }

View File

@ -133,7 +133,7 @@ private:
orc::SymbolNameSet Result; orc::SymbolNameSet Result;
for (auto &S : Symbols) { for (auto &S : Symbols) {
if (auto Sym = findSymbol(*S)) { if (auto Sym = findSymbol(std::string(*S))) {
if (!Sym.getFlags().isStrong()) if (!Sym.getFlags().isStrong())
Result.insert(S); Result.insert(S);
} else if (auto Err = Sym.takeError()) { } else if (auto Err = Sym.takeError()) {
@ -151,7 +151,7 @@ private:
orc::SymbolNameSet UnresolvedSymbols; orc::SymbolNameSet UnresolvedSymbols;
for (auto &S : Symbols) { for (auto &S : Symbols) {
if (auto Sym = findSymbol(*S)) { if (auto Sym = findSymbol(std::string(*S))) {
if (auto Addr = Sym.getAddress()) { if (auto Addr = Sym.getAddress()) {
Query->notifySymbolMetRequiredState( Query->notifySymbolMetRequiredState(
S, JITEvaluatedSymbol(*Addr, Sym.getFlags())); S, JITEvaluatedSymbol(*Addr, Sym.getFlags()));

View File

@ -154,7 +154,8 @@ class OrcMCJITReplacement : public ExecutionEngine {
M.reportError(std::move(Err)); M.reportError(std::move(Err));
return SymbolNameSet(); return SymbolNameSet();
} else { } else {
if (auto Sym2 = M.ClientResolver->findSymbolInLogicalDylib(*S)) { if (auto Sym2 =
M.ClientResolver->findSymbolInLogicalDylib(std::string(*S))) {
if (!Sym2.getFlags().isStrong()) if (!Sym2.getFlags().isStrong())
Result.insert(S); Result.insert(S);
} else if (auto Err = Sym2.takeError()) { } else if (auto Err = Sym2.takeError()) {
@ -187,7 +188,7 @@ class OrcMCJITReplacement : public ExecutionEngine {
M.ES.legacyFailQuery(*Query, std::move(Err)); M.ES.legacyFailQuery(*Query, std::move(Err));
return SymbolNameSet(); return SymbolNameSet();
} else { } else {
if (auto Sym2 = M.ClientResolver->findSymbol(*S)) { if (auto Sym2 = M.ClientResolver->findSymbol(std::string(*S))) {
if (auto Addr = Sym2.getAddress()) { if (auto Addr = Sym2.getAddress()) {
Query->notifySymbolMetRequiredState( Query->notifySymbolMetRequiredState(
S, JITEvaluatedSymbol(*Addr, Sym2.getFlags())); S, JITEvaluatedSymbol(*Addr, Sym2.getFlags()));
@ -378,9 +379,9 @@ public:
private: private:
JITSymbol findMangledSymbol(StringRef Name) { JITSymbol findMangledSymbol(StringRef Name) {
if (auto Sym = LazyEmitLayer.findSymbol(Name, false)) if (auto Sym = LazyEmitLayer.findSymbol(std::string(Name), false))
return Sym; return Sym;
if (auto Sym = ClientResolver->findSymbol(Name)) if (auto Sym = ClientResolver->findSymbol(std::string(Name)))
return Sym; return Sym;
if (auto Sym = scanArchives(Name)) if (auto Sym = scanArchives(Name))
return Sym; return Sym;

View File

@ -74,7 +74,7 @@ class SectionEntry {
public: public:
SectionEntry(StringRef name, uint8_t *address, size_t size, SectionEntry(StringRef name, uint8_t *address, size_t size,
size_t allocationSize, uintptr_t objAddress) size_t allocationSize, uintptr_t objAddress)
: Name(name), Address(address), Size(size), : Name(std::string(name)), Address(address), Size(size),
LoadAddress(reinterpret_cast<uintptr_t>(address)), StubOffset(size), LoadAddress(reinterpret_cast<uintptr_t>(address)), StubOffset(size),
AllocationSize(allocationSize), ObjAddress(objAddress) { AllocationSize(allocationSize), ObjAddress(objAddress) {
// AllocationSize is used only in asserts, prevent an "unused private field" // AllocationSize is used only in asserts, prevent an "unused private field"

View File

@ -36,7 +36,7 @@ void llvm::parseFuzzerCLOpts(int ArgC, char *ArgV[]) {
} }
void llvm::handleExecNameEncodedBEOpts(StringRef ExecName) { void llvm::handleExecNameEncodedBEOpts(StringRef ExecName) {
std::vector<std::string> Args{ExecName}; std::vector<std::string> Args{std::string(ExecName)};
auto NameAndArgs = ExecName.split("--"); auto NameAndArgs = ExecName.split("--");
if (NameAndArgs.second.empty()) if (NameAndArgs.second.empty())
@ -73,7 +73,7 @@ void llvm::handleExecNameEncodedBEOpts(StringRef ExecName) {
void llvm::handleExecNameEncodedOptimizerOpts(StringRef ExecName) { void llvm::handleExecNameEncodedOptimizerOpts(StringRef ExecName) {
// TODO: Refactor parts common with the 'handleExecNameEncodedBEOpts' // TODO: Refactor parts common with the 'handleExecNameEncodedBEOpts'
std::vector<std::string> Args{ExecName}; std::vector<std::string> Args{std::string(ExecName)};
auto NameAndArgs = ExecName.split("--"); auto NameAndArgs = ExecName.split("--");
if (NameAndArgs.second.empty()) if (NameAndArgs.second.empty())

View File

@ -2693,7 +2693,7 @@ void AssemblyWriter::printModuleSummaryIndex() {
// A module id of -1 is a special entry for a regular LTO module created // A module id of -1 is a special entry for a regular LTO module created
// during the thin link. // during the thin link.
ModPath.second.first == -1u ? RegularLTOModuleName ModPath.second.first == -1u ? RegularLTOModuleName
: (std::string)ModPath.first(), : (std::string)std::string(ModPath.first()),
ModPath.second.second); ModPath.second.second);
unsigned i = 0; unsigned i = 0;

View File

@ -152,7 +152,8 @@ class StringAttributeImpl : public AttributeImpl {
public: public:
StringAttributeImpl(StringRef Kind, StringRef Val = StringRef()) StringAttributeImpl(StringRef Kind, StringRef Val = StringRef())
: AttributeImpl(StringAttrEntry), Kind(Kind), Val(Val) {} : AttributeImpl(StringAttrEntry), Kind(std::string(Kind)),
Val(std::string(Val)) {}
StringRef getStringKind() const { return Kind; } StringRef getStringKind() const { return Kind; }
StringRef getStringValue() const { return Val; } StringRef getStringValue() const { return Val; }

View File

@ -466,7 +466,7 @@ std::string Attribute::getAsString(bool InAttrGrp) const {
std::string Result; std::string Result;
Result += (Twine('"') + getKindAsString() + Twine('"')).str(); Result += (Twine('"') + getKindAsString() + Twine('"')).str();
std::string AttrVal = pImpl->getValueAsString(); std::string AttrVal = std::string(pImpl->getValueAsString());
if (AttrVal.empty()) return Result; if (AttrVal.empty()) return Result;
// Since some attribute strings contain special characters that cannot be // Since some attribute strings contain special characters that cannot be
@ -1481,7 +1481,7 @@ AttrBuilder &AttrBuilder::addAttribute(Attribute Attr) {
} }
AttrBuilder &AttrBuilder::addAttribute(StringRef A, StringRef V) { AttrBuilder &AttrBuilder::addAttribute(StringRef A, StringRef V) {
TargetDepAttrs[A] = V; TargetDepAttrs[std::string(A)] = std::string(V);
return *this; return *this;
} }

View File

@ -3663,7 +3663,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
// Replace the original call result with the first result of the new call. // Replace the original call result with the first result of the new call.
Value *TSC = Builder.CreateExtractValue(NewCall, 0); Value *TSC = Builder.CreateExtractValue(NewCall, 0);
std::string Name = CI->getName(); std::string Name = std::string(CI->getName());
if (!Name.empty()) { if (!Name.empty()) {
CI->setName(Name + ".old"); CI->setName(Name + ".old");
NewCall->setName(Name); NewCall->setName(Name);
@ -3738,7 +3738,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
} }
assert(NewCall && "Should have either set this variable or returned through " assert(NewCall && "Should have either set this variable or returned through "
"the default case"); "the default case");
std::string Name = CI->getName(); std::string Name = std::string(CI->getName());
if (!Name.empty()) { if (!Name.empty()) {
CI->setName(Name + ".old"); CI->setName(Name + ".old");
NewCall->setName(Name); NewCall->setName(Name);
@ -4080,7 +4080,7 @@ void llvm::UpgradeSectionAttributes(Module &M) {
for (auto Component : Components) for (auto Component : Components)
OS << ',' << Component.trim(); OS << ',' << Component.trim();
return OS.str().substr(1); return std::string(OS.str().substr(1));
}; };
for (auto &GV : M.globals()) { for (auto &GV : M.globals()) {
@ -4166,12 +4166,12 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) {
// If X86, and the datalayout matches the expected format, add pointer size // If X86, and the datalayout matches the expected format, add pointer size
// address spaces to the datalayout. // address spaces to the datalayout.
if (!Triple(TT).isX86() || DL.contains(AddrSpaces)) if (!Triple(TT).isX86() || DL.contains(AddrSpaces))
return DL; return std::string(DL);
SmallVector<StringRef, 4> Groups; SmallVector<StringRef, 4> Groups;
Regex R("(e-m:[a-z](-p:32:32)?)(-[if]64:.*$)"); Regex R("(e-m:[a-z](-p:32:32)?)(-[if]64:.*$)");
if (!R.match(DL, &Groups)) if (!R.match(DL, &Groups))
return DL; return std::string(DL);
SmallString<1024> Buf; SmallString<1024> Buf;
std::string Res = (Groups[1] + AddrSpaces + Groups[3]).toStringRef(Buf).str(); std::string Res = (Groups[1] + AddrSpaces + Groups[3]).toStringRef(Buf).str();

View File

@ -454,8 +454,8 @@ struct InlineAsmKeyType {
InlineAsm *create(TypeClass *Ty) const { InlineAsm *create(TypeClass *Ty) const {
assert(PointerType::getUnqual(FTy) == Ty); assert(PointerType::getUnqual(FTy) == Ty);
return new InlineAsm(FTy, AsmString, Constraints, HasSideEffects, return new InlineAsm(FTy, std::string(AsmString), std::string(Constraints),
IsAlignStack, AsmDialect); HasSideEffects, IsAlignStack, AsmDialect);
} }
}; };

View File

@ -229,7 +229,7 @@ static unsigned getAddrSpace(StringRef R) {
} }
void DataLayout::parseSpecifier(StringRef Desc) { void DataLayout::parseSpecifier(StringRef Desc) {
StringRepresentation = Desc; StringRepresentation = std::string(Desc);
while (!Desc.empty()) { while (!Desc.empty()) {
// Split at '-'. // Split at '-'.
std::pair<StringRef, StringRef> Split = split(Desc, '-'); std::pair<StringRef, StringRef> Split = split(Desc, '-');

View File

@ -132,7 +132,7 @@ StringRef DiagnosticLocation::getRelativePath() const {
std::string DiagnosticLocation::getAbsolutePath() const { std::string DiagnosticLocation::getAbsolutePath() const {
StringRef Name = File->getFilename(); StringRef Name = File->getFilename();
if (sys::path::is_absolute(Name)) if (sys::path::is_absolute(Name))
return Name; return std::string(Name);
SmallString<128> Path; SmallString<128> Path;
sys::path::append(Path, File->getDirectory(), Name); sys::path::append(Path, File->getDirectory(), Name);
@ -160,8 +160,9 @@ const std::string DiagnosticInfoWithLocationBase::getLocationStr() const {
return (Filename + ":" + Twine(Line) + ":" + Twine(Column)).str(); return (Filename + ":" + Twine(Line) + ":" + Twine(Column)).str();
} }
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Value *V) DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key,
: Key(Key) { const Value *V)
: Key(std::string(Key)) {
if (auto *F = dyn_cast<Function>(V)) { if (auto *F = dyn_cast<Function>(V)) {
if (DISubprogram *SP = F->getSubprogram()) if (DISubprogram *SP = F->getSubprogram())
Loc = SP; Loc = SP;
@ -172,7 +173,7 @@ DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Value *V
// Only include names that correspond to user variables. FIXME: We should use // Only include names that correspond to user variables. FIXME: We should use
// debug info if available to get the name of the user variable. // debug info if available to get the name of the user variable.
if (isa<llvm::Argument>(V) || isa<GlobalValue>(V)) if (isa<llvm::Argument>(V) || isa<GlobalValue>(V))
Val = GlobalValue::dropLLVMManglingEscape(V->getName()); Val = std::string(GlobalValue::dropLLVMManglingEscape(V->getName()));
else if (isa<Constant>(V)) { else if (isa<Constant>(V)) {
raw_string_ostream OS(Val); raw_string_ostream OS(Val);
V->printAsOperand(OS, /*PrintType=*/false); V->printAsOperand(OS, /*PrintType=*/false);
@ -181,39 +182,39 @@ DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Value *V
} }
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Type *T) DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Type *T)
: Key(Key) { : Key(std::string(Key)) {
raw_string_ostream OS(Val); raw_string_ostream OS(Val);
OS << *T; OS << *T;
} }
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, StringRef S) DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, StringRef S)
: Key(Key), Val(S.str()) {} : Key(std::string(Key)), Val(S.str()) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, int N) DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, int N)
: Key(Key), Val(itostr(N)) {} : Key(std::string(Key)), Val(itostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, float N) DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, float N)
: Key(Key), Val(llvm::to_string(N)) {} : Key(std::string(Key)), Val(llvm::to_string(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, long N) DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, long N)
: Key(Key), Val(itostr(N)) {} : Key(std::string(Key)), Val(itostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, long long N) DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, long long N)
: Key(Key), Val(itostr(N)) {} : Key(std::string(Key)), Val(itostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, unsigned N) DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, unsigned N)
: Key(Key), Val(utostr(N)) {} : Key(std::string(Key)), Val(utostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key,
unsigned long N) unsigned long N)
: Key(Key), Val(utostr(N)) {} : Key(std::string(Key)), Val(utostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key,
unsigned long long N) unsigned long long N)
: Key(Key), Val(utostr(N)) {} : Key(std::string(Key)), Val(utostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, DebugLoc Loc) DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, DebugLoc Loc)
: Key(Key), Loc(Loc) { : Key(std::string(Key)), Loc(Loc) {
if (Loc) { if (Loc) {
Val = (Loc->getFilename() + ":" + Twine(Loc.getLine()) + ":" + Val = (Loc->getFilename() + ":" + Twine(Loc.getLine()) + ":" +
Twine(Loc.getCol())).str(); Twine(Loc.getCol())).str();

View File

@ -143,7 +143,7 @@ std::string GlobalValue::getGlobalIdentifier(StringRef Name,
if (Name[0] == '\1') if (Name[0] == '\1')
Name = Name.substr(1); Name = Name.substr(1);
std::string NewName = Name; std::string NewName = std::string(Name);
if (llvm::GlobalValue::isLocalLinkage(Linkage)) { if (llvm::GlobalValue::isLocalLinkage(Linkage)) {
// For local symbols, prepend the main file name to distinguish them. // For local symbols, prepend the main file name to distinguish them.
// Do not include the full path in the file name since there's no guarantee // Do not include the full path in the file name since there's no guarantee

View File

@ -136,14 +136,14 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str,
// Find the end of the register name. // Find the end of the register name.
StringRef::iterator ConstraintEnd = std::find(I+1, E, '}'); StringRef::iterator ConstraintEnd = std::find(I+1, E, '}');
if (ConstraintEnd == E) return true; // "{foo" if (ConstraintEnd == E) return true; // "{foo"
pCodes->push_back(StringRef(I, ConstraintEnd+1 - I)); pCodes->push_back(std::string(StringRef(I, ConstraintEnd + 1 - I)));
I = ConstraintEnd+1; I = ConstraintEnd+1;
} else if (isdigit(static_cast<unsigned char>(*I))) { // Matching Constraint } else if (isdigit(static_cast<unsigned char>(*I))) { // Matching Constraint
// Maximal munch numbers. // Maximal munch numbers.
StringRef::iterator NumStart = I; StringRef::iterator NumStart = I;
while (I != E && isdigit(static_cast<unsigned char>(*I))) while (I != E && isdigit(static_cast<unsigned char>(*I)))
++I; ++I;
pCodes->push_back(StringRef(NumStart, I - NumStart)); pCodes->push_back(std::string(StringRef(NumStart, I - NumStart)));
unsigned N = atoi(pCodes->back().c_str()); unsigned N = atoi(pCodes->back().c_str());
// Check that this is a valid matching constraint! // Check that this is a valid matching constraint!
if (N >= ConstraintsSoFar.size() || ConstraintsSoFar[N].Type != isOutput|| if (N >= ConstraintsSoFar.size() || ConstraintsSoFar[N].Type != isOutput||
@ -179,7 +179,7 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str,
} else if (*I == '^') { } else if (*I == '^') {
// Multi-letter constraint // Multi-letter constraint
// FIXME: For now assuming these are 2-character constraints. // FIXME: For now assuming these are 2-character constraints.
pCodes->push_back(StringRef(I+1, 2)); pCodes->push_back(std::string(StringRef(I + 1, 2)));
I += 3; I += 3;
} else if (*I == '@') { } else if (*I == '@') {
// Multi-letter constraint // Multi-letter constraint
@ -189,11 +189,11 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str,
int N = C - '0'; int N = C - '0';
assert(N > 0 && "Found a zero letter constraint!"); assert(N > 0 && "Found a zero letter constraint!");
++I; ++I;
pCodes->push_back(StringRef(I, N)); pCodes->push_back(std::string(StringRef(I, N)));
I += N; I += N;
} else { } else {
// Single letter constraint. // Single letter constraint.
pCodes->push_back(StringRef(I, 1)); pCodes->push_back(std::string(StringRef(I, 1)));
++I; ++I;
} }
} }

View File

@ -132,7 +132,8 @@ bool llvm::forcePrintModuleIR() { return PrintModuleScope; }
bool llvm::isFunctionInPrintList(StringRef FunctionName) { bool llvm::isFunctionInPrintList(StringRef FunctionName) {
static std::unordered_set<std::string> PrintFuncNames(PrintFuncsList.begin(), static std::unordered_set<std::string> PrintFuncNames(PrintFuncsList.begin(),
PrintFuncsList.end()); PrintFuncsList.end());
return PrintFuncNames.empty() || PrintFuncNames.count(FunctionName); return PrintFuncNames.empty() ||
PrintFuncNames.count(std::string(FunctionName));
} }
/// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions
/// or higher is specified. /// or higher is specified.
@ -239,7 +240,7 @@ void PMDataManager::emitInstrCountChangedRemark(
// Helper lambda that emits a remark when the size of a function has changed. // Helper lambda that emits a remark when the size of a function has changed.
auto EmitFunctionSizeChangedRemark = [&FunctionToInstrCount, &F, &BB, auto EmitFunctionSizeChangedRemark = [&FunctionToInstrCount, &F, &BB,
&PassName](const std::string &Fname) { &PassName](StringRef Fname) {
unsigned FnCountBefore, FnCountAfter; unsigned FnCountBefore, FnCountAfter;
std::pair<unsigned, unsigned> &Change = FunctionToInstrCount[Fname]; std::pair<unsigned, unsigned> &Change = FunctionToInstrCount[Fname];
std::tie(FnCountBefore, FnCountAfter) = Change; std::tie(FnCountBefore, FnCountAfter) = Change;

View File

@ -72,7 +72,8 @@ template class llvm::SymbolTableListTraits<GlobalIFunc>;
Module::Module(StringRef MID, LLVMContext &C) Module::Module(StringRef MID, LLVMContext &C)
: Context(C), ValSymTab(std::make_unique<ValueSymbolTable>()), : Context(C), ValSymTab(std::make_unique<ValueSymbolTable>()),
Materializer(), ModuleID(MID), SourceFileName(MID), DL("") { Materializer(), ModuleID(std::string(MID)),
SourceFileName(std::string(MID)), DL("") {
Context.addModule(this); Context.addModule(this);
} }

View File

@ -144,7 +144,7 @@ Expected<NativeObjectCache> lto::localCache(StringRef CacheDirectoryPath,
// This CacheStream will move the temporary file into the cache when done. // This CacheStream will move the temporary file into the cache when done.
return std::make_unique<CacheStream>( return std::make_unique<CacheStream>(
std::make_unique<raw_fd_ostream>(Temp->FD, /* ShouldClose */ false), std::make_unique<raw_fd_ostream>(Temp->FD, /* ShouldClose */ false),
AddBuffer, std::move(*Temp), EntryPath.str(), Task); AddBuffer, std::move(*Temp), std::string(EntryPath.str()), Task);
}; };
}; };
} }

View File

@ -513,7 +513,7 @@ void LTO::addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
assert(!GlobalRes.Prevailing && assert(!GlobalRes.Prevailing &&
"Multiple prevailing defs are not allowed"); "Multiple prevailing defs are not allowed");
GlobalRes.Prevailing = true; GlobalRes.Prevailing = true;
GlobalRes.IRName = Sym.getIRName(); GlobalRes.IRName = std::string(Sym.getIRName());
} else if (!GlobalRes.Prevailing && GlobalRes.IRName.empty()) { } else if (!GlobalRes.Prevailing && GlobalRes.IRName.empty()) {
// Sometimes it can be two copies of symbol in a module and prevailing // Sometimes it can be two copies of symbol in a module and prevailing
// symbol can have no IR name. That might happen if symbol is defined in // symbol can have no IR name. That might happen if symbol is defined in
@ -521,7 +521,7 @@ void LTO::addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
// the same symbol we want to use IR name of the prevailing symbol. // the same symbol we want to use IR name of the prevailing symbol.
// Otherwise, if we haven't seen a prevailing symbol, set the name so that // Otherwise, if we haven't seen a prevailing symbol, set the name so that
// we can later use it to check if there is any prevailing copy in IR. // we can later use it to check if there is any prevailing copy in IR.
GlobalRes.IRName = Sym.getIRName(); GlobalRes.IRName = std::string(Sym.getIRName());
} }
// Set the partition to external if we know it is re-defined by the linker // Set the partition to external if we know it is re-defined by the linker
@ -762,7 +762,7 @@ LTO::addRegularLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
if (Sym.isCommon()) { if (Sym.isCommon()) {
// FIXME: We should figure out what to do about commons defined by asm. // FIXME: We should figure out what to do about commons defined by asm.
// For now they aren't reported correctly by ModuleSymbolTable. // For now they aren't reported correctly by ModuleSymbolTable.
auto &CommonRes = RegularLTO.Commons[Sym.getIRName()]; auto &CommonRes = RegularLTO.Commons[std::string(Sym.getIRName())];
CommonRes.Size = std::max(CommonRes.Size, Sym.getCommonSize()); CommonRes.Size = std::max(CommonRes.Size, Sym.getCommonSize());
CommonRes.Align = CommonRes.Align =
std::max(CommonRes.Align, MaybeAlign(Sym.getCommonAlignment())); std::max(CommonRes.Align, MaybeAlign(Sym.getCommonAlignment()));
@ -1191,7 +1191,7 @@ std::string lto::getThinLTOOutputFile(const std::string &Path,
llvm::errs() << "warning: could not create directory '" << ParentPath llvm::errs() << "warning: could not create directory '" << ParentPath
<< "': " << EC.message() << '\n'; << "': " << EC.message() << '\n';
} }
return NewPath.str(); return std::string(NewPath.str());
} }
namespace { namespace {
@ -1220,7 +1220,7 @@ public:
MapVector<StringRef, BitcodeModule> &ModuleMap) override { MapVector<StringRef, BitcodeModule> &ModuleMap) override {
StringRef ModulePath = BM.getModuleIdentifier(); StringRef ModulePath = BM.getModuleIdentifier();
std::string NewModulePath = std::string NewModulePath =
getThinLTOOutputFile(ModulePath, OldPrefix, NewPrefix); getThinLTOOutputFile(std::string(ModulePath), OldPrefix, NewPrefix);
if (LinkedObjectsFile) if (LinkedObjectsFile)
*LinkedObjectsFile << NewModulePath << '\n'; *LinkedObjectsFile << NewModulePath << '\n';
@ -1244,7 +1244,7 @@ public:
} }
if (OnWrite) if (OnWrite)
OnWrite(ModulePath); OnWrite(std::string(ModulePath));
return Error::success(); return Error::success();
} }
@ -1391,7 +1391,7 @@ Expected<std::unique_ptr<ToolOutputFile>>
lto::setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename, lto::setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename,
StringRef RemarksPasses, StringRef RemarksFormat, StringRef RemarksPasses, StringRef RemarksFormat,
bool RemarksWithHotness, int Count) { bool RemarksWithHotness, int Count) {
std::string Filename = RemarksFilename; std::string Filename = std::string(RemarksFilename);
// For ThinLTO, file.opt.<format> becomes // For ThinLTO, file.opt.<format> becomes
// file.opt.<format>.thin.<num>.<format>. // file.opt.<format>.thin.<num>.<format>.
if (!Filename.empty() && Count != -1) if (!Filename.empty() && Count != -1)

View File

@ -632,7 +632,7 @@ bool LTOCodeGenerator::compileOptimized(ArrayRef<raw_pwrite_stream *> Out) {
void LTOCodeGenerator::setCodeGenDebugOptions(ArrayRef<const char *> Options) { void LTOCodeGenerator::setCodeGenDebugOptions(ArrayRef<const char *> Options) {
for (StringRef Option : Options) for (StringRef Option : Options)
CodegenOptions.push_back(Option); CodegenOptions.push_back(std::string(Option));
} }
void LTOCodeGenerator::parseCodeGenDebugOptions() { void LTOCodeGenerator::parseCodeGenDebugOptions() {

View File

@ -870,11 +870,11 @@ ThinLTOCodeGenerator::writeGeneratedObject(int count, StringRef CacheEntryPath,
// Cache is enabled, hard-link the entry (or copy if hard-link fails). // Cache is enabled, hard-link the entry (or copy if hard-link fails).
auto Err = sys::fs::create_hard_link(CacheEntryPath, OutputPath); auto Err = sys::fs::create_hard_link(CacheEntryPath, OutputPath);
if (!Err) if (!Err)
return OutputPath.str(); return std::string(OutputPath.str());
// Hard linking failed, try to copy. // Hard linking failed, try to copy.
Err = sys::fs::copy_file(CacheEntryPath, OutputPath); Err = sys::fs::copy_file(CacheEntryPath, OutputPath);
if (!Err) if (!Err)
return OutputPath.str(); return std::string(OutputPath.str());
// Copy failed (could be because the CacheEntry was removed from the cache // Copy failed (could be because the CacheEntry was removed from the cache
// in the meantime by another process), fall back and try to write down the // in the meantime by another process), fall back and try to write down the
// buffer to the output. // buffer to the output.
@ -887,7 +887,7 @@ ThinLTOCodeGenerator::writeGeneratedObject(int count, StringRef CacheEntryPath,
if (Err) if (Err)
report_fatal_error("Can't open output '" + OutputPath + "'\n"); report_fatal_error("Can't open output '" + OutputPath + "'\n");
OS << OutputBuffer.getBuffer(); OS << OutputBuffer.getBuffer();
return OutputPath.str(); return std::string(OutputPath.str());
} }
// Main entry point for the ThinLTO processing // Main entry point for the ThinLTO processing

View File

@ -24,7 +24,7 @@ std::string LineEditor::getDefaultHistoryPath(StringRef ProgName) {
SmallString<32> Path; SmallString<32> Path;
if (sys::path::home_directory(Path)) { if (sys::path::home_directory(Path)) {
sys::path::append(Path, "." + ProgName + "-history"); sys::path::append(Path, "." + ProgName + "-history");
return Path.str(); return std::string(Path.str());
} }
return std::string(); return std::string();
} }
@ -197,7 +197,7 @@ unsigned char ElCompletionFn(EditLine *EL, int ch) {
LineEditor::LineEditor(StringRef ProgName, StringRef HistoryPath, FILE *In, LineEditor::LineEditor(StringRef ProgName, StringRef HistoryPath, FILE *In,
FILE *Out, FILE *Err) FILE *Out, FILE *Err)
: Prompt((ProgName + "> ").str()), HistoryPath(HistoryPath), : Prompt((ProgName + "> ").str()), HistoryPath(std::string(HistoryPath)),
Data(new InternalData) { Data(new InternalData) {
if (HistoryPath.empty()) if (HistoryPath.empty())
this->HistoryPath = getDefaultHistoryPath(ProgName); this->HistoryPath = getDefaultHistoryPath(ProgName);

View File

@ -68,8 +68,8 @@ MCContext::MCContext(const MCAsmInfo *mai, const MCRegisterInfo *mri,
SecureLogFile = AsSecureLogFileName; SecureLogFile = AsSecureLogFileName;
if (SrcMgr && SrcMgr->getNumBuffers()) if (SrcMgr && SrcMgr->getNumBuffers())
MainFileName = MainFileName = std::string(SrcMgr->getMemoryBuffer(SrcMgr->getMainFileID())
SrcMgr->getMemoryBuffer(SrcMgr->getMainFileID())->getBufferIdentifier(); ->getBufferIdentifier());
} }
MCContext::~MCContext() { MCContext::~MCContext() {
@ -593,7 +593,7 @@ void MCContext::RemapDebugPaths() {
}; };
// Remap compilation directory. // Remap compilation directory.
std::string CompDir = CompilationDir.str(); std::string CompDir = std::string(CompilationDir.str());
RemapDebugPath(CompDir); RemapDebugPath(CompDir);
CompilationDir = CompDir; CompilationDir = CompDir;

View File

@ -620,7 +620,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
} else { } else {
DirIndex = llvm::find(MCDwarfDirs, Directory) - MCDwarfDirs.begin(); DirIndex = llvm::find(MCDwarfDirs, Directory) - MCDwarfDirs.begin();
if (DirIndex >= MCDwarfDirs.size()) if (DirIndex >= MCDwarfDirs.size())
MCDwarfDirs.push_back(Directory); MCDwarfDirs.push_back(std::string(Directory));
// The DirIndex is one based, as DirIndex of 0 is used for FileNames with // The DirIndex is one based, as DirIndex of 0 is used for FileNames with
// no directories. MCDwarfDirs[] is unlike MCDwarfFiles[] in that the // no directories. MCDwarfDirs[] is unlike MCDwarfFiles[] in that the
// directory names are stored at MCDwarfDirs[DirIndex-1] where FileNames // directory names are stored at MCDwarfDirs[DirIndex-1] where FileNames
@ -628,7 +628,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
DirIndex++; DirIndex++;
} }
File.Name = FileName; File.Name = std::string(FileName);
File.DirIndex = DirIndex; File.DirIndex = DirIndex;
File.Checksum = Checksum; File.Checksum = Checksum;
trackMD5Usage(Checksum.hasValue()); trackMD5Usage(Checksum.hasValue());

View File

@ -2358,7 +2358,7 @@ void AsmParser::DiagHandler(const SMDiagnostic &Diag, void *Context) {
// Use the CppHashFilename and calculate a line number based on the // Use the CppHashFilename and calculate a line number based on the
// CppHashInfo.Loc and CppHashInfo.LineNumber relative to this Diag's SMLoc // CppHashInfo.Loc and CppHashInfo.LineNumber relative to this Diag's SMLoc
// for the diagnostic. // for the diagnostic.
const std::string &Filename = Parser->CppHashInfo.Filename; const std::string &Filename = std::string(Parser->CppHashInfo.Filename);
int DiagLocLineNo = DiagSrcMgr.FindLineNumber(DiagLoc, DiagBuf); int DiagLocLineNo = DiagSrcMgr.FindLineNumber(DiagLoc, DiagBuf);
int CppHashLocLineNo = int CppHashLocLineNo =

View File

@ -672,7 +672,7 @@ bool DarwinAsmParser::parseDirectiveSection(StringRef, SMLoc) {
if (!getLexer().is(AsmToken::Comma)) if (!getLexer().is(AsmToken::Comma))
return TokError("unexpected token in '.section' directive"); return TokError("unexpected token in '.section' directive");
std::string SectionSpec = SectionName; std::string SectionSpec = std::string(SectionName);
SectionSpec += ","; SectionSpec += ",";
// Add all the tokens until the end of the line, ParseSectionSpecifier will // Add all the tokens until the end of the line, ParseSectionSpecifier will

View File

@ -206,15 +206,17 @@ void MCSubtargetInfo::setDefaultFeatures(StringRef CPU, StringRef FS) {
FeatureBits = getFeatures(CPU, FS, ProcDesc, ProcFeatures); FeatureBits = getFeatures(CPU, FS, ProcDesc, ProcFeatures);
} }
MCSubtargetInfo::MCSubtargetInfo( MCSubtargetInfo::MCSubtargetInfo(const Triple &TT, StringRef C, StringRef FS,
const Triple &TT, StringRef C, StringRef FS, ArrayRef<SubtargetFeatureKV> PF,
ArrayRef<SubtargetFeatureKV> PF, ArrayRef<SubtargetSubTypeKV> PD, ArrayRef<SubtargetSubTypeKV> PD,
const MCWriteProcResEntry *WPR, const MCWriteProcResEntry *WPR,
const MCWriteLatencyEntry *WL, const MCReadAdvanceEntry *RA, const MCWriteLatencyEntry *WL,
const InstrStage *IS, const unsigned *OC, const unsigned *FP) const MCReadAdvanceEntry *RA,
: TargetTriple(TT), CPU(C), ProcFeatures(PF), ProcDesc(PD), const InstrStage *IS, const unsigned *OC,
WriteProcResTable(WPR), WriteLatencyTable(WL), const unsigned *FP)
ReadAdvanceTable(RA), Stages(IS), OperandCycles(OC), ForwardingPaths(FP) { : TargetTriple(TT), CPU(std::string(C)), ProcFeatures(PF), ProcDesc(PD),
WriteProcResTable(WPR), WriteLatencyTable(WL), ReadAdvanceTable(RA),
Stages(IS), OperandCycles(OC), ForwardingPaths(FP) {
InitMCProcessorInfo(CPU, FS); InitMCProcessorInfo(CPU, FS);
} }

Some files were not shown because too many files have changed in this diff Show More