Index: wasm/Driver.cpp =================================================================== --- wasm/Driver.cpp +++ wasm/Driver.cpp @@ -186,8 +186,7 @@ // Returns slices of MB by parsing MB as an archive file. // Each slice consists of a member file in the archive. -std::vector static getArchiveMembers( - MemoryBufferRef MB) { +std::vector static getArchiveMembers(MemoryBufferRef MB) { std::unique_ptr File = CHECK(Archive::create(MB), MB.getBufferIdentifier() + ": failed to parse archive"); @@ -205,8 +204,8 @@ 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 &MB : File->takeThinBuffers()) Index: wasm/InputChunks.cpp =================================================================== --- wasm/InputChunks.cpp +++ wasm/InputChunks.cpp @@ -25,7 +25,9 @@ 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 @@ 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(); Index: wasm/InputFiles.cpp =================================================================== --- wasm/InputFiles.cpp +++ wasm/InputFiles.cpp @@ -94,16 +94,17 @@ 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 @@ 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 @@ return; ArrayRef 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 @@ 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(RelocsStart, RelocsNext)); } } @@ -259,7 +258,8 @@ Functions.reserve(Funcs.size()); for (size_t I = 0, E = Funcs.size(); I != E; ++I) - Functions.emplace_back(make(Types[FuncTypes[I]], &Funcs[I], this)); + Functions.emplace_back( + make(Types[FuncTypes[I]], &Funcs[I], this)); setRelocs(Functions, CodeSection); // Populate `Globals`. Index: wasm/OutputSections.h =================================================================== --- wasm/OutputSections.h +++ wasm/OutputSections.h @@ -113,7 +113,7 @@ 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 Index: wasm/Writer.cpp =================================================================== --- wasm/Writer.cpp +++ wasm/Writer.cpp @@ -586,9 +586,9 @@ // - 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();