[WebAssembly] Do not use Subsection as a local variable name.

That variable hides the class of the same name.

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

llvm-svn: 326283
This commit is contained in:
Rui Ueyama 2018-02-28 00:39:30 +00:00
parent c61b834f31
commit 19eedbf013
1 changed files with 39 additions and 40 deletions

View File

@ -395,63 +395,62 @@ void Writer::createLinkingSection() {
return; return;
if (!SymtabEntries.empty()) { if (!SymtabEntries.empty()) {
SubSection SubSection(WASM_SYMBOL_TABLE); SubSection Sub(WASM_SYMBOL_TABLE);
writeUleb128(SubSection.getStream(), SymtabEntries.size(), "num symbols"); writeUleb128(Sub.getStream(), SymtabEntries.size(), "num symbols");
for (const Symbol *Sym : SymtabEntries) { for (const Symbol *Sym : SymtabEntries) {
assert(Sym->isDefined() || Sym->isUndefined()); assert(Sym->isDefined() || Sym->isUndefined());
WasmSymbolType Kind = Sym->getWasmType(); WasmSymbolType Kind = Sym->getWasmType();
uint32_t Flags = getWasmFlags(Sym); uint32_t Flags = getWasmFlags(Sym);
writeUleb128(SubSection.getStream(), Kind, "sym kind"); writeUleb128(Sub.getStream(), Kind, "sym kind");
writeUleb128(SubSection.getStream(), Flags, "sym flags"); writeUleb128(Sub.getStream(), Flags, "sym flags");
switch (Kind) { switch (Kind) {
case llvm::wasm::WASM_SYMBOL_TYPE_FUNCTION: case llvm::wasm::WASM_SYMBOL_TYPE_FUNCTION:
case llvm::wasm::WASM_SYMBOL_TYPE_GLOBAL: case llvm::wasm::WASM_SYMBOL_TYPE_GLOBAL:
writeUleb128(SubSection.getStream(), Sym->getOutputIndex(), "index"); writeUleb128(Sub.getStream(), Sym->getOutputIndex(), "index");
if (Sym->isDefined()) if (Sym->isDefined())
writeStr(SubSection.getStream(), Sym->getName(), "sym name"); writeStr(Sub.getStream(), Sym->getName(), "sym name");
break; break;
case llvm::wasm::WASM_SYMBOL_TYPE_DATA: case llvm::wasm::WASM_SYMBOL_TYPE_DATA:
writeStr(SubSection.getStream(), Sym->getName(), "sym name"); writeStr(Sub.getStream(), Sym->getName(), "sym name");
if (auto *DataSym = dyn_cast<DefinedData>(Sym)) { if (auto *DataSym = dyn_cast<DefinedData>(Sym)) {
writeUleb128(SubSection.getStream(), DataSym->getOutputSegmentIndex(), writeUleb128(Sub.getStream(), DataSym->getOutputSegmentIndex(),
"index"); "index");
writeUleb128(SubSection.getStream(), writeUleb128(Sub.getStream(), DataSym->getOutputSegmentOffset(),
DataSym->getOutputSegmentOffset(), "data offset"); "data offset");
writeUleb128(SubSection.getStream(), DataSym->getSize(), "data size"); writeUleb128(Sub.getStream(), DataSym->getSize(), "data size");
} }
break; break;
} }
} }
SubSection.finalizeContents(); Sub.finalizeContents();
SubSection.writeToStream(OS); Sub.writeToStream(OS);
} }
if (Segments.size()) { if (Segments.size()) {
SubSection SubSection(WASM_SEGMENT_INFO); SubSection Sub(WASM_SEGMENT_INFO);
writeUleb128(SubSection.getStream(), Segments.size(), "num data segments"); writeUleb128(Sub.getStream(), Segments.size(), "num data segments");
for (const OutputSegment *S : Segments) { for (const OutputSegment *S : Segments) {
writeStr(SubSection.getStream(), S->Name, "segment name"); writeStr(Sub.getStream(), S->Name, "segment name");
writeUleb128(SubSection.getStream(), S->Alignment, "alignment"); writeUleb128(Sub.getStream(), S->Alignment, "alignment");
writeUleb128(SubSection.getStream(), 0, "flags"); writeUleb128(Sub.getStream(), 0, "flags");
} }
SubSection.finalizeContents(); Sub.finalizeContents();
SubSection.writeToStream(OS); Sub.writeToStream(OS);
} }
if (!InitFunctions.empty()) { if (!InitFunctions.empty()) {
SubSection SubSection(WASM_INIT_FUNCS); SubSection Sub(WASM_INIT_FUNCS);
writeUleb128(SubSection.getStream(), InitFunctions.size(), writeUleb128(Sub.getStream(), InitFunctions.size(), "num init functions");
"num init functions");
for (const WasmInitEntry &F : InitFunctions) { for (const WasmInitEntry &F : InitFunctions) {
writeUleb128(SubSection.getStream(), F.Priority, "priority"); writeUleb128(Sub.getStream(), F.Priority, "priority");
writeUleb128(SubSection.getStream(), F.Sym->getOutputSymbolIndex(), writeUleb128(Sub.getStream(), F.Sym->getOutputSymbolIndex(),
"function index"); "function index");
} }
SubSection.finalizeContents(); Sub.finalizeContents();
SubSection.writeToStream(OS); Sub.writeToStream(OS);
} }
struct ComdatEntry { unsigned Kind; uint32_t Index; }; struct ComdatEntry { unsigned Kind; uint32_t Index; };
@ -477,19 +476,19 @@ void Writer::createLinkingSection() {
} }
if (!Comdats.empty()) { if (!Comdats.empty()) {
SubSection SubSection(WASM_COMDAT_INFO); SubSection Sub(WASM_COMDAT_INFO);
writeUleb128(SubSection.getStream(), Comdats.size(), "num comdats"); writeUleb128(Sub.getStream(), Comdats.size(), "num comdats");
for (const auto &C : Comdats) { for (const auto &C : Comdats) {
writeStr(SubSection.getStream(), C.first, "comdat name"); writeStr(Sub.getStream(), C.first, "comdat name");
writeUleb128(SubSection.getStream(), 0, "comdat flags"); // flags for future use writeUleb128(Sub.getStream(), 0, "comdat flags"); // flags for future use
writeUleb128(SubSection.getStream(), C.second.size(), "num entries"); writeUleb128(Sub.getStream(), C.second.size(), "num entries");
for (const ComdatEntry &Entry : C.second) { for (const ComdatEntry &Entry : C.second) {
writeUleb128(SubSection.getStream(), Entry.Kind, "entry kind"); writeUleb128(Sub.getStream(), Entry.Kind, "entry kind");
writeUleb128(SubSection.getStream(), Entry.Index, "entry index"); writeUleb128(Sub.getStream(), Entry.Index, "entry index");
} }
} }
SubSection.finalizeContents(); Sub.finalizeContents();
SubSection.writeToStream(OS); Sub.writeToStream(OS);
} }
} }
@ -505,8 +504,8 @@ void Writer::createNameSection() {
SyntheticSection *Section = createSyntheticSection(WASM_SEC_CUSTOM, "name"); SyntheticSection *Section = createSyntheticSection(WASM_SEC_CUSTOM, "name");
SubSection FunctionSubsection(WASM_NAMES_FUNCTION); SubSection Sub(WASM_NAMES_FUNCTION);
raw_ostream &OS = FunctionSubsection.getStream(); raw_ostream &OS = Sub.getStream();
writeUleb128(OS, NumNames, "name count"); writeUleb128(OS, NumNames, "name count");
// Names must appear in function index order. As it happens ImportedSymbols // Names must appear in function index order. As it happens ImportedSymbols
@ -525,8 +524,8 @@ void Writer::createNameSection() {
} }
} }
FunctionSubsection.finalizeContents(); Sub.finalizeContents();
FunctionSubsection.writeToStream(Section->getStream()); Sub.writeToStream(Section->getStream());
} }
void Writer::writeHeader() { void Writer::writeHeader() {