diff options
author | Stephen Hines <srhines@google.com> | 2015-04-01 18:49:24 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-04-01 18:49:26 +0000 |
commit | 3fa16bd6062e23bcdb82ed4dd965674792e6b761 (patch) | |
tree | 9348fc507292f7e8715d22d64ce5a32131b4f875 /unittests/IR/DebugInfoTest.cpp | |
parent | beed47390a60f6f0c77532b3d3f76bb47ef49423 (diff) | |
parent | ebe69fe11e48d322045d5949c83283927a0d790b (diff) | |
download | external_llvm-3fa16bd6062e23bcdb82ed4dd965674792e6b761.zip external_llvm-3fa16bd6062e23bcdb82ed4dd965674792e6b761.tar.gz external_llvm-3fa16bd6062e23bcdb82ed4dd965674792e6b761.tar.bz2 |
Merge "Update aosp/master LLVM for rebase to r230699."
Diffstat (limited to 'unittests/IR/DebugInfoTest.cpp')
-rw-r--r-- | unittests/IR/DebugInfoTest.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/unittests/IR/DebugInfoTest.cpp b/unittests/IR/DebugInfoTest.cpp index 1fa851e..3c6c786 100644 --- a/unittests/IR/DebugInfoTest.cpp +++ b/unittests/IR/DebugInfoTest.cpp @@ -65,4 +65,71 @@ TEST(DebugInfoTest, DIHeaderFieldIterator) { ASSERT_EQ("stuff", *++MAKE_FIELD_ITERATOR("\0stuff")); } +TEST(DIDescriptorTest, getFlag) { + // Some valid flags. + EXPECT_EQ(DIDescriptor::FlagPublic, DIDescriptor::getFlag("DIFlagPublic")); + EXPECT_EQ(DIDescriptor::FlagProtected, + DIDescriptor::getFlag("DIFlagProtected")); + EXPECT_EQ(DIDescriptor::FlagPrivate, DIDescriptor::getFlag("DIFlagPrivate")); + EXPECT_EQ(DIDescriptor::FlagVector, DIDescriptor::getFlag("DIFlagVector")); + EXPECT_EQ(DIDescriptor::FlagRValueReference, + DIDescriptor::getFlag("DIFlagRValueReference")); + + // FlagAccessibility shouldn't work. + EXPECT_EQ(0u, DIDescriptor::getFlag("DIFlagAccessibility")); + + // Some other invalid strings. + EXPECT_EQ(0u, DIDescriptor::getFlag("FlagVector")); + EXPECT_EQ(0u, DIDescriptor::getFlag("Vector")); + EXPECT_EQ(0u, DIDescriptor::getFlag("other things")); + EXPECT_EQ(0u, DIDescriptor::getFlag("DIFlagOther")); +} + +TEST(DIDescriptorTest, getFlagString) { + // Some valid flags. + EXPECT_EQ(StringRef("DIFlagPublic"), + DIDescriptor::getFlagString(DIDescriptor::FlagPublic)); + EXPECT_EQ(StringRef("DIFlagProtected"), + DIDescriptor::getFlagString(DIDescriptor::FlagProtected)); + EXPECT_EQ(StringRef("DIFlagPrivate"), + DIDescriptor::getFlagString(DIDescriptor::FlagPrivate)); + EXPECT_EQ(StringRef("DIFlagVector"), + DIDescriptor::getFlagString(DIDescriptor::FlagVector)); + EXPECT_EQ(StringRef("DIFlagRValueReference"), + DIDescriptor::getFlagString(DIDescriptor::FlagRValueReference)); + + // FlagAccessibility actually equals FlagPublic. + EXPECT_EQ(StringRef("DIFlagPublic"), + DIDescriptor::getFlagString(DIDescriptor::FlagAccessibility)); + + // Some other invalid flags. + EXPECT_EQ(StringRef(), DIDescriptor::getFlagString(DIDescriptor::FlagPublic | + DIDescriptor::FlagVector)); + EXPECT_EQ(StringRef(), + DIDescriptor::getFlagString(DIDescriptor::FlagFwdDecl | + DIDescriptor::FlagArtificial)); + EXPECT_EQ(StringRef(), DIDescriptor::getFlagString(0xffff)); +} + +TEST(DIDescriptorTest, splitFlags) { + // Some valid flags. +#define CHECK_SPLIT(FLAGS, VECTOR, REMAINDER) \ + { \ + SmallVector<unsigned, 8> V; \ + EXPECT_EQ(REMAINDER, DIDescriptor::splitFlags(FLAGS, V)); \ + EXPECT_TRUE(makeArrayRef(V).equals VECTOR); \ + } + CHECK_SPLIT(DIDescriptor::FlagPublic, (DIDescriptor::FlagPublic), 0u); + CHECK_SPLIT(DIDescriptor::FlagProtected, (DIDescriptor::FlagProtected), 0u); + CHECK_SPLIT(DIDescriptor::FlagPrivate, (DIDescriptor::FlagPrivate), 0u); + CHECK_SPLIT(DIDescriptor::FlagVector, (DIDescriptor::FlagVector), 0u); + CHECK_SPLIT(DIDescriptor::FlagRValueReference, (DIDescriptor::FlagRValueReference), 0u); + CHECK_SPLIT(DIDescriptor::FlagFwdDecl | DIDescriptor::FlagVector, + (DIDescriptor::FlagFwdDecl, DIDescriptor::FlagVector), 0u); + CHECK_SPLIT(0x100000u, (), 0x100000u); + CHECK_SPLIT(0x100000u | DIDescriptor::FlagVector, (DIDescriptor::FlagVector), + 0x100000u); +#undef CHECK_SPLIT +} + } // end namespace |