[WebAssembly] clang-format (NFC)

Summary: This patch runs clang-format on all wasm-only files.

Reviewers: sbc100

Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D51449

llvm-svn: 340970
This commit is contained in:
Heejin Ahn 2018-08-29 21:03:16 +00:00
parent d709a36084
commit 4821ebf73f
5 changed files with 27 additions and 25 deletions

View File

@ -186,8 +186,7 @@ static void readImportFile(StringRef Filename) {
// Returns slices of MB by parsing MB as an archive file.
// Each slice consists of a member file in the archive.
std::vector<MemoryBufferRef> static getArchiveMembers(
MemoryBufferRef MB) {
std::vector<MemoryBufferRef> static getArchiveMembers(MemoryBufferRef MB) {
std::unique_ptr<Archive> File =
CHECK(Archive::create(MB),
MB.getBufferIdentifier() + ": failed to parse archive");
@ -205,8 +204,8 @@ std::vector<MemoryBufferRef> static getArchiveMembers(
V.push_back(MBRef);
}
if (Err)
fatal(MB.getBufferIdentifier() + ": Archive::children failed: " +
toString(std::move(Err)));
fatal(MB.getBufferIdentifier() +
": Archive::children failed: " + toString(std::move(Err)));
// Take ownership of memory buffers created for members of thin archives.
for (std::unique_ptr<MemoryBuffer> &MB : File->takeThinBuffers())

View File

@ -25,7 +25,9 @@ using namespace lld::wasm;
static StringRef ReloctTypeToString(uint8_t RelocType) {
switch (RelocType) {
#define WASM_RELOC(NAME, REL) case REL: return #NAME;
#define WASM_RELOC(NAME, REL) \
case REL: \
return #NAME;
#include "llvm/BinaryFormat/WasmRelocs.def"
#undef WASM_RELOC
}
@ -257,7 +259,8 @@ void InputFunction::writeTo(uint8_t *Buf) const {
return InputChunk::writeTo(Buf);
Buf += OutputOffset;
uint8_t *Orig = Buf; (void)Orig;
uint8_t *Orig = Buf;
(void)Orig;
const uint8_t *SecStart = File->CodeSection->Content.data();
const uint8_t *FuncStart = SecStart + getInputSectionOffset();

View File

@ -94,16 +94,17 @@ uint32_t ObjFile::calcExpectedValue(const WasmRelocation &Reloc) const {
switch (Reloc.Type) {
case R_WEBASSEMBLY_TABLE_INDEX_I32:
case R_WEBASSEMBLY_TABLE_INDEX_SLEB: {
const WasmSymbol& Sym = WasmObj->syms()[Reloc.Index];
const WasmSymbol &Sym = WasmObj->syms()[Reloc.Index];
return TableEntries[Sym.Info.ElementIndex];
}
case R_WEBASSEMBLY_MEMORY_ADDR_SLEB:
case R_WEBASSEMBLY_MEMORY_ADDR_I32:
case R_WEBASSEMBLY_MEMORY_ADDR_LEB: {
const WasmSymbol& Sym = WasmObj->syms()[Reloc.Index];
const WasmSymbol &Sym = WasmObj->syms()[Reloc.Index];
if (Sym.isUndefined())
return 0;
const WasmSegment& Segment = WasmObj->dataSegments()[Sym.Info.DataRef.Segment];
const WasmSegment &Segment =
WasmObj->dataSegments()[Sym.Info.DataRef.Segment];
return Segment.Data.Offset.Value.Int32 + Sym.Info.DataRef.Offset +
Reloc.Addend;
}
@ -119,7 +120,7 @@ uint32_t ObjFile::calcExpectedValue(const WasmRelocation &Reloc) const {
return Reloc.Index;
case R_WEBASSEMBLY_FUNCTION_INDEX_LEB:
case R_WEBASSEMBLY_GLOBAL_INDEX_LEB: {
const WasmSymbol& Sym = WasmObj->syms()[Reloc.Index];
const WasmSymbol &Sym = WasmObj->syms()[Reloc.Index];
return Sym.Info.ElementIndex;
}
default:
@ -166,14 +167,12 @@ static void setRelocs(const std::vector<T *> &Chunks,
return;
ArrayRef<WasmRelocation> Relocs = Section->Relocations;
assert(std::is_sorted(Relocs.begin(), Relocs.end(),
[](const WasmRelocation &R1, const WasmRelocation &R2) {
return R1.Offset < R2.Offset;
}));
assert(std::is_sorted(
Relocs.begin(), Relocs.end(),
[](const WasmRelocation &R1, const WasmRelocation &R2) {
return R1.Offset < R2.Offset;
}));
assert(std::is_sorted(
Chunks.begin(), Chunks.end(),
[](InputChunk *C1, InputChunk *C2) {
Chunks.begin(), Chunks.end(), [](InputChunk *C1, InputChunk *C2) {
return C1->getInputSectionOffset() < C2->getInputSectionOffset();
}));
@ -185,9 +184,9 @@ static void setRelocs(const std::vector<T *> &Chunks,
for (InputChunk *C : Chunks) {
auto RelocsStart = std::lower_bound(RelocsNext, RelocsEnd,
C->getInputSectionOffset(), RelocLess);
RelocsNext = std::lower_bound(RelocsStart, RelocsEnd,
C->getInputSectionOffset() + C->getInputSize(),
RelocLess);
RelocsNext = std::lower_bound(
RelocsStart, RelocsEnd, C->getInputSectionOffset() + C->getInputSize(),
RelocLess);
C->setRelocations(ArrayRef<WasmRelocation>(RelocsStart, RelocsNext));
}
}
@ -259,7 +258,8 @@ void ObjFile::parse() {
Functions.reserve(Funcs.size());
for (size_t I = 0, E = Funcs.size(); I != E; ++I)
Functions.emplace_back(make<InputFunction>(Types[FuncTypes[I]], &Funcs[I], this));
Functions.emplace_back(
make<InputFunction>(Types[FuncTypes[I]], &Funcs[I], this));
setRelocs(Functions, CodeSection);
// Populate `Globals`.

View File

@ -113,7 +113,7 @@ protected:
size_t BodySize = 0;
};
// Represents a custom section in the output file. Wasm custom sections are
// Represents a custom section in the output file. Wasm custom sections are
// used for storing user-defined metadata. Unlike the core sections types
// they are identified by their string name.
// The linker combines custom sections that have the same name by simply

View File

@ -586,9 +586,9 @@ void Writer::writeSections() {
// - heap start / unallocated
//
// The --stack-first option means that stack is placed before any static data.
// This can be useful since it means that stack overflow traps immediately rather
// than overwriting global data, but also increases code size since all static
// data loads and stores requires larger offsets.
// This can be useful since it means that stack overflow traps immediately
// rather than overwriting global data, but also increases code size since all
// static data loads and stores requires larger offsets.
void Writer::layoutMemory() {
createOutputSegments();