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/XRay/InstrumentationMap.cpp | 53 +++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 25 deletions(-) (limited to 'llvm/lib/XRay/InstrumentationMap.cpp') diff --git a/llvm/lib/XRay/InstrumentationMap.cpp b/llvm/lib/XRay/InstrumentationMap.cpp index f14ad381578..b3b482f0286 100644 --- a/llvm/lib/XRay/InstrumentationMap.cpp +++ b/llvm/lib/XRay/InstrumentationMap.cpp @@ -11,19 +11,26 @@ // //===----------------------------------------------------------------------===// -#ifndef XRAY_INSTRUMENTATIONMAP_H -#define XRAY_INSTRUMENTATIONMAP_H - -#include "llvm/XRay/InstrumentationMap.h" - +#include "llvm/ADT/None.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Triple.h" +#include "llvm/ADT/Twine.h" +#include "llvm/Object/Binary.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Support/DataExtractor.h" +#include "llvm/Support/Error.h" #include "llvm/Support/FileSystem.h" -#include "llvm/XRay/XRayRecord.h" +#include "llvm/Support/YAMLTraits.h" +#include "llvm/XRay/InstrumentationMap.h" +#include +#include +#include #include +#include -namespace llvm { -namespace xray { +using namespace llvm; +using namespace xray; Optional InstrumentationMap::getFunctionId(uint64_t Addr) const { auto I = FunctionIds.find(Addr); @@ -39,12 +46,11 @@ Optional InstrumentationMap::getFunctionAddr(int32_t FuncId) const { return None; } -namespace { -Error loadELF64(StringRef Filename, - object::OwningBinary &ObjFile, - InstrumentationMap::SledContainer &Sleds, - InstrumentationMap::FunctionAddressMap &FunctionAddresses, - InstrumentationMap::FunctionAddressReverseMap &FunctionIds) { +static Error +loadELF64(StringRef Filename, object::OwningBinary &ObjFile, + InstrumentationMap::SledContainer &Sleds, + InstrumentationMap::FunctionAddressMap &FunctionAddresses, + InstrumentationMap::FunctionAddressReverseMap &FunctionIds) { InstrumentationMap Map; // Find the section named "xray_instr_map". @@ -56,7 +62,7 @@ Error loadELF64(StringRef Filename, StringRef Contents = ""; const auto &Sections = ObjFile.getBinary()->sections(); - auto I = find_if(Sections, [&](object::SectionRef Section) { + auto I = llvm::find_if(Sections, [&](object::SectionRef Section) { StringRef Name = ""; if (Section.getName(Name)) return false; @@ -122,10 +128,11 @@ Error loadELF64(StringRef Filename, return Error::success(); } -Error loadYAML(int Fd, size_t FileSize, StringRef Filename, - InstrumentationMap::SledContainer &Sleds, - InstrumentationMap::FunctionAddressMap &FunctionAddresses, - InstrumentationMap::FunctionAddressReverseMap &FunctionIds) { +static Error +loadYAML(int Fd, size_t FileSize, StringRef Filename, + InstrumentationMap::SledContainer &Sleds, + InstrumentationMap::FunctionAddressMap &FunctionAddresses, + InstrumentationMap::FunctionAddressReverseMap &FunctionIds) { std::error_code EC; sys::fs::mapped_file_region MappedFile( Fd, sys::fs::mapped_file_region::mapmode::readonly, FileSize, 0, EC); @@ -150,11 +157,11 @@ Error loadYAML(int Fd, size_t FileSize, StringRef Filename, } return Error::success(); } -} // namespace // FIXME: Create error types that encapsulate a bit more information than what // StringError instances contain. -Expected loadInstrumentationMap(StringRef Filename) { +Expected +llvm::xray::loadInstrumentationMap(StringRef Filename) { // At this point we assume the file is an object file -- and if that doesn't // work, we treat it as YAML. // FIXME: Extend to support non-ELF and non-x86_64 binaries. @@ -188,7 +195,3 @@ Expected loadInstrumentationMap(StringRef Filename) { } return Map; } -} -} - -#endif // XRAY_INSTRUMENTATIONMAP_H -- cgit v1.2.3