summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/DwarfTest.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-03 21:16:49 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-03 21:16:49 +0000
commit6f5546cdeee7ee02edf2f7f9d26a0c6ada8895a3 (patch)
tree0bb3a1c5c63b13fe545fd6ad99f23bc2ad2f0dcd /llvm/unittests/Support/DwarfTest.cpp
parent981811efc811f48ebeeb1204609d386f7cedf749 (diff)
downloadbcm5719-llvm-6f5546cdeee7ee02edf2f7f9d26a0c6ada8895a3.tar.gz
bcm5719-llvm-6f5546cdeee7ee02edf2f7f9d26a0c6ada8895a3.zip
Support: Add string => unsigned mapping for DW_TAG
Add `dwarf::getTag()` to translate from `StringRef` to `unsigned`. llvm-svn: 228031
Diffstat (limited to 'llvm/unittests/Support/DwarfTest.cpp')
-rw-r--r--llvm/unittests/Support/DwarfTest.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/unittests/Support/DwarfTest.cpp b/llvm/unittests/Support/DwarfTest.cpp
index 9b141601b20..d016aacedce 100644
--- a/llvm/unittests/Support/DwarfTest.cpp
+++ b/llvm/unittests/Support/DwarfTest.cpp
@@ -26,4 +26,20 @@ TEST(DwarfTest, TagStringOnInvalid) {
EXPECT_EQ(nullptr, TagString(DW_TAG_user_base));
}
+TEST(DwarfTest, getTag) {
+ // A couple of valid tags.
+ EXPECT_EQ(DW_TAG_array_type, getTag("DW_TAG_array_type"));
+ EXPECT_EQ(DW_TAG_module, getTag("DW_TAG_module"));
+
+ // Invalid tags.
+ EXPECT_EQ(DW_TAG_invalid, getTag("DW_TAG_invalid"));
+ EXPECT_EQ(DW_TAG_invalid, getTag("DW_TAG_madeuptag"));
+ EXPECT_EQ(DW_TAG_invalid, getTag("something else"));
+
+ // Tag range markers should not be recognized.
+ EXPECT_EQ(DW_TAG_invalid, getTag("DW_TAG_lo_user"));
+ EXPECT_EQ(DW_TAG_invalid, getTag("DW_TAG_hi_user"));
+ EXPECT_EQ(DW_TAG_invalid, getTag("DW_TAG_user_base"));
+}
+
} // end namespace
OpenPOWER on IntegriCloud