diff options
author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2017-02-09 01:09:54 +0000 |
---|---|---|
committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2017-02-09 01:09:54 +0000 |
commit | 44d951226ed135bc4273a74444f94edf24f603e5 (patch) | |
tree | 1ae623f1756af7b5f941611a0e8dcc826032f742 /llvm/lib/Object/WasmObjectFile.cpp | |
parent | 60fc1dd532e06b5b0c37caff308d33daed1b58e5 (diff) | |
download | llvm-44d951226ed135bc4273a74444f94edf24f603e5.zip llvm-44d951226ed135bc4273a74444f94edf24f603e5.tar.gz llvm-44d951226ed135bc4273a74444f94edf24f603e5.tar.bz2 |
[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
Diffstat (limited to 'llvm/lib/Object/WasmObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/WasmObjectFile.cpp | 36 |
1 files changed, 22 insertions, 14 deletions
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 <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 |