[llvm] 9456bbd - [BinaryFormat] Add formatv support for DW_OP constants
Pavel Labath via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 06:28:10 PDT 2020
Author: Pavel Labath
Date: 2020-06-08T15:27:44+02:00
New Revision: 9456bbdd0874e5bd1427222fac2897bc3cbda34d
URL: https://github.com/llvm/llvm-project/commit/9456bbdd0874e5bd1427222fac2897bc3cbda34d
DIFF: https://github.com/llvm/llvm-project/commit/9456bbdd0874e5bd1427222fac2897bc3cbda34d.diff
LOG: [BinaryFormat] Add formatv support for DW_OP constants
The functionality will be used from lldb.
Added:
Modified:
llvm/include/llvm/BinaryFormat/Dwarf.h
llvm/lib/BinaryFormat/Dwarf.cpp
llvm/unittests/BinaryFormat/DwarfTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.h b/llvm/include/llvm/BinaryFormat/Dwarf.h
index 00e580bbe450..4e8b708f39bb 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.h
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -669,6 +669,11 @@ template <> struct EnumTraits<LineNumberOps> : public std::true_type {
static constexpr char Type[4] = "LNS";
static constexpr StringRef (*StringFn)(unsigned) = &LNStandardString;
};
+
+template <> struct EnumTraits<LocationAtom> : public std::true_type {
+ static constexpr char Type[3] = "OP";
+ static constexpr StringRef (*StringFn)(unsigned) = &OperationEncodingString;
+};
} // End of namespace dwarf
/// Dwarf constants format_provider
diff --git a/llvm/lib/BinaryFormat/Dwarf.cpp b/llvm/lib/BinaryFormat/Dwarf.cpp
index 971b850a09cc..a497c16685c1 100644
--- a/llvm/lib/BinaryFormat/Dwarf.cpp
+++ b/llvm/lib/BinaryFormat/Dwarf.cpp
@@ -789,3 +789,4 @@ constexpr char llvm::dwarf::EnumTraits<Form>::Type[];
constexpr char llvm::dwarf::EnumTraits<Index>::Type[];
constexpr char llvm::dwarf::EnumTraits<Tag>::Type[];
constexpr char llvm::dwarf::EnumTraits<LineNumberOps>::Type[];
+constexpr char llvm::dwarf::EnumTraits<LocationAtom>::Type[];
diff --git a/llvm/unittests/BinaryFormat/DwarfTest.cpp b/llvm/unittests/BinaryFormat/DwarfTest.cpp
index 5509689f89e0..5e49a5cc2ee6 100644
--- a/llvm/unittests/BinaryFormat/DwarfTest.cpp
+++ b/llvm/unittests/BinaryFormat/DwarfTest.cpp
@@ -201,5 +201,7 @@ TEST(DwarfTest, format_provider) {
EXPECT_EQ("DW_IDX_unknown_3fff", formatv("{0}", DW_IDX_hi_user).str());
EXPECT_EQ("DW_TAG_compile_unit", formatv("{0}", DW_TAG_compile_unit).str());
EXPECT_EQ("DW_TAG_unknown_ffff", formatv("{0}", DW_TAG_hi_user).str());
+ EXPECT_EQ("DW_OP_lit0", formatv("{0}", DW_OP_lit0).str());
+ EXPECT_EQ("DW_OP_unknown_ff", formatv("{0}", DW_OP_hi_user).str());
}
} // end namespace
More information about the llvm-commits
mailing list