Index: COFF/Driver.cpp =================================================================== --- COFF/Driver.cpp +++ COFF/Driver.cpp @@ -426,7 +426,7 @@ case OPT_manifestuac: break; default: - OS << toString(Arg) << "\n"; + OS << toString(*Arg) << "\n"; } } @@ -674,7 +674,7 @@ break; case OPT_opt: if (!StringRef(Arg->getValue()).startswith("lld")) - Rsp += toString(Arg) + " "; + Rsp += toString(*Arg) + " "; break; case OPT_INPUT: { if (Optional Path = doFindFile(Arg->getValue())) { @@ -686,7 +686,7 @@ break; } default: - Rsp += toString(Arg) + "\n"; + Rsp += toString(*Arg) + "\n"; } } Index: COFF/InputFiles.h =================================================================== --- COFF/InputFiles.h +++ COFF/InputFiles.h @@ -58,7 +58,7 @@ virtual ~InputFile() {} // Returns the filename. - StringRef getName() { return MB.getBufferIdentifier(); } + StringRef getName() const { return MB.getBufferIdentifier(); } // Reads a file (the constructor doesn't do that). virtual void parse() = 0; @@ -229,7 +229,7 @@ }; } // namespace coff -std::string toString(coff::InputFile *File); +std::string toString(const coff::InputFile *File); } // namespace lld #endif Index: COFF/InputFiles.cpp =================================================================== --- COFF/InputFiles.cpp +++ COFF/InputFiles.cpp @@ -493,7 +493,7 @@ } // Returns a string in the format of "foo.obj" or "foo.obj(bar.lib)". -std::string lld::toString(coff::InputFile *File) { +std::string lld::toString(const coff::InputFile *File) { if (!File) return ""; if (File->ParentName.empty()) Index: Common/Reproduce.cpp =================================================================== --- Common/Reproduce.cpp +++ Common/Reproduce.cpp @@ -55,12 +55,12 @@ return S; } -std::string lld::toString(opt::Arg *Arg) { - std::string K = Arg->getSpelling(); - if (Arg->getNumValues() == 0) +std::string lld::toString(const opt::Arg &Arg) { + std::string K = Arg.getSpelling(); + if (Arg.getNumValues() == 0) return K; - std::string V = quote(Arg->getValue()); - if (Arg->getOption().getRenderStyle() == opt::Option::RenderJoinedStyle) + std::string V = quote(Arg.getValue()); + if (Arg.getOption().getRenderStyle() == opt::Option::RenderJoinedStyle) return K + V; return K + " " + V; } Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -489,7 +489,7 @@ return StripPolicy::Debug; } -static uint64_t parseSectionAddress(StringRef S, opt::Arg *Arg) { +static uint64_t parseSectionAddress(StringRef S, const opt::Arg &Arg) { uint64_t VA = 0; if (S.startswith("0x")) S = S.drop_front(2); @@ -504,15 +504,15 @@ StringRef Name; StringRef Addr; std::tie(Name, Addr) = StringRef(Arg->getValue()).split('='); - Ret[Name] = parseSectionAddress(Addr, Arg); + Ret[Name] = parseSectionAddress(Addr, *Arg); } if (auto *Arg = Args.getLastArg(OPT_Ttext)) - Ret[".text"] = parseSectionAddress(Arg->getValue(), Arg); + Ret[".text"] = parseSectionAddress(Arg->getValue(), *Arg); if (auto *Arg = Args.getLastArg(OPT_Tdata)) - Ret[".data"] = parseSectionAddress(Arg->getValue(), Arg); + Ret[".data"] = parseSectionAddress(Arg->getValue(), *Arg); if (auto *Arg = Args.getLastArg(OPT_Tbss)) - Ret[".bss"] = parseSectionAddress(Arg->getValue(), Arg); + Ret[".bss"] = parseSectionAddress(Arg->getValue(), *Arg); return Ret; } Index: ELF/DriverUtils.cpp =================================================================== --- ELF/DriverUtils.cpp +++ ELF/DriverUtils.cpp @@ -166,7 +166,7 @@ << "\n"; break; default: - OS << toString(Arg) << "\n"; + OS << toString(*Arg) << "\n"; } } return Data.str(); Index: include/lld/Common/Reproduce.h =================================================================== --- include/lld/Common/Reproduce.h +++ include/lld/Common/Reproduce.h @@ -33,7 +33,7 @@ std::string rewritePath(StringRef S); // Returns the string form of the given argument. -std::string toString(llvm::opt::Arg *Arg); +std::string toString(const llvm::opt::Arg &Arg); } #endif Index: wasm/InputFiles.h =================================================================== --- wasm/InputFiles.h +++ wasm/InputFiles.h @@ -143,7 +143,7 @@ } // namespace wasm -std::string toString(wasm::InputFile *File); +std::string toString(const wasm::InputFile *File); } // namespace lld Index: wasm/InputFiles.cpp =================================================================== --- wasm/InputFiles.cpp +++ wasm/InputFiles.cpp @@ -264,7 +264,7 @@ } // Returns a string in the format of "foo.o" or "foo.a(bar.o)". -std::string lld::toString(wasm::InputFile *File) { +std::string lld::toString(const wasm::InputFile *File) { if (!File) return ""; Index: wasm/Symbols.h =================================================================== --- wasm/Symbols.h +++ wasm/Symbols.h @@ -111,8 +111,8 @@ } // namespace wasm // Returns a symbol name for an error message. -std::string toString(wasm::Symbol &Sym); -std::string toString(wasm::Symbol::Kind &Kind); +std::string toString(const wasm::Symbol &Sym); +std::string toString(wasm::Symbol::Kind Kind); } // namespace lld Index: wasm/Symbols.cpp =================================================================== --- wasm/Symbols.cpp +++ wasm/Symbols.cpp @@ -76,11 +76,11 @@ bool Symbol::isHidden() const { return Sym && Sym->isHidden(); } -std::string lld::toString(wasm::Symbol &Sym) { +std::string lld::toString(const wasm::Symbol &Sym) { return wasm::displayName(Sym.getName()); } -std::string lld::toString(wasm::Symbol::Kind &Kind) { +std::string lld::toString(wasm::Symbol::Kind Kind) { switch (Kind) { case wasm::Symbol::DefinedFunctionKind: return "DefinedFunction";