llvm-6502/unittests/Support/DwarfTest.cpp
Duncan P. N. Exon Smith 5ff000f15e Support: Add string => unsigned mapping for DW_TAG
Add `dwarf::getTag()` to translate from `StringRef` to `unsigned`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228031 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-03 21:16:49 +00:00

46 lines
1.4 KiB
C++

//===- unittest/Support/DwarfTest.cpp - Dwarf support tests ---------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/Dwarf.h"
#include "gtest/gtest.h"
using namespace llvm;
using namespace llvm::dwarf;
namespace {
TEST(DwarfTest, TagStringOnInvalid) {
// This is invalid, so it shouldn't be stringified.
EXPECT_EQ(nullptr, TagString(DW_TAG_invalid));
// These aren't really tags: they describe ranges within tags. They
// shouldn't be stringified either.
EXPECT_EQ(nullptr, TagString(DW_TAG_lo_user));
EXPECT_EQ(nullptr, TagString(DW_TAG_hi_user));
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