From 44d951226ed135bc4273a74444f94edf24f603e5 Mon Sep 17 00:00:00 2001 From: Eugene Zelenko Date: Thu, 9 Feb 2017 01:09:54 +0000 Subject: [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 --- llvm/lib/Object/WasmObjectFile.cpp | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'llvm/lib/Object/WasmObjectFile.cpp') diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index e61ae15..254347a 100644 --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -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 +#include +#include -namespace llvm { -namespace object { +using namespace llvm; +using namespace object; Expected> 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(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 -- cgit v1.1