mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-25 21:00:00 +00:00
Support: Add dwarf::getVirtuality()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228474 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a496490358
commit
5a504d487c
@ -38,7 +38,8 @@ namespace dwarf {
|
||||
|
||||
enum LLVMConstants : uint32_t {
|
||||
// LLVM mock tags (see also llvm/Support/Dwarf.def).
|
||||
DW_TAG_invalid = ~0U, // Tag for invalid results.
|
||||
DW_TAG_invalid = ~0U, // Tag for invalid results.
|
||||
DW_VIRTUALITY_invalid = ~0U, // Virtuality for invalid results.
|
||||
|
||||
// Other constants.
|
||||
DWARF_VERSION = 4, // Default dwarf version we output.
|
||||
@ -742,11 +743,14 @@ const char *GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage);
|
||||
/// \defgroup DwarfConstantsParsing Dwarf constants parsing functions
|
||||
///
|
||||
/// These functions map their strings back to the corresponding enumeration
|
||||
/// value or return 0 if there is none. As an exception, \a getTag() returns
|
||||
/// \a DW_TAG_invalid on invalid input.
|
||||
/// value or return 0 if there is none, except for these exceptions:
|
||||
///
|
||||
/// \li \a getTag() returns \a DW_TAG_invalid on invalid input.
|
||||
/// \li \a getVirtuality() returns \a DW_VIRTUALITY_invalid on invalid input.
|
||||
///
|
||||
/// @{
|
||||
unsigned getTag(StringRef TagString);
|
||||
unsigned getVirtuality(StringRef VirtualityString);
|
||||
unsigned getLanguage(StringRef LanguageString);
|
||||
unsigned getAttributeEncoding(StringRef EncodingString);
|
||||
/// @}
|
||||
|
@ -473,6 +473,14 @@ const char *llvm::dwarf::VirtualityString(unsigned Virtuality) {
|
||||
}
|
||||
}
|
||||
|
||||
unsigned llvm::dwarf::getVirtuality(StringRef VirtualityString) {
|
||||
return StringSwitch<unsigned>(VirtualityString)
|
||||
#define HANDLE_DW_VIRTUALITY(ID, NAME) \
|
||||
.Case("DW_VIRTUALITY_" #NAME, DW_VIRTUALITY_##NAME)
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
.Default(DW_VIRTUALITY_invalid);
|
||||
}
|
||||
|
||||
const char *llvm::dwarf::LanguageString(unsigned Language) {
|
||||
switch (Language) {
|
||||
default:
|
||||
|
@ -109,4 +109,16 @@ TEST(DwarfTest, VirtualityString) {
|
||||
EXPECT_EQ(nullptr, VirtualityString(DW_VIRTUALITY_max + 77));
|
||||
}
|
||||
|
||||
TEST(DwarfTest, getVirtuality) {
|
||||
EXPECT_EQ(DW_VIRTUALITY_none, getVirtuality("DW_VIRTUALITY_none"));
|
||||
EXPECT_EQ(DW_VIRTUALITY_virtual, getVirtuality("DW_VIRTUALITY_virtual"));
|
||||
EXPECT_EQ(DW_VIRTUALITY_pure_virtual,
|
||||
getVirtuality("DW_VIRTUALITY_pure_virtual"));
|
||||
|
||||
// Invalid strings.
|
||||
EXPECT_EQ(DW_VIRTUALITY_invalid, getVirtuality("DW_VIRTUALITY_invalid"));
|
||||
EXPECT_EQ(DW_VIRTUALITY_invalid, getVirtuality("DW_VIRTUALITY_max"));
|
||||
EXPECT_EQ(DW_VIRTUALITY_invalid, getVirtuality("something else"));
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
Loading…
Reference in New Issue
Block a user