forked from OSchip/llvm-project
Support: Add dwarf::getAttributeEncoding()
llvm-svn: 228470
This commit is contained in:
parent
dd563dd341
commit
e07f13ae35
|
@ -749,6 +749,7 @@ const char *GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage);
|
||||||
/// @{
|
/// @{
|
||||||
unsigned getTag(StringRef TagString);
|
unsigned getTag(StringRef TagString);
|
||||||
unsigned getLanguage(StringRef LanguageString);
|
unsigned getLanguage(StringRef LanguageString);
|
||||||
|
unsigned getAttributeEncoding(StringRef EncodingString);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// \brief Returns the symbolic string representing Val when used as a value
|
/// \brief Returns the symbolic string representing Val when used as a value
|
||||||
|
|
|
@ -414,6 +414,13 @@ const char *llvm::dwarf::AttributeEncodingString(unsigned Encoding) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned llvm::dwarf::getAttributeEncoding(StringRef EncodingString) {
|
||||||
|
return StringSwitch<unsigned>(EncodingString)
|
||||||
|
#define HANDLE_DW_ATE(ID, NAME) .Case("DW_ATE_" #NAME, DW_ATE_##NAME)
|
||||||
|
#include "llvm/Support/Dwarf.def"
|
||||||
|
.Default(0);
|
||||||
|
}
|
||||||
|
|
||||||
const char *llvm::dwarf::DecimalSignString(unsigned Sign) {
|
const char *llvm::dwarf::DecimalSignString(unsigned Sign) {
|
||||||
switch (Sign) {
|
switch (Sign) {
|
||||||
case DW_DS_unsigned: return "DW_DS_unsigned";
|
case DW_DS_unsigned: return "DW_DS_unsigned";
|
||||||
|
|
|
@ -79,4 +79,20 @@ TEST(DwarfTest, AttributeEncodingStringOnInvalid) {
|
||||||
EXPECT_EQ(nullptr, AttributeEncodingString(DW_ATE_hi_user));
|
EXPECT_EQ(nullptr, AttributeEncodingString(DW_ATE_hi_user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(DwarfTest, getAttributeEncoding) {
|
||||||
|
// A couple of valid languages.
|
||||||
|
EXPECT_EQ(DW_ATE_boolean, getAttributeEncoding("DW_ATE_boolean"));
|
||||||
|
EXPECT_EQ(DW_ATE_imaginary_float,
|
||||||
|
getAttributeEncoding("DW_ATE_imaginary_float"));
|
||||||
|
|
||||||
|
// Invalid languages.
|
||||||
|
EXPECT_EQ(0u, getAttributeEncoding("DW_ATE_invalid"));
|
||||||
|
EXPECT_EQ(0u, getAttributeEncoding("DW_TAG_array_type"));
|
||||||
|
EXPECT_EQ(0u, getAttributeEncoding("something else"));
|
||||||
|
|
||||||
|
// AttributeEncoding range markers should not be recognized.
|
||||||
|
EXPECT_EQ(0u, getAttributeEncoding("DW_ATE_lo_user"));
|
||||||
|
EXPECT_EQ(0u, getAttributeEncoding("DW_ATE_hi_user"));
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace
|
} // end namespace
|
||||||
|
|
Loading…
Reference in New Issue