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
/// @{
operator std::string() const {
return str();
}
operator std::string() const { return str(); }
#if __cplusplus > 201402L
operator std::string_view() const {

View File

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

View File

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

View File

@ -129,7 +129,7 @@ public:
void setAvailableWithName(LibFunc F, StringRef Name) {
if (StandardNames[F] != Name) {
setState(F, CustomName);
CustomNames[F] = Name;
CustomNames[F] = std::string(Name);
assert(CustomNames.find(F) != CustomNames.end());
} else {
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,
// this will set the CPU to an empty string which tells the target to
// pick a basic default.
if (MCPU == "native")
return sys::getHostCPUName();
if (MCPU == "native") return std::string(sys::getHostCPUName());
return MCPU;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -273,22 +273,22 @@ public:
/// @{
/// 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.
void setSourceFileName(StringRef Name) { SourceFileName = Name; }
void setSourceFileName(StringRef Name) { SourceFileName = std::string(Name); }
/// Set the data layout
void setDataLayout(StringRef Desc);
void setDataLayout(const DataLayout &Other);
/// 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.
/// A trailing newline is added if the input doesn't have one.
void setModuleInlineAsm(StringRef Asm) {
GlobalScopeAsm = Asm;
GlobalScopeAsm = std::string(Asm);
if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n')
GlobalScopeAsm += '\n';
}

View File

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

View File

@ -262,7 +262,7 @@ template <> struct CustomMappingTraits<TypeIdSummaryMapTy> {
static void inputOne(IO &io, StringRef Key, TypeIdSummaryMapTy &V) {
TypeIdSummary 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) {
for (auto TidIter = V.begin(); TidIter != V.end(); TidIter++)

View File

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

View File

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

View File

@ -541,7 +541,7 @@ namespace llvm {
const std::string &getMainFileName() const { return MainFileName; }
/// 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.
Expected<unsigned> getDwarfFile(StringRef Directory, StringRef FileName,

View File

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

View File

@ -77,7 +77,9 @@ public:
}
return "env";
}
void setImportModule(StringRef Name) { ImportModule = Name; }
void setImportModule(StringRef Name) {
ImportModule = std::string(std::string(Name));
}
bool hasImportName() const { return ImportName.hasValue(); }
const StringRef getImportName() const {
@ -86,11 +88,15 @@ public:
}
return getName();
}
void setImportName(StringRef Name) { ImportName = Name; }
void setImportName(StringRef Name) {
ImportName = std::string(std::string(Name));
}
bool hasExportName() const { return ExportName.hasValue(); }
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; }
bool isUsedInGOT() const { return IsUsedInGOT; }

View File

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

View File

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

View File

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

View File

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

View File

@ -562,7 +562,7 @@ StringRef InstrProfSymtab::getFuncName(uint64_t FuncMD5Hash) {
finalizeSymtab();
auto Result =
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; });
if (Result != MD5NameMap.end() && Result->first == FuncMD5Hash)
return Result->second;

View File

@ -68,7 +68,7 @@ public:
// 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.
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) {
if (!isCountingEnabled())

View File

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

View File

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

View File

@ -44,7 +44,7 @@ public:
/// Construct a named SmallVectorMemoryBuffer from the given
/// SmallVector r-value and StringRef.
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);
}

View File

@ -1936,7 +1936,7 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
using map_type = std::map<std::string, T>;
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) {

View File

@ -614,7 +614,9 @@ public:
bool isConcrete() const override { return true; }
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 {
llvm_unreachable("Illegal bit reference off string");
@ -649,7 +651,9 @@ public:
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 {
llvm_unreachable("Illegal bit reference off string");
@ -1098,7 +1102,7 @@ public:
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.

View File

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

View File

@ -158,7 +158,7 @@ public:
/// Set the path from which this file was generated (if applicable).
///
/// \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).
///
@ -217,7 +217,9 @@ public:
const_filtered_target_range targets(ArchitectureSet Archs) const;
/// 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.
StringRef getInstallName() const { return InstallName; }

View File

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

View File

@ -1801,11 +1801,12 @@ LazyCallGraphDOTPrinterPass::LazyCallGraphDOTPrinterPass(raw_ostream &OS)
: OS(OS) {}
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()) {
OS << " " << Name << " -> \""
<< DOT::EscapeString(E.getFunction().getName()) << "\"";
<< DOT::EscapeString(std::string(E.getFunction().getName())) << "\"";
if (!E.isCall()) // It is a ref edge.
OS << " [style=dashed,label=\"ref\"]";
OS << ";\n";

View File

@ -403,7 +403,7 @@ Optional<VFInfo> VFABI::tryDemangleForVFABI(StringRef MangledName) {
"The global predicate must be the last parameter");
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) {

View File

@ -1180,7 +1180,7 @@ void VFABI::getVectorVariantNames(
assert(CI.getModule()->getFunction(Info.getValue().VectorName) &&
"Vector function is missing.");
#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 {
if (GlobalName.empty())
return TokError("comdat cannot be unnamed");
C = getComdat(GlobalName, KwLoc);
C = getComdat(std::string(GlobalName), KwLoc);
}
return false;
@ -5546,7 +5546,7 @@ bool LLParser::PerFunctionState::resolveForwardRefBlockAddresses() {
ValID ID;
if (FunctionNumber == -1) {
ID.Kind = ValID::t_GlobalName;
ID.StrVal = F.getName();
ID.StrVal = std::string(F.getName());
} else {
ID.Kind = ValID::t_GlobalID;
ID.UIntVal = FunctionNumber;

View File

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

View File

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

View File

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

View File

@ -119,9 +119,9 @@ public:
std::string TypeName;
if (!TI.isNoneType()) {
if (TI.isSimple())
TypeName = TypeIndex::simpleTypeName(TI);
TypeName = std::string(TypeIndex::simpleTypeName(TI));
else
TypeName = TypeTable.getTypeName(TI);
TypeName = std::string(TypeTable.getTypeName(TI));
}
return TypeName;
}
@ -183,7 +183,7 @@ StringRef CodeViewDebug::getFullFilepath(const DIFile *File) {
if (Dir.startswith("/") || Filename.startswith("/")) {
if (llvm::sys::path::is_absolute(Filename, llvm::sys::path::Style::posix))
return Filename;
Filepath = Dir;
Filepath = std::string(Dir);
if (Dir.back() != '/')
Filepath += '/';
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.
// For now, just concatenate and canonicalize the path here.
if (Filename.find(':') == 1)
Filepath = Filename;
Filepath = std::string(Filename);
else
Filepath = (Dir + "\\" + Filename).str();
@ -322,10 +322,10 @@ static std::string getQualifiedName(ArrayRef<StringRef> QualifiedNameComponents,
std::string FullyQualifiedName;
for (StringRef QualifiedNameComponent :
llvm::reverse(QualifiedNameComponents)) {
FullyQualifiedName.append(QualifiedNameComponent);
FullyQualifiedName.append(std::string(QualifiedNameComponent));
FullyQualifiedName.append("::");
}
FullyQualifiedName.append(TypeName);
FullyQualifiedName.append(std::string(TypeName));
return FullyQualifiedName;
}
@ -943,7 +943,8 @@ void CodeViewDebug::switchToDebugSectionForSymbol(const MCSymbol *GVSym) {
void CodeViewDebug::emitDebugInfoForThunk(const Function *GV,
FunctionInfo &FI,
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.
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 (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.
if (Triple(MMI->getModule()->getTargetTriple()).getArch() == Triple::x86)

View File

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

View File

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

View File

@ -523,7 +523,7 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals,
const StructLayout *MergedLayout = DL.getStructLayout(MergedTy);
for (ssize_t k = i, idx = 0; k != j; k = GlobalSet.find_next(k), ++idx) {
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::DLLStorageClassTypes DLLStorage =
Globals[k]->getDLLStorageClass();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -185,7 +185,7 @@ static void analyzeImportedModule(
Twine("Conflicting parseable interfaces for Swift Module ") +
*Name + ": " + Entry + " and " + Path,
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);
// FIXME: The missing space here may be a bug, but
// dsymutil-classic also does it this way.
MethodNameNoCategory.append(SelectorStart);
MethodNameNoCategory.append(std::string(SelectorStart));
Unit.addNameAccelerator(Die, StringPool.getEntry(MethodNameNoCategory),
SkipPubSection);
}

View File

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

View File

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

View File

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

View File

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

View File

@ -21,7 +21,7 @@ std::string LookupResult::getSourceFile(uint32_t Index) const {
if (Index < Locations.size()) {
if (!Locations[Index].Dir.empty()) {
if (Locations[Index].Base.empty()) {
Fullpath = Locations[Index].Dir;
Fullpath = std::string(Locations[Index].Dir);
} else {
llvm::SmallString<64> Storage;
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());
}
} else if (!Locations[Index].Base.empty())
Fullpath = Locations[Index].Base;
Fullpath = std::string(Locations[Index].Base);
}
return Fullpath;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -51,7 +51,9 @@ SymIndexId NativeSymbolEnumerator::getClassParentId() const {
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 {
return Parent.getTypeId();

View File

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

View File

@ -20,7 +20,9 @@ void NativeTypeTypedef::dump(raw_ostream &OS, int Indent,
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 {
return Session.getSymbolCache().findSymbolByTypeIndex(Record.Type);

View File

@ -74,7 +74,7 @@ std::string NativeTypeUDT::getName() const {
if (UnmodifiedType)
return UnmodifiedType->getName();
return Tag->getName();
return std::string(Tag->getName());
}
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,
BumpPtrAllocator &Allocator)
: FilePath(Path), Allocator(Allocator), Buffer(std::move(PdbFileBuffer)) {}
: FilePath(std::string(Path)), Allocator(Allocator),
Buffer(std::move(PdbFileBuffer)) {}
PDBFile::~PDBFile() = default;

View File

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

View File

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

View File

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

View File

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

View File

@ -47,8 +47,8 @@ Expected<std::unique_ptr<LinkGraph>> MachOLinkGraphBuilder::buildGraph() {
MachOLinkGraphBuilder::MachOLinkGraphBuilder(const object::MachOObjectFile &Obj)
: Obj(Obj),
G(std::make_unique<LinkGraph>(Obj.getFileName(), getPointerSize(Obj),
getEndianness(Obj))) {}
G(std::make_unique<LinkGraph>(std::string(Obj.getFileName()),
getPointerSize(Obj), getEndianness(Obj))) {}
void MachOLinkGraphBuilder::addCustomSectionParser(
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) {
if (!isSymbolSearchingDisabled()) {
if (auto Sym = Resolver.findSymbol(Name)) {
if (auto Sym = Resolver.findSymbol(std::string(Name))) {
if (auto AddrOrErr = Sym.getAddress())
return reinterpret_cast<void*>(
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 (LazyFunctionCreator)
if (void *RP = LazyFunctionCreator(Name))
if (void *RP = LazyFunctionCreator(std::string(Name)))
return RP;
if (AbortOnFailure) {

View File

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

View File

@ -838,7 +838,7 @@ JITDylib::defineMaterializing(SymbolFlagsMap SymbolFlags) {
Symbols.erase(SI);
// 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.
@ -1815,7 +1815,7 @@ Error JITDylib::defineImpl(MaterializationUnit &MU) {
// If there were any duplicate definitions then bail out.
if (!Duplicates.empty())
return make_error<DuplicateDefinition>(**Duplicates.begin());
return make_error<DuplicateDefinition>(std::string(**Duplicates.begin()));
// Discard any overridden defs in this MU.
for (auto &S : MUDefsOverridden)

View File

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

View File

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

View File

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

View File

@ -74,7 +74,7 @@ class SectionEntry {
public:
SectionEntry(StringRef name, uint8_t *address, size_t size,
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),
AllocationSize(allocationSize), ObjAddress(objAddress) {
// 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) {
std::vector<std::string> Args{ExecName};
std::vector<std::string> Args{std::string(ExecName)};
auto NameAndArgs = ExecName.split("--");
if (NameAndArgs.second.empty())
@ -73,7 +73,7 @@ void llvm::handleExecNameEncodedBEOpts(StringRef ExecName) {
void llvm::handleExecNameEncodedOptimizerOpts(StringRef ExecName) {
// 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("--");
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
// during the thin link.
ModPath.second.first == -1u ? RegularLTOModuleName
: (std::string)ModPath.first(),
: (std::string)std::string(ModPath.first()),
ModPath.second.second);
unsigned i = 0;

View File

@ -152,7 +152,8 @@ class StringAttributeImpl : public AttributeImpl {
public:
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 getStringValue() const { return Val; }

View File

@ -466,7 +466,7 @@ std::string Attribute::getAsString(bool InAttrGrp) const {
std::string Result;
Result += (Twine('"') + getKindAsString() + Twine('"')).str();
std::string AttrVal = pImpl->getValueAsString();
std::string AttrVal = std::string(pImpl->getValueAsString());
if (AttrVal.empty()) return Result;
// 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) {
TargetDepAttrs[A] = V;
TargetDepAttrs[std::string(A)] = std::string(V);
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.
Value *TSC = Builder.CreateExtractValue(NewCall, 0);
std::string Name = CI->getName();
std::string Name = std::string(CI->getName());
if (!Name.empty()) {
CI->setName(Name + ".old");
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 "
"the default case");
std::string Name = CI->getName();
std::string Name = std::string(CI->getName());
if (!Name.empty()) {
CI->setName(Name + ".old");
NewCall->setName(Name);
@ -4080,7 +4080,7 @@ void llvm::UpgradeSectionAttributes(Module &M) {
for (auto Component : Components)
OS << ',' << Component.trim();
return OS.str().substr(1);
return std::string(OS.str().substr(1));
};
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
// address spaces to the datalayout.
if (!Triple(TT).isX86() || DL.contains(AddrSpaces))
return DL;
return std::string(DL);
SmallVector<StringRef, 4> Groups;
Regex R("(e-m:[a-z](-p:32:32)?)(-[if]64:.*$)");
if (!R.match(DL, &Groups))
return DL;
return std::string(DL);
SmallString<1024> Buf;
std::string Res = (Groups[1] + AddrSpaces + Groups[3]).toStringRef(Buf).str();

View File

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

View File

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

View File

@ -132,7 +132,7 @@ StringRef DiagnosticLocation::getRelativePath() const {
std::string DiagnosticLocation::getAbsolutePath() const {
StringRef Name = File->getFilename();
if (sys::path::is_absolute(Name))
return Name;
return std::string(Name);
SmallString<128> Path;
sys::path::append(Path, File->getDirectory(), Name);
@ -160,8 +160,9 @@ const std::string DiagnosticInfoWithLocationBase::getLocationStr() const {
return (Filename + ":" + Twine(Line) + ":" + Twine(Column)).str();
}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Value *V)
: Key(Key) {
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key,
const Value *V)
: Key(std::string(Key)) {
if (auto *F = dyn_cast<Function>(V)) {
if (DISubprogram *SP = F->getSubprogram())
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
// debug info if available to get the name of the user variable.
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)) {
raw_string_ostream OS(Val);
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)
: Key(Key) {
: Key(std::string(Key)) {
raw_string_ostream OS(Val);
OS << *T;
}
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)
: Key(Key), Val(itostr(N)) {}
: Key(std::string(Key)), Val(itostr(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)
: Key(Key), Val(itostr(N)) {}
: Key(std::string(Key)), Val(itostr(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)
: Key(Key), Val(utostr(N)) {}
: Key(std::string(Key)), Val(utostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key,
unsigned long N)
: Key(Key), Val(utostr(N)) {}
: Key(std::string(Key)), Val(utostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key,
unsigned long long N)
: Key(Key), Val(utostr(N)) {}
: Key(std::string(Key)), Val(utostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, DebugLoc Loc)
: Key(Key), Loc(Loc) {
: Key(std::string(Key)), Loc(Loc) {
if (Loc) {
Val = (Loc->getFilename() + ":" + Twine(Loc.getLine()) + ":" +
Twine(Loc.getCol())).str();

View File

@ -143,7 +143,7 @@ std::string GlobalValue::getGlobalIdentifier(StringRef Name,
if (Name[0] == '\1')
Name = Name.substr(1);
std::string NewName = Name;
std::string NewName = std::string(Name);
if (llvm::GlobalValue::isLocalLinkage(Linkage)) {
// 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

View File

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

View File

@ -132,7 +132,8 @@ bool llvm::forcePrintModuleIR() { return PrintModuleScope; }
bool llvm::isFunctionInPrintList(StringRef FunctionName) {
static std::unordered_set<std::string> PrintFuncNames(PrintFuncsList.begin(),
PrintFuncsList.end());
return PrintFuncNames.empty() || PrintFuncNames.count(FunctionName);
return PrintFuncNames.empty() ||
PrintFuncNames.count(std::string(FunctionName));
}
/// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions
/// 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.
auto EmitFunctionSizeChangedRemark = [&FunctionToInstrCount, &F, &BB,
&PassName](const std::string &Fname) {
&PassName](StringRef Fname) {
unsigned FnCountBefore, FnCountAfter;
std::pair<unsigned, unsigned> &Change = FunctionToInstrCount[Fname];
std::tie(FnCountBefore, FnCountAfter) = Change;

View File

@ -72,7 +72,8 @@ template class llvm::SymbolTableListTraits<GlobalIFunc>;
Module::Module(StringRef MID, LLVMContext &C)
: 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);
}

View File

@ -144,7 +144,7 @@ Expected<NativeObjectCache> lto::localCache(StringRef CacheDirectoryPath,
// This CacheStream will move the temporary file into the cache when done.
return std::make_unique<CacheStream>(
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 &&
"Multiple prevailing defs are not allowed");
GlobalRes.Prevailing = true;
GlobalRes.IRName = Sym.getIRName();
GlobalRes.IRName = std::string(Sym.getIRName());
} else if (!GlobalRes.Prevailing && GlobalRes.IRName.empty()) {
// 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
@ -521,7 +521,7 @@ void LTO::addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
// 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
// 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
@ -762,7 +762,7 @@ LTO::addRegularLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
if (Sym.isCommon()) {
// FIXME: We should figure out what to do about commons defined by asm.
// 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.Align =
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
<< "': " << EC.message() << '\n';
}
return NewPath.str();
return std::string(NewPath.str());
}
namespace {
@ -1220,7 +1220,7 @@ public:
MapVector<StringRef, BitcodeModule> &ModuleMap) override {
StringRef ModulePath = BM.getModuleIdentifier();
std::string NewModulePath =
getThinLTOOutputFile(ModulePath, OldPrefix, NewPrefix);
getThinLTOOutputFile(std::string(ModulePath), OldPrefix, NewPrefix);
if (LinkedObjectsFile)
*LinkedObjectsFile << NewModulePath << '\n';
@ -1244,7 +1244,7 @@ public:
}
if (OnWrite)
OnWrite(ModulePath);
OnWrite(std::string(ModulePath));
return Error::success();
}
@ -1391,7 +1391,7 @@ Expected<std::unique_ptr<ToolOutputFile>>
lto::setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename,
StringRef RemarksPasses, StringRef RemarksFormat,
bool RemarksWithHotness, int Count) {
std::string Filename = RemarksFilename;
std::string Filename = std::string(RemarksFilename);
// For ThinLTO, file.opt.<format> becomes
// file.opt.<format>.thin.<num>.<format>.
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) {
for (StringRef Option : Options)
CodegenOptions.push_back(Option);
CodegenOptions.push_back(std::string(Option));
}
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).
auto Err = sys::fs::create_hard_link(CacheEntryPath, OutputPath);
if (!Err)
return OutputPath.str();
return std::string(OutputPath.str());
// Hard linking failed, try to copy.
Err = sys::fs::copy_file(CacheEntryPath, OutputPath);
if (!Err)
return OutputPath.str();
return std::string(OutputPath.str());
// 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
// buffer to the output.
@ -887,7 +887,7 @@ ThinLTOCodeGenerator::writeGeneratedObject(int count, StringRef CacheEntryPath,
if (Err)
report_fatal_error("Can't open output '" + OutputPath + "'\n");
OS << OutputBuffer.getBuffer();
return OutputPath.str();
return std::string(OutputPath.str());
}
// Main entry point for the ThinLTO processing

View File

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

View File

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

View File

@ -620,7 +620,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
} else {
DirIndex = llvm::find(MCDwarfDirs, Directory) - MCDwarfDirs.begin();
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
// no directories. MCDwarfDirs[] is unlike MCDwarfFiles[] in that the
// directory names are stored at MCDwarfDirs[DirIndex-1] where FileNames
@ -628,7 +628,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
DirIndex++;
}
File.Name = FileName;
File.Name = std::string(FileName);
File.DirIndex = DirIndex;
File.Checksum = Checksum;
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
// CppHashInfo.Loc and CppHashInfo.LineNumber relative to this Diag's SMLoc
// 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 CppHashLocLineNo =

View File

@ -672,7 +672,7 @@ bool DarwinAsmParser::parseDirectiveSection(StringRef, SMLoc) {
if (!getLexer().is(AsmToken::Comma))
return TokError("unexpected token in '.section' directive");
std::string SectionSpec = SectionName;
std::string SectionSpec = std::string(SectionName);
SectionSpec += ",";
// 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);
}
MCSubtargetInfo::MCSubtargetInfo(
const Triple &TT, StringRef C, StringRef FS,
ArrayRef<SubtargetFeatureKV> PF, ArrayRef<SubtargetSubTypeKV> PD,
const MCWriteProcResEntry *WPR,
const MCWriteLatencyEntry *WL, const MCReadAdvanceEntry *RA,
const InstrStage *IS, const unsigned *OC, const unsigned *FP)
: TargetTriple(TT), CPU(C), ProcFeatures(PF), ProcDesc(PD),
WriteProcResTable(WPR), WriteLatencyTable(WL),
ReadAdvanceTable(RA), Stages(IS), OperandCycles(OC), ForwardingPaths(FP) {
MCSubtargetInfo::MCSubtargetInfo(const Triple &TT, StringRef C, StringRef FS,
ArrayRef<SubtargetFeatureKV> PF,
ArrayRef<SubtargetSubTypeKV> PD,
const MCWriteProcResEntry *WPR,
const MCWriteLatencyEntry *WL,
const MCReadAdvanceEntry *RA,
const InstrStage *IS, const unsigned *OC,
const unsigned *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);
}

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