diff options
author | Sander de Smalen <sander.desmalen@arm.com> | 2018-01-24 09:56:07 +0000 |
---|---|---|
committer | Sander de Smalen <sander.desmalen@arm.com> | 2018-01-24 09:56:07 +0000 |
commit | fdf40917d946e3b36fd67afb2aac4063af9fc85d (patch) | |
tree | 9f0bac9e282261c26720ea14594ddb76e35f5d2f /llvm/unittests/IR/MetadataTest.cpp | |
parent | e8404780c38e44ccbbc1cd89873929ed4c49dac0 (diff) | |
download | bcm5719-llvm-fdf40917d946e3b36fd67afb2aac4063af9fc85d.tar.gz bcm5719-llvm-fdf40917d946e3b36fd67afb2aac4063af9fc85d.zip |
[Metadata] Extend 'count' field of DISubrange to take a metadata node
Summary:
This patch extends the DISubrange 'count' field to take either a
(signed) constant integer value or a reference to a DILocalVariable
or DIGlobalVariable.
This is patch [1/3] in a series to extend LLVM's DISubrange Metadata
node to support debugging of C99 variable length arrays and vectors with
runtime length like the Scalable Vector Extension for AArch64. It is
also a first step towards representing more complex cases like arrays
in Fortran.
Reviewers: echristo, pcc, aprantl, dexonsmith, clayborg, kristof.beyls, dblaikie
Reviewed By: aprantl
Subscribers: rnk, probinson, fhahn, aemerson, rengolin, JDevlieghere, llvm-commits
Differential Revision: https://reviews.llvm.org/D41695
llvm-svn: 323313
Diffstat (limited to 'llvm/unittests/IR/MetadataTest.cpp')
-rw-r--r-- | llvm/unittests/IR/MetadataTest.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp index 51ca8408f1a..af58657d5f1 100644 --- a/llvm/unittests/IR/MetadataTest.cpp +++ b/llvm/unittests/IR/MetadataTest.cpp @@ -932,8 +932,11 @@ typedef MetadataTest DISubrangeTest; TEST_F(DISubrangeTest, get) { auto *N = DISubrange::get(Context, 5, 7); + auto Count = N->getCount(); EXPECT_EQ(dwarf::DW_TAG_subrange_type, N->getTag()); - EXPECT_EQ(5, N->getCount()); + ASSERT_TRUE(Count); + ASSERT_TRUE(Count.is<ConstantInt*>()); + EXPECT_EQ(5, Count.get<ConstantInt*>()->getSExtValue()); EXPECT_EQ(7, N->getLowerBound()); EXPECT_EQ(N, DISubrange::get(Context, 5, 7)); EXPECT_EQ(DISubrange::get(Context, 5, 0), DISubrange::get(Context, 5)); @@ -944,12 +947,34 @@ TEST_F(DISubrangeTest, get) { TEST_F(DISubrangeTest, getEmptyArray) { auto *N = DISubrange::get(Context, -1, 0); + auto Count = N->getCount(); EXPECT_EQ(dwarf::DW_TAG_subrange_type, N->getTag()); - EXPECT_EQ(-1, N->getCount()); + ASSERT_TRUE(Count); + ASSERT_TRUE(Count.is<ConstantInt*>()); + EXPECT_EQ(-1, Count.get<ConstantInt*>()->getSExtValue()); EXPECT_EQ(0, N->getLowerBound()); EXPECT_EQ(N, DISubrange::get(Context, -1, 0)); } +TEST_F(DISubrangeTest, getVariableCount) { + DILocalScope *Scope = getSubprogram(); + DIFile *File = getFile(); + DIType *Type = getDerivedType(); + DINode::DIFlags Flags = static_cast<DINode::DIFlags>(7); + auto *VlaExpr = DILocalVariable::get(Context, Scope, "vla_expr", File, 8, + Type, 2, Flags, 8); + + auto *N = DISubrange::get(Context, VlaExpr, 0); + auto Count = N->getCount(); + ASSERT_TRUE(Count); + ASSERT_TRUE(Count.is<DIVariable*>()); + EXPECT_EQ(VlaExpr, Count.get<DIVariable*>()); + ASSERT_TRUE(isa<DIVariable>(N->getRawCountNode())); + EXPECT_EQ(0, N->getLowerBound()); + EXPECT_EQ("vla_expr", Count.get<DIVariable*>()->getName()); + EXPECT_EQ(N, DISubrange::get(Context, VlaExpr, 0)); +} + typedef MetadataTest DIEnumeratorTest; TEST_F(DIEnumeratorTest, get) { |