Skip to content

Commit a1cc4ea

Browse files
committed
[WebAssembly] clang-tidy (NFC)
Summary: This patch fixes clang-tidy warnings on wasm-only files. The list of checks used is: `-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming,modernize-*` (LLVM's default .clang-tidy list is the same except it does not have `modernize-*`.) The list of fixes are: - Variable names start with an uppercase letter - Function names start with a lowercase letter - Use `auto` when you use casts so the type is evident Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D57499 llvm-svn: 353076
1 parent 18c56a0 commit a1cc4ea

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

lld/wasm/InputChunks.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ using namespace llvm::support::endian;
2222
using namespace lld;
2323
using namespace lld::wasm;
2424

25-
static StringRef ReloctTypeToString(uint8_t RelocType) {
25+
static StringRef reloctTypeToString(uint8_t RelocType) {
2626
switch (RelocType) {
2727
#define WASM_RELOC(NAME, REL) \
2828
case REL: \
@@ -76,7 +76,7 @@ void InputChunk::verifyRelocTargets() const {
7676
warn("expected LEB at relocation site be 5-byte padded");
7777
uint32_t ExpectedValue = File->calcExpectedValue(Rel);
7878
if (ExpectedValue != ExistingValue)
79-
warn("unexpected existing value for " + ReloctTypeToString(Rel.Type) +
79+
warn("unexpected existing value for " + reloctTypeToString(Rel.Type) +
8080
": existing=" + Twine(ExistingValue) +
8181
" expected=" + Twine(ExpectedValue));
8282
}
@@ -102,7 +102,7 @@ void InputChunk::writeTo(uint8_t *Buf) const {
102102
for (const WasmRelocation &Rel : Relocations) {
103103
uint8_t *Loc = Buf + Rel.Offset + Off;
104104
uint32_t Value = File->calcNewValue(Rel);
105-
LLVM_DEBUG(dbgs() << "apply reloc: type=" << ReloctTypeToString(Rel.Type)
105+
LLVM_DEBUG(dbgs() << "apply reloc: type=" << reloctTypeToString(Rel.Type)
106106
<< " addend=" << Rel.Addend << " index=" << Rel.Index
107107
<< " value=" << Value << " offset=" << Rel.Offset
108108
<< "\n");

lld/wasm/InputFiles.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ static Symbol *createBitcodeSymbol(const lto::InputFile::Symbol &ObjSym,
447447

448448
if (ObjSym.isUndefined()) {
449449
if (ObjSym.isExecutable())
450-
return Symtab->addUndefinedFunction(Name, kDefaultModule, Flags, &F, nullptr);
450+
return Symtab->addUndefinedFunction(Name, DefaultModule, Flags, &F, nullptr);
451451
return Symtab->addUndefinedData(Name, Flags, &F);
452452
}
453453

lld/wasm/LTO.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ BitcodeCompiler::~BitcodeCompiler() = default;
8080

8181
static void undefine(Symbol *S) {
8282
if (auto F = dyn_cast<DefinedFunction>(S))
83-
replaceSymbol<UndefinedFunction>(F, F->getName(), kDefaultModule, 0,
83+
replaceSymbol<UndefinedFunction>(F, F->getName(), DefaultModule, 0,
8484
F->getFile(), F->Signature);
8585
else if (isa<DefinedData>(S))
8686
replaceSymbol<UndefinedData>(S, S->getName(), 0, S->getFile());

lld/wasm/MarkLive.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void lld::wasm::markLive() {
8484
// equal to null pointer, only reachable via direct call).
8585
if (Reloc.Type == R_WASM_TABLE_INDEX_SLEB ||
8686
Reloc.Type == R_WASM_TABLE_INDEX_I32) {
87-
FunctionSymbol *FuncSym = cast<FunctionSymbol>(Sym);
87+
auto *FuncSym = cast<FunctionSymbol>(Sym);
8888
if (FuncSym->hasTableIndex() && FuncSym->getTableIndex() == 0)
8989
continue;
9090
}

lld/wasm/Writer.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ using namespace llvm::wasm;
3939
using namespace lld;
4040
using namespace lld::wasm;
4141

42-
static constexpr int kStackAlignment = 16;
43-
static constexpr const char *kFunctionTableName = "__indirect_function_table";
44-
const char *lld::wasm::kDefaultModule = "env";
42+
static constexpr int StackAlignment = 16;
43+
static constexpr const char *FunctionTableName = "__indirect_function_table";
44+
const char *lld::wasm::DefaultModule = "env";
4545

4646
namespace {
4747

@@ -157,7 +157,7 @@ void Writer::createImportSection() {
157157

158158
if (Config->ImportMemory) {
159159
WasmImport Import;
160-
Import.Module = kDefaultModule;
160+
Import.Module = DefaultModule;
161161
Import.Field = "memory";
162162
Import.Kind = WASM_EXTERNAL_MEMORY;
163163
Import.Memory.Flags = 0;
@@ -174,8 +174,8 @@ void Writer::createImportSection() {
174174
if (Config->ImportTable) {
175175
uint32_t TableSize = TableBase + IndirectFunctions.size();
176176
WasmImport Import;
177-
Import.Module = kDefaultModule;
178-
Import.Field = kFunctionTableName;
177+
Import.Module = DefaultModule;
178+
Import.Field = FunctionTableName;
179179
Import.Kind = WASM_EXTERNAL_TABLE;
180180
Import.Table.ElemType = WASM_TYPE_FUNCREF;
181181
Import.Table.Limits = {0, TableSize, 0};
@@ -187,7 +187,7 @@ void Writer::createImportSection() {
187187
if (auto *F = dyn_cast<UndefinedFunction>(Sym))
188188
Import.Module = F->Module;
189189
else
190-
Import.Module = kDefaultModule;
190+
Import.Module = DefaultModule;
191191

192192
Import.Field = Sym->getName();
193193
if (auto *FunctionSym = dyn_cast<FunctionSymbol>(Sym)) {
@@ -709,9 +709,9 @@ void Writer::layoutMemory() {
709709
auto PlaceStack = [&]() {
710710
if (Config->Relocatable || Config->Shared)
711711
return;
712-
MemoryPtr = alignTo(MemoryPtr, kStackAlignment);
713-
if (Config->ZStackSize != alignTo(Config->ZStackSize, kStackAlignment))
714-
error("stack size must be " + Twine(kStackAlignment) + "-byte aligned");
712+
MemoryPtr = alignTo(MemoryPtr, StackAlignment);
713+
if (Config->ZStackSize != alignTo(Config->ZStackSize, StackAlignment))
714+
error("stack size must be " + Twine(StackAlignment) + "-byte aligned");
715715
log("mem: stack size = " + Twine(Config->ZStackSize));
716716
log("mem: stack base = " + Twine(MemoryPtr));
717717
MemoryPtr += Config->ZStackSize;
@@ -864,7 +864,7 @@ void Writer::calculateExports() {
864864
Exports.push_back(WasmExport{"memory", WASM_EXTERNAL_MEMORY, 0});
865865

866866
if (!Config->Relocatable && Config->ExportTable)
867-
Exports.push_back(WasmExport{kFunctionTableName, WASM_EXTERNAL_TABLE, 0});
867+
Exports.push_back(WasmExport{FunctionTableName, WASM_EXTERNAL_TABLE, 0});
868868

869869
unsigned FakeGlobalIndex = NumImportedGlobals + InputGlobals.size();
870870

lld/wasm/Writer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace wasm {
1414

1515
void writeResult();
1616

17-
extern const char *kDefaultModule;
17+
extern const char *DefaultModule;
1818

1919
} // namespace wasm
2020
} // namespace lld

0 commit comments

Comments
 (0)