diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-13 20:44:56 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-13 20:44:56 +0000 |
commit | de03ff572138c56dab846f26d1a4bde1aa1f59d9 (patch) | |
tree | d2f2837f400366db02f2563bd8444e0ebd2d64d6 /llvm/unittests/IR/MetadataTest.cpp | |
parent | b56d8433483b9b5a99ef5f3b3540193561e54670 (diff) | |
download | bcm5719-llvm-de03ff572138c56dab846f26d1a4bde1aa1f59d9.tar.gz bcm5719-llvm-de03ff572138c56dab846f26d1a4bde1aa1f59d9.zip |
IR: Add MDLocation class
Add a new subclass of `UniquableMDNode`, `MDLocation`. This will be the
IR version of `DebugLoc` and `DILocation`. The goal is to rename this
to `DILocation` once the IR classes supersede the `DI`-prefixed
wrappers.
This isn't used anywhere yet. Part of PR21433.
llvm-svn: 225824
Diffstat (limited to 'llvm/unittests/IR/MetadataTest.cpp')
-rw-r--r-- | llvm/unittests/IR/MetadataTest.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp index 9f5d133943b..8c5c312a2f7 100644 --- a/llvm/unittests/IR/MetadataTest.cpp +++ b/llvm/unittests/IR/MetadataTest.cpp @@ -387,6 +387,43 @@ TEST_F(MDNodeTest, replaceResolvedOperand) { Temp->replaceAllUsesWith(nullptr); } +typedef MetadataTest MDLocationTest; + +TEST_F(MDLocationTest, Overflow) { + MDNode *N = MDNode::get(Context, None); + { + MDLocation *L = MDLocation::get(Context, 2, 7, N); + EXPECT_EQ(2u, L->getLine()); + EXPECT_EQ(7u, L->getColumn()); + } + unsigned U24 = 1u << 24; + unsigned U8 = 1u << 8; + { + MDLocation *L = MDLocation::get(Context, U24 - 1, U8 - 1, N); + EXPECT_EQ(U24 - 1, L->getLine()); + EXPECT_EQ(U8 - 1, L->getColumn()); + } + { + MDLocation *L = MDLocation::get(Context, U24, U8, N); + EXPECT_EQ(0u, L->getLine()); + EXPECT_EQ(0u, L->getColumn()); + } + { + MDLocation *L = MDLocation::get(Context, U24 + 1, U8 + 1, N); + EXPECT_EQ(0u, L->getLine()); + EXPECT_EQ(0u, L->getColumn()); + } +} + +TEST_F(MDLocationTest, getDistinct) { + MDNode *N = MDNode::get(Context, None); + MDLocation *L0 = MDLocation::getDistinct(Context, 2, 7, N); + EXPECT_TRUE(L0->isDistinct()); + MDLocation *L1 = MDLocation::get(Context, 2, 7, N); + EXPECT_FALSE(L1->isDistinct()); + EXPECT_EQ(L1, MDLocation::get(Context, 2, 7, N)); +} + typedef MetadataTest MetadataAsValueTest; TEST_F(MetadataAsValueTest, MDNode) { |