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 | 3a124c0e3d198c57522a3e027eb63385067acbbc (patch) | |
tree | 2e4d8117d6168aebaecde893bed673ada930dffe /lib/XRay | |
parent | 2012b38a6b91c509c4ce5b651f684183342c94f1 (diff) |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294548 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/XRay')
-rw-r--r-- | lib/XRay/InstrumentationMap.cpp | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/lib/XRay/InstrumentationMap.cpp b/lib/XRay/InstrumentationMap.cpp index f14ad3815780..b3b482f02863 100644 --- a/lib/XRay/InstrumentationMap.cpp +++ b/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 <algorithm> +#include <cstddef> +#include <cstdint> #include <system_error> +#include <vector> -namespace llvm { -namespace xray { +using namespace llvm; +using namespace xray; Optional<int32_t> InstrumentationMap::getFunctionId(uint64_t Addr) const { auto I = FunctionIds.find(Addr); @@ -39,12 +46,11 @@ Optional<uint64_t> InstrumentationMap::getFunctionAddr(int32_t FuncId) const { return None; } -namespace { -Error loadELF64(StringRef Filename, - object::OwningBinary<object::ObjectFile> &ObjFile, - InstrumentationMap::SledContainer &Sleds, - InstrumentationMap::FunctionAddressMap &FunctionAddresses, - InstrumentationMap::FunctionAddressReverseMap &FunctionIds) { +static Error +loadELF64(StringRef Filename, object::OwningBinary<object::ObjectFile> &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<InstrumentationMap> loadInstrumentationMap(StringRef Filename) { +Expected<InstrumentationMap> +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<InstrumentationMap> loadInstrumentationMap(StringRef Filename) { } return Map; } -} -} - -#endif // XRAY_INSTRUMENTATIONMAP_H |