From c976146d3133884cd6326ab9f262e5dbc67187c5 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sun, 15 Mar 2015 01:30:58 +0000 Subject: [PATCH 1/1] llvm-cxxdump: Rename llvm-vtabledump to llvm-cxxdump llvm-vtabledump has grown enough functionality not related to vtables that it deserves a name which is more descriptive. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232301 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CMakeLists.txt | 2 +- test/lit.cfg | 4 +-- .../Inputs/eh.obj.coff-i386 | Bin .../Inputs/trivial.obj.coff-i386 | Bin .../Inputs/trivial.obj.elf-i386 | Bin .../{llvm-vtabledump => llvm-cxxdump}/eh.test | 2 +- .../trivial.test | 4 +-- tools/CMakeLists.txt | 2 +- tools/Makefile | 2 +- .../CMakeLists.txt | 4 +-- .../Error.cpp | 22 ++++++------ .../{llvm-vtabledump => llvm-cxxdump}/Error.h | 18 +++++----- .../LLVMBuild.txt | 4 +-- .../Makefile | 4 +-- .../llvm-cxxdump.cpp} | 33 +++++++++--------- .../llvm-cxxdump.h} | 8 ++--- 16 files changed, 55 insertions(+), 54 deletions(-) rename test/tools/{llvm-vtabledump => llvm-cxxdump}/Inputs/eh.obj.coff-i386 (100%) rename test/tools/{llvm-vtabledump => llvm-cxxdump}/Inputs/trivial.obj.coff-i386 (100%) rename test/tools/{llvm-vtabledump => llvm-cxxdump}/Inputs/trivial.obj.elf-i386 (100%) rename test/tools/{llvm-vtabledump => llvm-cxxdump}/eh.test (99%) rename test/tools/{llvm-vtabledump => llvm-cxxdump}/trivial.test (95%) rename tools/{llvm-vtabledump => llvm-cxxdump}/CMakeLists.txt (63%) rename tools/{llvm-vtabledump => llvm-cxxdump}/Error.cpp (58%) rename tools/{llvm-vtabledump => llvm-cxxdump}/Error.h (51%) rename tools/{llvm-vtabledump => llvm-cxxdump}/LLVMBuild.txt (87%) rename tools/{llvm-vtabledump => llvm-cxxdump}/Makefile (82%) rename tools/{llvm-vtabledump/llvm-vtabledump.cpp => llvm-cxxdump/llvm-cxxdump.cpp} (96%) rename tools/{llvm-vtabledump/llvm-vtabledump.h => llvm-cxxdump/llvm-cxxdump.h} (66%) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f85a1d97e90..5a97ee720bd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -28,6 +28,7 @@ set(LLVM_TEST_DEPENDS llvm-bcanalyzer llvm-c-test llvm-cov + llvm-cxxdump llvm-diff llvm-dis llvm-dsymutil @@ -46,7 +47,6 @@ set(LLVM_TEST_DEPENDS llvm-size llvm-symbolizer llvm-tblgen - llvm-vtabledump macho-dump opt FileCheck diff --git a/test/lit.cfg b/test/lit.cfg index 197b4582979..70f83fd0072 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -41,7 +41,7 @@ config.test_format = lit.formats.ShTest(execute_external) # suffixes: A list of file extensions to treat as test files. This is overriden # by individual lit.local.cfg files in the test subdirectories. -config.suffixes = ['.ll', '.c', '.cpp', '.test', '.txt', '.s'] +config.suffixes = ['.ll', '.c', '.cxx', '.test', '.txt', '.s'] # excludes: A list of directories to exclude from the testsuite. The 'Inputs' # subdirectories contain auxiliary inputs for various tests in their parent @@ -228,6 +228,7 @@ for pattern in [r"\bbugpoint\b(?!-)", r"\bllvm-bcanalyzer\b", r"\bllvm-config\b", r"\bllvm-cov\b", + r"\bllvm-cxxdump\b", r"\bllvm-diff\b", r"\bllvm-dis\b", r"\bllvm-dsymutil\b", @@ -246,7 +247,6 @@ for pattern in [r"\bbugpoint\b(?!-)", r"\bllvm-rtdyld\b", r"\bllvm-size\b", r"\bllvm-tblgen\b", - r"\bllvm-vtabledump\b", r"\bllvm-c-test\b", r"\bmacho-dump\b", NOJUNK + r"\bopt\b", diff --git a/test/tools/llvm-vtabledump/Inputs/eh.obj.coff-i386 b/test/tools/llvm-cxxdump/Inputs/eh.obj.coff-i386 similarity index 100% rename from test/tools/llvm-vtabledump/Inputs/eh.obj.coff-i386 rename to test/tools/llvm-cxxdump/Inputs/eh.obj.coff-i386 diff --git a/test/tools/llvm-vtabledump/Inputs/trivial.obj.coff-i386 b/test/tools/llvm-cxxdump/Inputs/trivial.obj.coff-i386 similarity index 100% rename from test/tools/llvm-vtabledump/Inputs/trivial.obj.coff-i386 rename to test/tools/llvm-cxxdump/Inputs/trivial.obj.coff-i386 diff --git a/test/tools/llvm-vtabledump/Inputs/trivial.obj.elf-i386 b/test/tools/llvm-cxxdump/Inputs/trivial.obj.elf-i386 similarity index 100% rename from test/tools/llvm-vtabledump/Inputs/trivial.obj.elf-i386 rename to test/tools/llvm-cxxdump/Inputs/trivial.obj.elf-i386 diff --git a/test/tools/llvm-vtabledump/eh.test b/test/tools/llvm-cxxdump/eh.test similarity index 99% rename from test/tools/llvm-vtabledump/eh.test rename to test/tools/llvm-cxxdump/eh.test index 1c43e0e7f65..b323b05defe 100644 --- a/test/tools/llvm-vtabledump/eh.test +++ b/test/tools/llvm-cxxdump/eh.test @@ -1,4 +1,4 @@ -RUN: llvm-vtabledump %p/Inputs/eh.obj.coff-i386 \ +RUN: llvm-cxxdump %p/Inputs/eh.obj.coff-i386 \ RUN: | FileCheck %s --check-prefix=COFF-I386 diff --git a/test/tools/llvm-vtabledump/trivial.test b/test/tools/llvm-cxxdump/trivial.test similarity index 95% rename from test/tools/llvm-vtabledump/trivial.test rename to test/tools/llvm-cxxdump/trivial.test index 92bd058cfb1..450ed3b3780 100644 --- a/test/tools/llvm-vtabledump/trivial.test +++ b/test/tools/llvm-cxxdump/trivial.test @@ -1,7 +1,7 @@ -RUN: llvm-vtabledump %p/Inputs/trivial.obj.coff-i386 \ +RUN: llvm-cxxdump %p/Inputs/trivial.obj.coff-i386 \ RUN: | FileCheck %s --check-prefix=COFF-I386 -RUN: llvm-vtabledump %p/Inputs/trivial.obj.elf-i386 \ +RUN: llvm-cxxdump %p/Inputs/trivial.obj.elf-i386 \ RUN: | FileCheck %s --check-prefix=ELF-I386 COFF-I386: ??_7S@@6B@[0]: ??_R4S@@6B@ diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 1f415b620df..7859b49c9de 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -37,7 +37,7 @@ add_llvm_tool_subdirectory(llvm-readobj) add_llvm_tool_subdirectory(llvm-rtdyld) add_llvm_tool_subdirectory(llvm-dwarfdump) add_llvm_tool_subdirectory(dsymutil) -add_llvm_tool_subdirectory(llvm-vtabledump) +add_llvm_tool_subdirectory(llvm-cxxdump) if( LLVM_USE_INTEL_JITEVENTS ) add_llvm_tool_subdirectory(llvm-jitlistener) else() diff --git a/tools/Makefile b/tools/Makefile index fcb6c647e3a..d8534866c3d 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -33,7 +33,7 @@ PARALLEL_DIRS := opt llvm-as llvm-dis llc llvm-ar llvm-nm llvm-link \ macho-dump llvm-objdump llvm-readobj llvm-rtdyld \ llvm-dwarfdump llvm-cov llvm-size llvm-stress llvm-mcmarkup \ llvm-profdata llvm-symbolizer obj2yaml yaml2obj llvm-c-test \ - llvm-vtabledump verify-uselistorder dsymutil llvm-pdbdump + llvm-cxxdump verify-uselistorder dsymutil llvm-pdbdump # If Intel JIT Events support is configured, build an extra tool to test it. ifeq ($(USE_INTEL_JITEVENTS), 1) diff --git a/tools/llvm-vtabledump/CMakeLists.txt b/tools/llvm-cxxdump/CMakeLists.txt similarity index 63% rename from tools/llvm-vtabledump/CMakeLists.txt rename to tools/llvm-cxxdump/CMakeLists.txt index 4fe205b6efd..ada886e8887 100644 --- a/tools/llvm-vtabledump/CMakeLists.txt +++ b/tools/llvm-cxxdump/CMakeLists.txt @@ -4,7 +4,7 @@ set(LLVM_LINK_COMPONENTS Support ) -add_llvm_tool(llvm-vtabledump - llvm-vtabledump.cpp +add_llvm_tool(llvm-cxxdump + llvm-cxxdump.cpp Error.cpp ) diff --git a/tools/llvm-vtabledump/Error.cpp b/tools/llvm-cxxdump/Error.cpp similarity index 58% rename from tools/llvm-vtabledump/Error.cpp rename to tools/llvm-cxxdump/Error.cpp index c5de8951636..16fed96e483 100644 --- a/tools/llvm-vtabledump/Error.cpp +++ b/tools/llvm-cxxdump/Error.cpp @@ -1,4 +1,4 @@ -//===- Error.cpp - system_error extensions for llvm-vtabledump --*- C++ -*-===// +//===- Error.cxx - system_error extensions for llvm-cxxdump -----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This defines a new error_category for the llvm-vtabledump tool. +// This defines a new error_category for the llvm-cxxdump tool. // //===----------------------------------------------------------------------===// @@ -17,27 +17,27 @@ using namespace llvm; namespace { -class vtabledump_error_category : public std::error_category { +class cxxdump_error_category : public std::error_category { public: - const char *name() const LLVM_NOEXCEPT override { return "llvm.vtabledump"; } + const char *name() const LLVM_NOEXCEPT override { return "llvm.cxxdump"; } std::string message(int ev) const override { - switch (static_cast(ev)) { - case vtabledump_error::success: + switch (static_cast(ev)) { + case cxxdump_error::success: return "Success"; - case vtabledump_error::file_not_found: + case cxxdump_error::file_not_found: return "No such file."; - case vtabledump_error::unrecognized_file_format: + case cxxdump_error::unrecognized_file_format: return "Unrecognized file type."; } llvm_unreachable( - "An enumerator of vtabledump_error does not have a message defined."); + "An enumerator of cxxdump_error does not have a message defined."); } }; } // namespace namespace llvm { -const std::error_category &vtabledump_category() { - static vtabledump_error_category o; +const std::error_category &cxxdump_category() { + static cxxdump_error_category o; return o; } } // namespace llvm diff --git a/tools/llvm-vtabledump/Error.h b/tools/llvm-cxxdump/Error.h similarity index 51% rename from tools/llvm-vtabledump/Error.h rename to tools/llvm-cxxdump/Error.h index fd8bb18994d..7caf6d6447c 100644 --- a/tools/llvm-vtabledump/Error.h +++ b/tools/llvm-cxxdump/Error.h @@ -1,4 +1,4 @@ -//===- Error.h - system_error extensions for llvm-vtabledump ----*- C++ -*-===// +//===- Error.h - system_error extensions for llvm-cxxdump -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,33 +7,33 @@ // //===----------------------------------------------------------------------===// // -// This declares a new error_category for the llvm-vtabledump tool. +// This declares a new error_category for the llvm-cxxdump tool. // //===----------------------------------------------------------------------===// -#ifndef LLVM_TOOLS_LLVM_VTABLEDUMP_ERROR_H -#define LLVM_TOOLS_LLVM_VTABLEDUMP_ERROR_H +#ifndef LLVM_TOOLS_LLVM_CXXDUMP_ERROR_H +#define LLVM_TOOLS_LLVM_CXXDUMP_ERROR_H #include namespace llvm { -const std::error_category &vtabledump_category(); +const std::error_category &cxxdump_category(); -enum class vtabledump_error { +enum class cxxdump_error { success = 0, file_not_found, unrecognized_file_format, }; -inline std::error_code make_error_code(vtabledump_error e) { - return std::error_code(static_cast(e), vtabledump_category()); +inline std::error_code make_error_code(cxxdump_error e) { + return std::error_code(static_cast(e), cxxdump_category()); } } // namespace llvm namespace std { template <> -struct is_error_code_enum : std::true_type {}; +struct is_error_code_enum : std::true_type {}; } #endif diff --git a/tools/llvm-vtabledump/LLVMBuild.txt b/tools/llvm-cxxdump/LLVMBuild.txt similarity index 87% rename from tools/llvm-vtabledump/LLVMBuild.txt rename to tools/llvm-cxxdump/LLVMBuild.txt index 6a3cbfff4c1..4e088157799 100644 --- a/tools/llvm-vtabledump/LLVMBuild.txt +++ b/tools/llvm-cxxdump/LLVMBuild.txt @@ -1,4 +1,4 @@ -;===- ./tools/llvm-vtabledump/LLVMBuild.txt --------------------*- Conf -*--===; +;===- ./tools/llvm-cxxdump/LLVMBuild.txt -----------------------*- Conf -*--===; ; ; The LLVM Compiler Infrastructure ; @@ -17,6 +17,6 @@ [component_0] type = Tool -name = llvm-vtabledump +name = llvm-cxxdump parent = Tools required_libraries = all-targets BitReader Object diff --git a/tools/llvm-vtabledump/Makefile b/tools/llvm-cxxdump/Makefile similarity index 82% rename from tools/llvm-vtabledump/Makefile rename to tools/llvm-cxxdump/Makefile index 596c64c67b6..02e8e5f9010 100644 --- a/tools/llvm-vtabledump/Makefile +++ b/tools/llvm-cxxdump/Makefile @@ -1,4 +1,4 @@ -##===- tools/llvm-vtabledump/Makefile ----------------------*- Makefile -*-===## +##===- tools/llvm-cxxdump/Makefile -------------------------*- Makefile -*-===## # # The LLVM Compiler Infrastructure # @@ -8,7 +8,7 @@ ##===----------------------------------------------------------------------===## LEVEL := ../.. -TOOLNAME := llvm-vtabledump +TOOLNAME := llvm-cxxdump LINK_COMPONENTS := bitreader object all-targets # This tool has no plugins, optimize startup time. diff --git a/tools/llvm-vtabledump/llvm-vtabledump.cpp b/tools/llvm-cxxdump/llvm-cxxdump.cpp similarity index 96% rename from tools/llvm-vtabledump/llvm-vtabledump.cpp rename to tools/llvm-cxxdump/llvm-cxxdump.cpp index de3f5a94378..e76f66c3980 100644 --- a/tools/llvm-vtabledump/llvm-vtabledump.cpp +++ b/tools/llvm-cxxdump/llvm-cxxdump.cpp @@ -1,4 +1,4 @@ -//===- llvm-vtabledump.cpp - Dump vtables in an Object File -----*- C++ -*-===// +//===- llvm-cxxdump.cpp - Dump C++ data in an Object File -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,11 +7,11 @@ // //===----------------------------------------------------------------------===// // -// Dumps VTables resident in object files and archives. +// Dumps C++ data resident in object files and archives. // //===----------------------------------------------------------------------===// -#include "llvm-vtabledump.h" +#include "llvm-cxxdump.h" #include "Error.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/Object/Archive.h" @@ -134,7 +134,7 @@ static bool collectRelocationOffsets( return false; } -static void dumpVTables(const ObjectFile *Obj) { +static void dumpCXXData(const ObjectFile *Obj) { struct CompleteObjectLocator { StringRef Symbols[2]; ArrayRef Data; @@ -333,7 +333,8 @@ static void dumpVTables(const ObjectFile *Obj) { auto Key = std::make_pair(SymName, SymOffI); if (VTableSymEntries.count(Key)) continue; - const char *DataPtr = SymContents.substr(SymOffI, BytesInAddress).data(); + const char *DataPtr = + SymContents.substr(SymOffI, BytesInAddress).data(); int64_t VData; if (BytesInAddress == 8) VData = *reinterpret_cast(DataPtr); @@ -347,8 +348,7 @@ static void dumpVTables(const ObjectFile *Obj) { // FIXME: Do something with these! } } - for (const std::pair, StringRef> &VFTableEntry : - VFTableEntries) { + for (const auto &VFTableEntry : VFTableEntries) { StringRef VFTableName = VFTableEntry.first.first; uint64_t Offset = VFTableEntry.first.second; StringRef SymName = VFTableEntry.second; @@ -369,7 +369,8 @@ static void dumpVTables(const ObjectFile *Obj) { outs() << COLName << "[OffsetToTop]: " << COL.Data[1] << '\n'; outs() << COLName << "[VFPtrOffset]: " << COL.Data[2] << '\n'; outs() << COLName << "[TypeDescriptor]: " << COL.Symbols[0] << '\n'; - outs() << COLName << "[ClassHierarchyDescriptor]: " << COL.Symbols[1] << '\n'; + outs() << COLName << "[ClassHierarchyDescriptor]: " << COL.Symbols[1] + << '\n'; } for (const std::pair &CHDPair : CHDs) { StringRef CHDName = CHDPair.first; @@ -395,7 +396,8 @@ static void dumpVTables(const ObjectFile *Obj) { outs() << BCDName << "[VBPtrOffset]: " << BCD.Data[2] << '\n'; outs() << BCDName << "[OffsetInVBTable]: " << BCD.Data[3] << '\n'; outs() << BCDName << "[Flags]: " << BCD.Data[4] << '\n'; - outs() << BCDName << "[ClassHierarchyDescriptor]: " << BCD.Symbols[1] << '\n'; + outs() << BCDName << "[ClassHierarchyDescriptor]: " << BCD.Symbols[1] + << '\n'; } for (const std::pair &TDPair : TDs) { StringRef TDName = TDPair.first; @@ -515,17 +517,16 @@ static void dumpArchive(const Archive *Arc) { } if (ObjectFile *Obj = dyn_cast(&*ChildOrErr.get())) - dumpVTables(Obj); + dumpCXXData(Obj); else - reportError(Arc->getFileName(), - vtabledump_error::unrecognized_file_format); + reportError(Arc->getFileName(), cxxdump_error::unrecognized_file_format); } } static void dumpInput(StringRef File) { // If file isn't stdin, check that it exists. if (File != "-" && !sys::fs::exists(File)) { - reportError(File, vtabledump_error::file_not_found); + reportError(File, cxxdump_error::file_not_found); return; } @@ -540,9 +541,9 @@ static void dumpInput(StringRef File) { if (Archive *Arc = dyn_cast(&Binary)) dumpArchive(Arc); else if (ObjectFile *Obj = dyn_cast(&Binary)) - dumpVTables(Obj); + dumpCXXData(Obj); else - reportError(File, vtabledump_error::unrecognized_file_format); + reportError(File, cxxdump_error::unrecognized_file_format); } int main(int argc, const char *argv[]) { @@ -556,7 +557,7 @@ int main(int argc, const char *argv[]) { // Register the target printer for --version. cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion); - cl::ParseCommandLineOptions(argc, argv, "LLVM VTable Dumper\n"); + cl::ParseCommandLineOptions(argc, argv, "LLVM C++ ABI Data Dumper\n"); // Default to stdin if no filename is specified. if (opts::InputFilenames.size() == 0) diff --git a/tools/llvm-vtabledump/llvm-vtabledump.h b/tools/llvm-cxxdump/llvm-cxxdump.h similarity index 66% rename from tools/llvm-vtabledump/llvm-vtabledump.h rename to tools/llvm-cxxdump/llvm-cxxdump.h index 62f755739c3..daa05cb2ca0 100644 --- a/tools/llvm-vtabledump/llvm-vtabledump.h +++ b/tools/llvm-cxxdump/llvm-cxxdump.h @@ -1,4 +1,4 @@ -//===-- llvm-vtabledump.h ---------------------------------------*- C++ -*-===// +//===-- llvm-cxxdump.h ------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_TOOLS_LLVM_VTABLEDUMP_LLVM_VTABLEDUMP_H -#define LLVM_TOOLS_LLVM_VTABLEDUMP_LLVM_VTABLEDUMP_H +#ifndef LLVM_TOOLS_LLVM_CXXDUMP_LLVM_CXXDUMP_H +#define LLVM_TOOLS_LLVM_CXXDUMP_LLVM_CXXDUMP_H #include "llvm/Support/CommandLine.h" #include @@ -17,7 +17,7 @@ namespace opts { extern llvm::cl::list InputFilenames; } // namespace opts -#define LLVM_VTABLEDUMP_ENUM_ENT(ns, enum) \ +#define LLVM_CXXDUMP_ENUM_ENT(ns, enum) \ { #enum, ns::enum } #endif -- 2.34.1