forked from OSchip/llvm-project
Support: Use Dwarf.def for DW_VIRTUALITY, NFC
Use definition file for `DW_VIRTUALITY_*`. Add a `DW_VIRTUALITY_max` both for ease of testing and for future use by the `LLParser`. llvm-svn: 228473
This commit is contained in:
parent
dc494d5303
commit
d6f3574210
|
@ -12,7 +12,8 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// TODO: Add other DW-based macros.
|
||||
#if !(defined HANDLE_DW_TAG || defined HANDLE_DW_LANG || defined HANDLE_DW_ATE)
|
||||
#if !(defined HANDLE_DW_TAG || defined HANDLE_DW_LANG || \
|
||||
defined HANDLE_DW_ATE || defined HANDLE_DW_VIRTUALITY)
|
||||
#error "Missing macro definition of HANDLE_DW*"
|
||||
#endif
|
||||
|
||||
|
@ -28,6 +29,10 @@
|
|||
#define HANDLE_DW_ATE(ID, NAME)
|
||||
#endif
|
||||
|
||||
#ifndef HANDLE_DW_VIRTUALITY
|
||||
#define HANDLE_DW_VIRTUALITY(ID, NAME)
|
||||
#endif
|
||||
|
||||
HANDLE_DW_TAG(0x0001, array_type)
|
||||
HANDLE_DW_TAG(0x0002, class_type)
|
||||
HANDLE_DW_TAG(0x0003, entry_point)
|
||||
|
@ -159,6 +164,12 @@ HANDLE_DW_ATE(0x0e, unsigned_fixed)
|
|||
HANDLE_DW_ATE(0x0f, decimal_float)
|
||||
HANDLE_DW_ATE(0x10, UTF)
|
||||
|
||||
// DWARF virtuality codes.
|
||||
HANDLE_DW_VIRTUALITY(0x00, none)
|
||||
HANDLE_DW_VIRTUALITY(0x01, virtual)
|
||||
HANDLE_DW_VIRTUALITY(0x02, pure_virtual)
|
||||
|
||||
#undef HANDLE_DW_TAG
|
||||
#undef HANDLE_DW_LANG
|
||||
#undef HANDLE_DW_ATE
|
||||
#undef HANDLE_DW_VIRTUALITY
|
||||
|
|
|
@ -494,10 +494,9 @@ enum VisibilityAttribute {
|
|||
};
|
||||
|
||||
enum VirtualityAttribute {
|
||||
// Virtuality codes
|
||||
DW_VIRTUALITY_none = 0x00,
|
||||
DW_VIRTUALITY_virtual = 0x01,
|
||||
DW_VIRTUALITY_pure_virtual = 0x02
|
||||
#define HANDLE_DW_VIRTUALITY(ID, NAME) DW_VIRTUALITY_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
DW_VIRTUALITY_max = 0x02
|
||||
};
|
||||
|
||||
enum SourceLanguage {
|
||||
|
|
|
@ -464,11 +464,13 @@ const char *llvm::dwarf::VisibilityString(unsigned Visibility) {
|
|||
|
||||
const char *llvm::dwarf::VirtualityString(unsigned Virtuality) {
|
||||
switch (Virtuality) {
|
||||
case DW_VIRTUALITY_none: return "DW_VIRTUALITY_none";
|
||||
case DW_VIRTUALITY_virtual: return "DW_VIRTUALITY_virtual";
|
||||
case DW_VIRTUALITY_pure_virtual: return "DW_VIRTUALITY_pure_virtual";
|
||||
default:
|
||||
return nullptr;
|
||||
#define HANDLE_DW_VIRTUALITY(ID, NAME) \
|
||||
case DW_VIRTUALITY_##NAME: \
|
||||
return "DW_VIRTUALITY_" #NAME;
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *llvm::dwarf::LanguageString(unsigned Language) {
|
||||
|
|
|
@ -95,4 +95,18 @@ TEST(DwarfTest, getAttributeEncoding) {
|
|||
EXPECT_EQ(0u, getAttributeEncoding("DW_ATE_hi_user"));
|
||||
}
|
||||
|
||||
TEST(DwarfTest, VirtualityString) {
|
||||
EXPECT_EQ("DW_VIRTUALITY_none", VirtualityString(DW_VIRTUALITY_none));
|
||||
EXPECT_EQ("DW_VIRTUALITY_virtual", VirtualityString(DW_VIRTUALITY_virtual));
|
||||
EXPECT_EQ("DW_VIRTUALITY_pure_virtual",
|
||||
VirtualityString(DW_VIRTUALITY_pure_virtual));
|
||||
|
||||
// DW_VIRTUALITY_max should be pure virtual.
|
||||
EXPECT_EQ("DW_VIRTUALITY_pure_virtual", VirtualityString(DW_VIRTUALITY_max));
|
||||
|
||||
// Invalid numbers shouldn't be stringified.
|
||||
EXPECT_EQ(nullptr, VirtualityString(DW_VIRTUALITY_max + 1));
|
||||
EXPECT_EQ(nullptr, VirtualityString(DW_VIRTUALITY_max + 77));
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
|
Loading…
Reference in New Issue