IR: Allow MDSubrange to have 'count: -1'

It turns out that `count: -1` is a special value indicating an empty
array, such as `Values` in:

    struct T {
      unsigned Count;
      int Values[];
    };

Handle it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229769 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-02-18 23:17:51 +00:00
parent f89d9b1c75
commit c2c5e48ad5
4 changed files with 28 additions and 3 deletions

View File

@ -670,6 +670,14 @@ TEST_F(MDSubrangeTest, get) {
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
TEST_F(MDSubrangeTest, getEmptyArray) {
auto *N = MDSubrange::get(Context, -1, 0);
EXPECT_EQ(dwarf::DW_TAG_subrange_type, N->getTag());
EXPECT_EQ(-1, N->getCount());
EXPECT_EQ(0, N->getLo());
EXPECT_EQ(N, MDSubrange::get(Context, -1, 0));
}
typedef MetadataTest MDEnumeratorTest;
TEST_F(MDEnumeratorTest, get) {