2018-05-15 00:42:07 +02:00
|
|
|
//===-- llvm/BinaryFormat/Wasm.cpp -------------------------------*- C++-*-===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-05-15 00:42:07 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/BinaryFormat/Wasm.h"
|
|
|
|
|
[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-*`. But I've seen in multiple CLs in LLVM the modernize style
was recommended and code was fixed based on the style, so I added it as
well.)
The common 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
- Use inline initialization for class member variables
- Use `= default` for empty constructors / destructors
- Use `using` in place of `typedef`
Reviewers: sbc100, tlively, aardappel
Subscribers: dschuff, sunfish, jgravelle-google, yurydelendik, kripken, MatzeB, mgorny, rupprecht, llvm-commits
Differential Revision: https://reviews.llvm.org/D57500
llvm-svn: 353075
2019-02-04 20:13:39 +01:00
|
|
|
std::string llvm::wasm::toString(wasm::WasmSymbolType Type) {
|
|
|
|
switch (Type) {
|
2018-05-15 00:42:07 +02:00
|
|
|
case wasm::WASM_SYMBOL_TYPE_FUNCTION:
|
|
|
|
return "WASM_SYMBOL_TYPE_FUNCTION";
|
|
|
|
case wasm::WASM_SYMBOL_TYPE_GLOBAL:
|
|
|
|
return "WASM_SYMBOL_TYPE_GLOBAL";
|
|
|
|
case wasm::WASM_SYMBOL_TYPE_DATA:
|
|
|
|
return "WASM_SYMBOL_TYPE_DATA";
|
|
|
|
case wasm::WASM_SYMBOL_TYPE_SECTION:
|
|
|
|
return "WASM_SYMBOL_TYPE_SECTION";
|
2018-11-14 03:46:21 +01:00
|
|
|
case wasm::WASM_SYMBOL_TYPE_EVENT:
|
|
|
|
return "WASM_SYMBOL_TYPE_EVENT";
|
2018-05-15 00:42:07 +02:00
|
|
|
}
|
|
|
|
llvm_unreachable("unknown symbol type");
|
|
|
|
}
|
|
|
|
|
[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-*`. But I've seen in multiple CLs in LLVM the modernize style
was recommended and code was fixed based on the style, so I added it as
well.)
The common 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
- Use inline initialization for class member variables
- Use `= default` for empty constructors / destructors
- Use `using` in place of `typedef`
Reviewers: sbc100, tlively, aardappel
Subscribers: dschuff, sunfish, jgravelle-google, yurydelendik, kripken, MatzeB, mgorny, rupprecht, llvm-commits
Differential Revision: https://reviews.llvm.org/D57500
llvm-svn: 353075
2019-02-04 20:13:39 +01:00
|
|
|
std::string llvm::wasm::relocTypetoString(uint32_t Type) {
|
|
|
|
switch (Type) {
|
2018-09-05 03:27:38 +02:00
|
|
|
#define WASM_RELOC(NAME, VALUE) \
|
|
|
|
case VALUE: \
|
|
|
|
return #NAME;
|
2018-05-15 00:42:07 +02:00
|
|
|
#include "llvm/BinaryFormat/WasmRelocs.def"
|
|
|
|
#undef WASM_RELOC
|
|
|
|
default:
|
|
|
|
llvm_unreachable("unknown reloc type");
|
|
|
|
}
|
|
|
|
}
|
2019-06-26 02:52:42 +02:00
|
|
|
|
|
|
|
bool llvm::wasm::relocTypeHasAddend(uint32_t Type) {
|
|
|
|
switch (Type) {
|
|
|
|
case R_WASM_MEMORY_ADDR_LEB:
|
|
|
|
case R_WASM_MEMORY_ADDR_SLEB:
|
|
|
|
case R_WASM_MEMORY_ADDR_REL_SLEB:
|
|
|
|
case R_WASM_MEMORY_ADDR_I32:
|
|
|
|
case R_WASM_FUNCTION_OFFSET_I32:
|
|
|
|
case R_WASM_SECTION_OFFSET_I32:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|