86 object_error::parse_failed);
102 size_t End = Buf.find(
'\n');
103 Buf = (End == Buf.npos) ?
"" : Buf.drop_front(End);
107 Buf = Buf.drop_front();
108 if (Buf.startswith(
"=")) {
109 Buf = Buf.drop_front();
114 Buf = Buf.drop_front();
122 size_t End = Buf.find_first_of(
"=,;\r\n \t\v");
137 Buf = (End == Buf.npos) ?
"" : Buf.drop_front(End);
138 return Token(K, Word);
150 : Lex(S),
Machine(M), MingwDef(B) {}
154 if (
Error Err = parseOne())
155 return std::move(Err);
156 }
while (Tok.K !=
Eof);
170 Error readAsInt(uint64_t *
I) {
172 if (Tok.K !=
Identifier || Tok.Value.getAsInteger(10, *I))
179 if (Tok.K != Expected)
184 void unget() { Stack.push_back(Tok); }
198 if (
Error Err = parseExport())
202 return parseNumbers(&
Info.HeapReserve, &
Info.HeapCommit);
204 return parseNumbers(&
Info.StackReserve, &
Info.StackCommit);
209 if (
Error Err = parseName(&Name, &
Info.ImageBase))
215 if (
Info.OutputFile.empty()) {
219 Info.OutputFile += IsDll ?
".dll" :
".exe";
227 return createError(
"unknown directive: " + Tok.Value);
231 Error parseExport() {
235 if (Tok.K ==
Equal) {
238 return createError(
"identifier expected, but got " + Tok.Value);
247 E.
Name = (std::string(
"_").append(E.
Name));
254 if (Tok.K ==
Identifier && Tok.Value[0] ==
'@') {
255 if (Tok.Value ==
"@") {
258 Tok.Value.getAsInteger(10, E.
Ordinal);
259 }
else if (Tok.Value.drop_front().getAsInteger(10, E.
Ordinal)) {
263 Info.Exports.push_back(E);
295 Info.Exports.push_back(E);
301 Error parseNumbers(uint64_t *Reserve, uint64_t *Commit) {
302 if (
Error Err = readAsInt(Reserve))
305 if (Tok.K !=
Comma) {
310 if (
Error Err = readAsInt(Commit))
316 Error parseName(std::string *Out, uint64_t *Baseaddr) {
329 if (
Error Err = readAsInt(Baseaddr))
342 return createError(
"identifier expected, but got " + Tok.Value);
344 std::tie(V1, V2) = Tok.Value.split(
'.');
346 return createError(
"integer expected, but got " + Tok.Value);
350 return createError(
"integer expected, but got " + Tok.Value);
356 std::vector<Token> Stack;
This class represents lattice values for constants.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
bool has_extension(const Twine &path, Style style=Style::native)
Has extension?
static bool isDecorated(StringRef Sym, bool MingwDef)
Parser(StringRef S, MachineTypes M, bool B)
Expected< COFFModuleDefinition > parseCOFFModuleDefinition(MemoryBufferRef MB, COFF::MachineTypes Machine, bool MingwDef=false)
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
StringRef getBuffer() const
support::ulittle32_t Word
Tagged union holding either a T or a Error.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE R Default(T Value)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
static Error createError(const Twine &Err)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
COFF::MachineTypes Machine
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Analysis containing CSE Info
A switch()-like statement whose cases are string literals.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::Expected< Value > parse(llvm::StringRef JSON)
Parses the provided JSON source, or returns a ParseError.
Token(Kind T=Unknown, StringRef S="")
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
static ErrorSuccess success()
Create a success value.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(StringLiteral S, T Value)
Expected< COFFModuleDefinition > parse()
value_type read(const void *memory, endianness endian)
Read a value of a particular endianness from memory.
std::string str() const
Return the twine contents as a std::string.
static Version parseVersion(StringRef Name)
LLVM Value Representation.
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.