[MC] Fix some Clang-tidy modernize and Include What You Use warnings in SubtargetFeature; other minor fixes (NFC).
Same changes in files affected by reduced SubtargetFeature.h dependencies. llvm-svn: 294548
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//===- WasmObjectFile.cpp - Wasm object file implementation -----*- C++ -*-===//
|
||||
//===- WasmObjectFile.cpp - Wasm object file implementation ---------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@@ -7,12 +7,26 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/Object/Binary.h"
|
||||
#include "llvm/Object/Error.h"
|
||||
#include "llvm/Object/ObjectFile.h"
|
||||
#include "llvm/Object/SymbolicFile.h"
|
||||
#include "llvm/Object/Wasm.h"
|
||||
#include "llvm/Support/Endian.h"
|
||||
#include "llvm/Support/Error.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/LEB128.h"
|
||||
#include "llvm/Support/Wasm.h"
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <system_error>
|
||||
|
||||
namespace llvm {
|
||||
namespace object {
|
||||
using namespace llvm;
|
||||
using namespace object;
|
||||
|
||||
Expected<std::unique_ptr<WasmObjectFile>>
|
||||
ObjectFile::createWasmObjectFile(MemoryBufferRef Buffer) {
|
||||
@@ -24,30 +38,28 @@ ObjectFile::createWasmObjectFile(MemoryBufferRef Buffer) {
|
||||
return std::move(ObjectFile);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
uint32_t readUint32(const uint8_t *&Ptr) {
|
||||
static uint32_t readUint32(const uint8_t *&Ptr) {
|
||||
uint32_t Result = support::endian::read32le(Ptr);
|
||||
Ptr += sizeof(Result);
|
||||
return Result;
|
||||
}
|
||||
|
||||
uint64_t readULEB128(const uint8_t *&Ptr) {
|
||||
static uint64_t readULEB128(const uint8_t *&Ptr) {
|
||||
unsigned Count;
|
||||
uint64_t Result = decodeULEB128(Ptr, &Count);
|
||||
Ptr += Count;
|
||||
return Result;
|
||||
}
|
||||
|
||||
StringRef readString(const uint8_t *&Ptr) {
|
||||
static StringRef readString(const uint8_t *&Ptr) {
|
||||
uint32_t StringLen = readULEB128(Ptr);
|
||||
StringRef Return = StringRef(reinterpret_cast<const char *>(Ptr), StringLen);
|
||||
Ptr += StringLen;
|
||||
return Return;
|
||||
}
|
||||
|
||||
Error readSection(wasm::WasmSection &Section, const uint8_t *&Ptr,
|
||||
const uint8_t *Start) {
|
||||
static Error readSection(wasm::WasmSection &Section, const uint8_t *&Ptr,
|
||||
const uint8_t *Start) {
|
||||
// TODO(sbc): Avoid reading past EOF in the case of malformed files.
|
||||
Section.Offset = Ptr - Start;
|
||||
Section.Type = readULEB128(Ptr);
|
||||
@@ -59,7 +71,6 @@ Error readSection(wasm::WasmSection &Section, const uint8_t *&Ptr,
|
||||
Ptr += Size;
|
||||
return Error::success();
|
||||
}
|
||||
}
|
||||
|
||||
WasmObjectFile::WasmObjectFile(MemoryBufferRef Buffer, Error &Err)
|
||||
: ObjectFile(Binary::ID_Wasm, Buffer) {
|
||||
@@ -309,6 +320,3 @@ const wasm::WasmSection *
|
||||
WasmObjectFile::getWasmSection(const SectionRef &Section) const {
|
||||
return &Sections[Section.getRawDataRefImpl().d.a];
|
||||
}
|
||||
|
||||
} // end namespace object
|
||||
} // end namespace llvm
|
||||
|
||||
Reference in New Issue
Block a user