mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-25 14:32:53 +00:00
Support: Add dwarf::getOperationEncoding()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229001 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5fc468cbf5
commit
191690dc8c
@ -590,6 +590,7 @@ const char *GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage);
|
||||
///
|
||||
/// @{
|
||||
unsigned getTag(StringRef TagString);
|
||||
unsigned getOperationEncoding(StringRef OperationEncodingString);
|
||||
unsigned getVirtuality(StringRef VirtualityString);
|
||||
unsigned getLanguage(StringRef LanguageString);
|
||||
unsigned getAttributeEncoding(StringRef EncodingString);
|
||||
|
@ -247,6 +247,13 @@ const char *llvm::dwarf::OperationEncodingString(unsigned Encoding) {
|
||||
}
|
||||
}
|
||||
|
||||
unsigned llvm::dwarf::getOperationEncoding(StringRef OperationEncodingString) {
|
||||
return StringSwitch<unsigned>(OperationEncodingString)
|
||||
#define HANDLE_DW_OP(ID, NAME) .Case("DW_OP_" #NAME, DW_OP_##NAME)
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
.Default(0);
|
||||
}
|
||||
|
||||
const char *llvm::dwarf::AttributeEncodingString(unsigned Encoding) {
|
||||
switch (Encoding) {
|
||||
default: return nullptr;
|
||||
|
@ -42,6 +42,20 @@ TEST(DwarfTest, getTag) {
|
||||
EXPECT_EQ(DW_TAG_invalid, getTag("DW_TAG_user_base"));
|
||||
}
|
||||
|
||||
TEST(DwarfTest, getOperationEncoding) {
|
||||
// Some valid ops.
|
||||
EXPECT_EQ(DW_OP_deref, getOperationEncoding("DW_OP_deref"));
|
||||
EXPECT_EQ(DW_OP_bit_piece, getOperationEncoding("DW_OP_bit_piece"));
|
||||
|
||||
// Invalid ops.
|
||||
EXPECT_EQ(0u, getOperationEncoding("DW_OP_otherthings"));
|
||||
EXPECT_EQ(0u, getOperationEncoding("other"));
|
||||
|
||||
// Markers shouldn't be recognized.
|
||||
EXPECT_EQ(0u, getOperationEncoding("DW_OP_lo_user"));
|
||||
EXPECT_EQ(0u, getOperationEncoding("DW_OP_hi_user"));
|
||||
}
|
||||
|
||||
TEST(DwarfTest, LanguageStringOnInvalid) {
|
||||
// This is invalid, so it shouldn't be stringified.
|
||||
EXPECT_EQ(nullptr, LanguageString(0));
|
||||
|
Loading…
Reference in New Issue
Block a user