mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-12 21:28:48 +00:00
toString function take a const refs where possible
Differential Revision: https://reviews.llvm.org/D40824 llvm-svn: 319787
This commit is contained in:
parent
20569e96e9
commit
7e7566323d
@ -426,7 +426,7 @@ static std::string createResponseFile(const opt::InputArgList &Args,
|
|||||||
case OPT_manifestuac:
|
case OPT_manifestuac:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
OS << toString(Arg) << "\n";
|
OS << toString(*Arg) << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -674,7 +674,7 @@ void LinkerDriver::invokeMSVC(opt::InputArgList &Args) {
|
|||||||
break;
|
break;
|
||||||
case OPT_opt:
|
case OPT_opt:
|
||||||
if (!StringRef(Arg->getValue()).startswith("lld"))
|
if (!StringRef(Arg->getValue()).startswith("lld"))
|
||||||
Rsp += toString(Arg) + " ";
|
Rsp += toString(*Arg) + " ";
|
||||||
break;
|
break;
|
||||||
case OPT_INPUT: {
|
case OPT_INPUT: {
|
||||||
if (Optional<StringRef> Path = doFindFile(Arg->getValue())) {
|
if (Optional<StringRef> Path = doFindFile(Arg->getValue())) {
|
||||||
@ -686,7 +686,7 @@ void LinkerDriver::invokeMSVC(opt::InputArgList &Args) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
Rsp += toString(Arg) + "\n";
|
Rsp += toString(*Arg) + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,7 +493,7 @@ static StringRef getBasename(StringRef Path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns a string in the format of "foo.obj" or "foo.obj(bar.lib)".
|
// 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)
|
if (!File)
|
||||||
return "<internal>";
|
return "<internal>";
|
||||||
if (File->ParentName.empty())
|
if (File->ParentName.empty())
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
virtual ~InputFile() {}
|
virtual ~InputFile() {}
|
||||||
|
|
||||||
// Returns the filename.
|
// Returns the filename.
|
||||||
StringRef getName() { return MB.getBufferIdentifier(); }
|
StringRef getName() const { return MB.getBufferIdentifier(); }
|
||||||
|
|
||||||
// Reads a file (the constructor doesn't do that).
|
// Reads a file (the constructor doesn't do that).
|
||||||
virtual void parse() = 0;
|
virtual void parse() = 0;
|
||||||
@ -229,7 +229,7 @@ private:
|
|||||||
};
|
};
|
||||||
} // namespace coff
|
} // namespace coff
|
||||||
|
|
||||||
std::string toString(coff::InputFile *File);
|
std::string toString(const coff::InputFile *File);
|
||||||
} // namespace lld
|
} // namespace lld
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -55,12 +55,12 @@ std::string lld::rewritePath(StringRef S) {
|
|||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string lld::toString(opt::Arg *Arg) {
|
std::string lld::toString(const opt::Arg &Arg) {
|
||||||
std::string K = Arg->getSpelling();
|
std::string K = Arg.getSpelling();
|
||||||
if (Arg->getNumValues() == 0)
|
if (Arg.getNumValues() == 0)
|
||||||
return K;
|
return K;
|
||||||
std::string V = quote(Arg->getValue());
|
std::string V = quote(Arg.getValue());
|
||||||
if (Arg->getOption().getRenderStyle() == opt::Option::RenderJoinedStyle)
|
if (Arg.getOption().getRenderStyle() == opt::Option::RenderJoinedStyle)
|
||||||
return K + V;
|
return K + V;
|
||||||
return K + " " + V;
|
return K + " " + V;
|
||||||
}
|
}
|
||||||
|
@ -493,7 +493,7 @@ static StripPolicy getStrip(opt::InputArgList &Args) {
|
|||||||
return StripPolicy::Debug;
|
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;
|
uint64_t VA = 0;
|
||||||
if (S.startswith("0x"))
|
if (S.startswith("0x"))
|
||||||
S = S.drop_front(2);
|
S = S.drop_front(2);
|
||||||
@ -508,15 +508,15 @@ static StringMap<uint64_t> getSectionStartMap(opt::InputArgList &Args) {
|
|||||||
StringRef Name;
|
StringRef Name;
|
||||||
StringRef Addr;
|
StringRef Addr;
|
||||||
std::tie(Name, Addr) = StringRef(Arg->getValue()).split('=');
|
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))
|
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))
|
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))
|
if (auto *Arg = Args.getLastArg(OPT_Tbss))
|
||||||
Ret[".bss"] = parseSectionAddress(Arg->getValue(), Arg);
|
Ret[".bss"] = parseSectionAddress(Arg->getValue(), *Arg);
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ std::string elf::createResponseFile(const opt::InputArgList &Args) {
|
|||||||
<< "\n";
|
<< "\n";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
OS << toString(Arg) << "\n";
|
OS << toString(*Arg) << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Data.str();
|
return Data.str();
|
||||||
|
@ -33,7 +33,7 @@ std::string quote(StringRef S);
|
|||||||
std::string rewritePath(StringRef S);
|
std::string rewritePath(StringRef S);
|
||||||
|
|
||||||
// Returns the string form of the given argument.
|
// Returns the string form of the given argument.
|
||||||
std::string toString(llvm::opt::Arg *Arg);
|
std::string toString(const llvm::opt::Arg &Arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -264,7 +264,7 @@ void ArchiveFile::addMember(const Archive::Symbol *Sym) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns a string in the format of "foo.o" or "foo.a(bar.o)".
|
// 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)
|
if (!File)
|
||||||
return "<internal>";
|
return "<internal>";
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ llvm::Optional<MemoryBufferRef> readFile(StringRef Path);
|
|||||||
|
|
||||||
} // namespace wasm
|
} // namespace wasm
|
||||||
|
|
||||||
std::string toString(wasm::InputFile *File);
|
std::string toString(const wasm::InputFile *File);
|
||||||
|
|
||||||
} // namespace lld
|
} // namespace lld
|
||||||
|
|
||||||
|
@ -76,11 +76,11 @@ bool Symbol::isWeak() const { return Sym && Sym->isWeak(); }
|
|||||||
|
|
||||||
bool Symbol::isHidden() const { return Sym && Sym->isHidden(); }
|
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());
|
return wasm::displayName(Sym.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string lld::toString(wasm::Symbol::Kind &Kind) {
|
std::string lld::toString(wasm::Symbol::Kind Kind) {
|
||||||
switch (Kind) {
|
switch (Kind) {
|
||||||
case wasm::Symbol::DefinedFunctionKind:
|
case wasm::Symbol::DefinedFunctionKind:
|
||||||
return "DefinedFunction";
|
return "DefinedFunction";
|
||||||
|
@ -111,8 +111,8 @@ protected:
|
|||||||
} // namespace wasm
|
} // namespace wasm
|
||||||
|
|
||||||
// Returns a symbol name for an error message.
|
// Returns a symbol name for an error message.
|
||||||
std::string toString(wasm::Symbol &Sym);
|
std::string toString(const wasm::Symbol &Sym);
|
||||||
std::string toString(wasm::Symbol::Kind &Kind);
|
std::string toString(wasm::Symbol::Kind Kind);
|
||||||
|
|
||||||
} // namespace lld
|
} // namespace lld
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user