diff options
author | Pirama Arumuga Nainar <pirama@google.com> | 2015-05-06 11:46:36 -0700 |
---|---|---|
committer | Pirama Arumuga Nainar <pirama@google.com> | 2015-05-18 10:52:30 -0700 |
commit | 2c3e0051c31c3f5b2328b447eadf1cf9c4427442 (patch) | |
tree | c0104029af14e9f47c2ef58ca60e6137691f3c9b /unittests/IR | |
parent | e1bc145815f4334641be19f1c45ecf85d25b6e5a (diff) | |
download | external_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.zip external_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.tar.gz external_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.tar.bz2 |
Update aosp/master LLVM for rebase to r235153
Change-Id: I9bf53792f9fc30570e81a8d80d296c681d005ea7
(cherry picked from commit 0c7f116bb6950ef819323d855415b2f2b0aad987)
Diffstat (limited to 'unittests/IR')
-rw-r--r-- | unittests/IR/ConstantsTest.cpp | 8 | ||||
-rw-r--r-- | unittests/IR/DebugInfoTest.cpp | 128 | ||||
-rw-r--r-- | unittests/IR/DominatorTreeTest.cpp | 32 | ||||
-rw-r--r-- | unittests/IR/IRBuilderTest.cpp | 15 | ||||
-rw-r--r-- | unittests/IR/MetadataTest.cpp | 526 | ||||
-rw-r--r-- | unittests/IR/ValueHandleTest.cpp | 24 | ||||
-rw-r--r-- | unittests/IR/ValueMapTest.cpp | 3 |
7 files changed, 398 insertions, 338 deletions
diff --git a/unittests/IR/ConstantsTest.cpp b/unittests/IR/ConstantsTest.cpp index 0e040bc..0c7777d 100644 --- a/unittests/IR/ConstantsTest.cpp +++ b/unittests/IR/ConstantsTest.cpp @@ -249,7 +249,8 @@ TEST(ConstantsTest, AsInstructionsTest) { // not a normal one! //CHECK(ConstantExpr::getGetElementPtr(Global, V, false), // "getelementptr i32*, i32** @dummy, i32 1"); - CHECK(ConstantExpr::getInBoundsGetElementPtr(Global, V), + CHECK(ConstantExpr::getInBoundsGetElementPtr(PointerType::getUnqual(Int32Ty), + Global, V), "getelementptr inbounds i32*, i32** @dummy, i32 1"); CHECK(ConstantExpr::getExtractElement(P6, One), "extractelement <2 x i16> " @@ -266,7 +267,8 @@ TEST(ConstantsTest, ReplaceWithConstantTest) { Constant *Global = M->getOrInsertGlobal("dummy", PointerType::getUnqual(Int32Ty)); - Constant *GEP = ConstantExpr::getGetElementPtr(Global, One); + Constant *GEP = ConstantExpr::getGetElementPtr( + PointerType::getUnqual(Int32Ty), Global, One); EXPECT_DEATH(Global->replaceAllUsesWith(GEP), "this->replaceAllUsesWith\\(expr\\(this\\)\\) is NOT valid!"); } @@ -333,7 +335,7 @@ TEST(ConstantsTest, GEPReplaceWithConstant) { auto *C1 = ConstantInt::get(IntTy, 1); auto *Placeholder = new GlobalVariable( *M, IntTy, false, GlobalValue::ExternalWeakLinkage, nullptr); - auto *GEP = ConstantExpr::getGetElementPtr(Placeholder, C1); + auto *GEP = ConstantExpr::getGetElementPtr(IntTy, Placeholder, C1); ASSERT_EQ(GEP->getOperand(0), Placeholder); auto *Ref = diff --git a/unittests/IR/DebugInfoTest.cpp b/unittests/IR/DebugInfoTest.cpp index a957b99..534663a 100644 --- a/unittests/IR/DebugInfoTest.cpp +++ b/unittests/IR/DebugInfoTest.cpp @@ -7,127 +7,75 @@ // //===----------------------------------------------------------------------===// -#include "llvm/IR/DebugInfo.h" +#include "llvm/IR/DebugInfoMetadata.h" #include "gtest/gtest.h" using namespace llvm; -namespace llvm { - -static void PrintTo(const StringRef &S, ::std::ostream *os) { - *os << "(" << (const void *)S.data() << "," << S.size() << ") = '"; - for (auto C : S) - if (C) - *os << C; - else - *os << "\\00"; - *os << "'"; -} -static void PrintTo(const DIHeaderFieldIterator &I, ::std::ostream *os) { - PrintTo(I.getCurrent(), os); - *os << " in "; - PrintTo(I.getHeader(), os); -} - -} // end namespace llvm - namespace { -#define MAKE_FIELD_ITERATOR(S) \ - DIHeaderFieldIterator(StringRef(S, sizeof(S) - 1)) -TEST(DebugInfoTest, DIHeaderFieldIterator) { - ASSERT_EQ(DIHeaderFieldIterator(), DIHeaderFieldIterator()); - - ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("")); - ASSERT_EQ(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("")); - ASSERT_EQ("", *DIHeaderFieldIterator("")); - - ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("stuff")); - ASSERT_EQ(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("stuff")); - ASSERT_EQ("stuff", *DIHeaderFieldIterator("stuff")); - - ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("st\0uff")); - ASSERT_NE(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("st\0uff")); - ASSERT_EQ(DIHeaderFieldIterator(), ++++MAKE_FIELD_ITERATOR("st\0uff")); - ASSERT_EQ("st", *MAKE_FIELD_ITERATOR("st\0uff")); - ASSERT_EQ("uff", *++MAKE_FIELD_ITERATOR("st\0uff")); - - ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("stuff\0")); - ASSERT_NE(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("stuff\0")); - ASSERT_EQ(DIHeaderFieldIterator(), ++++MAKE_FIELD_ITERATOR("stuff\0")); - ASSERT_EQ("stuff", *MAKE_FIELD_ITERATOR("stuff\0")); - ASSERT_EQ("", *++MAKE_FIELD_ITERATOR("stuff\0")); - - ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("\0stuff")); - ASSERT_NE(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("\0stuff")); - ASSERT_EQ(DIHeaderFieldIterator(), ++++MAKE_FIELD_ITERATOR("\0stuff")); - ASSERT_EQ("", *MAKE_FIELD_ITERATOR("\0stuff")); - ASSERT_EQ("stuff", *++MAKE_FIELD_ITERATOR("\0stuff")); -} - -TEST(DIDescriptorTest, getFlag) { +TEST(DebugNodeTest, 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")); + EXPECT_EQ(DebugNode::FlagPublic, DebugNode::getFlag("DIFlagPublic")); + EXPECT_EQ(DebugNode::FlagProtected, DebugNode::getFlag("DIFlagProtected")); + EXPECT_EQ(DebugNode::FlagPrivate, DebugNode::getFlag("DIFlagPrivate")); + EXPECT_EQ(DebugNode::FlagVector, DebugNode::getFlag("DIFlagVector")); + EXPECT_EQ(DebugNode::FlagRValueReference, + DebugNode::getFlag("DIFlagRValueReference")); // FlagAccessibility shouldn't work. - EXPECT_EQ(0u, DIDescriptor::getFlag("DIFlagAccessibility")); + EXPECT_EQ(0u, DebugNode::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")); + EXPECT_EQ(0u, DebugNode::getFlag("FlagVector")); + EXPECT_EQ(0u, DebugNode::getFlag("Vector")); + EXPECT_EQ(0u, DebugNode::getFlag("other things")); + EXPECT_EQ(0u, DebugNode::getFlag("DIFlagOther")); } -TEST(DIDescriptorTest, getFlagString) { +TEST(DebugNodeTest, getFlagString) { // Some valid flags. EXPECT_EQ(StringRef("DIFlagPublic"), - DIDescriptor::getFlagString(DIDescriptor::FlagPublic)); + DebugNode::getFlagString(DebugNode::FlagPublic)); EXPECT_EQ(StringRef("DIFlagProtected"), - DIDescriptor::getFlagString(DIDescriptor::FlagProtected)); + DebugNode::getFlagString(DebugNode::FlagProtected)); EXPECT_EQ(StringRef("DIFlagPrivate"), - DIDescriptor::getFlagString(DIDescriptor::FlagPrivate)); + DebugNode::getFlagString(DebugNode::FlagPrivate)); EXPECT_EQ(StringRef("DIFlagVector"), - DIDescriptor::getFlagString(DIDescriptor::FlagVector)); + DebugNode::getFlagString(DebugNode::FlagVector)); EXPECT_EQ(StringRef("DIFlagRValueReference"), - DIDescriptor::getFlagString(DIDescriptor::FlagRValueReference)); + DebugNode::getFlagString(DebugNode::FlagRValueReference)); // FlagAccessibility actually equals FlagPublic. EXPECT_EQ(StringRef("DIFlagPublic"), - DIDescriptor::getFlagString(DIDescriptor::FlagAccessibility)); + DebugNode::getFlagString(DebugNode::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)); + EXPECT_EQ(StringRef(), DebugNode::getFlagString(DebugNode::FlagPublic | + DebugNode::FlagVector)); + EXPECT_EQ(StringRef(), DebugNode::getFlagString(DebugNode::FlagFwdDecl | + DebugNode::FlagArtificial)); + EXPECT_EQ(StringRef(), DebugNode::getFlagString(0xffff)); } -TEST(DIDescriptorTest, splitFlags) { - // Some valid flags. +TEST(DebugNodeTest, 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)); \ + EXPECT_EQ(REMAINDER, DebugNode::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); - unsigned Flags[] = {DIDescriptor::FlagFwdDecl, DIDescriptor::FlagVector}; - CHECK_SPLIT(DIDescriptor::FlagFwdDecl | DIDescriptor::FlagVector, Flags, 0u); + CHECK_SPLIT(DebugNode::FlagPublic, {DebugNode::FlagPublic}, 0u); + CHECK_SPLIT(DebugNode::FlagProtected, {DebugNode::FlagProtected}, 0u); + CHECK_SPLIT(DebugNode::FlagPrivate, {DebugNode::FlagPrivate}, 0u); + CHECK_SPLIT(DebugNode::FlagVector, {DebugNode::FlagVector}, 0u); + CHECK_SPLIT(DebugNode::FlagRValueReference, {DebugNode::FlagRValueReference}, + 0u); + unsigned Flags[] = {DebugNode::FlagFwdDecl, DebugNode::FlagVector}; + CHECK_SPLIT(DebugNode::FlagFwdDecl | DebugNode::FlagVector, Flags, 0u); CHECK_SPLIT(0x100000u, {}, 0x100000u); - CHECK_SPLIT(0x100000u | DIDescriptor::FlagVector, {DIDescriptor::FlagVector}, + CHECK_SPLIT(0x100000u | DebugNode::FlagVector, {DebugNode::FlagVector}, 0x100000u); #undef CHECK_SPLIT } diff --git a/unittests/IR/DominatorTreeTest.cpp b/unittests/IR/DominatorTreeTest.cpp index 8d2dc41..6a5838e 100644 --- a/unittests/IR/DominatorTreeTest.cpp +++ b/unittests/IR/DominatorTreeTest.cpp @@ -10,6 +10,7 @@ #include "llvm/IR/Dominators.h" #include "llvm/Analysis/PostDominators.h" #include "llvm/AsmParser/Parser.h" +#include "llvm/IR/Constants.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" @@ -25,7 +26,7 @@ namespace llvm { namespace { struct DPass : public FunctionPass { static char ID; - virtual bool runOnFunction(Function &F) { + bool runOnFunction(Function &F) override { DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); PostDominatorTree *PDT = &getAnalysis<PostDominatorTree>(); @@ -174,9 +175,36 @@ namespace llvm { EXPECT_EQ(DominatedBBs.size(), 0UL); EXPECT_EQ(PostDominatedBBs.size(), 0UL); + // Check DFS Numbers before + EXPECT_EQ(DT->getNode(BB0)->getDFSNumIn(), 0UL); + EXPECT_EQ(DT->getNode(BB0)->getDFSNumOut(), 7UL); + EXPECT_EQ(DT->getNode(BB1)->getDFSNumIn(), 1UL); + EXPECT_EQ(DT->getNode(BB1)->getDFSNumOut(), 2UL); + EXPECT_EQ(DT->getNode(BB2)->getDFSNumIn(), 5UL); + EXPECT_EQ(DT->getNode(BB2)->getDFSNumOut(), 6UL); + EXPECT_EQ(DT->getNode(BB4)->getDFSNumIn(), 3UL); + EXPECT_EQ(DT->getNode(BB4)->getDFSNumOut(), 4UL); + + // Reattach block 3 to block 1 and recalculate + BB1->getTerminator()->eraseFromParent(); + BranchInst::Create(BB4, BB3, ConstantInt::getTrue(F.getContext()), BB1); + DT->recalculate(F); + + // Check DFS Numbers after + EXPECT_EQ(DT->getNode(BB0)->getDFSNumIn(), 0UL); + EXPECT_EQ(DT->getNode(BB0)->getDFSNumOut(), 9UL); + EXPECT_EQ(DT->getNode(BB1)->getDFSNumIn(), 1UL); + EXPECT_EQ(DT->getNode(BB1)->getDFSNumOut(), 4UL); + EXPECT_EQ(DT->getNode(BB2)->getDFSNumIn(), 7UL); + EXPECT_EQ(DT->getNode(BB2)->getDFSNumOut(), 8UL); + EXPECT_EQ(DT->getNode(BB3)->getDFSNumIn(), 2UL); + EXPECT_EQ(DT->getNode(BB3)->getDFSNumOut(), 3UL); + EXPECT_EQ(DT->getNode(BB4)->getDFSNumIn(), 5UL); + EXPECT_EQ(DT->getNode(BB4)->getDFSNumOut(), 6UL); + return false; } - virtual void getAnalysisUsage(AnalysisUsage &AU) const { + void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired<DominatorTreeWrapperPass>(); AU.addRequired<PostDominatorTree>(); } diff --git a/unittests/IR/IRBuilderTest.cpp b/unittests/IR/IRBuilderTest.cpp index ca378a3..9fe241c 100644 --- a/unittests/IR/IRBuilderTest.cpp +++ b/unittests/IR/IRBuilderTest.cpp @@ -17,6 +17,7 @@ #include "llvm/IR/MDBuilder.h" #include "llvm/IR/Module.h" #include "llvm/IR/NoFolder.h" +#include "llvm/IR/Verifier.h" #include "gtest/gtest.h" using namespace llvm; @@ -25,7 +26,7 @@ namespace { class IRBuilderTest : public testing::Test { protected: - virtual void SetUp() { + void SetUp() override { M.reset(new Module("MyModule", Ctx)); FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx), /*isVarArg=*/false); @@ -35,7 +36,7 @@ protected: GlobalValue::ExternalLinkage, nullptr); } - virtual void TearDown() { + void TearDown() override { BB = nullptr; M.reset(); } @@ -295,14 +296,14 @@ TEST_F(IRBuilderTest, DIBuilder) { auto CU = DIB.createCompileUnit(dwarf::DW_LANG_Cobol74, "F.CBL", "/", "llvm-cobol74", true, "", 0); auto Type = DIB.createSubroutineType(File, DIB.getOrCreateTypeArray(None)); - auto SP = DIB.createFunction(CU, "foo", "", File, 1, Type, - false, true, 1, 0, true, F); - EXPECT_TRUE(SP.Verify()); + DIB.createFunction(CU, "foo", "", File, 1, Type, false, true, 1, 0, true, F); AllocaInst *I = Builder.CreateAlloca(Builder.getInt8Ty()); - auto BadScope = DIB.createLexicalBlockFile(DIDescriptor(), File, 0); + auto BarSP = DIB.createFunction(CU, "bar", "", File, 1, Type, false, true, 1, + 0, true, nullptr); + auto BadScope = DIB.createLexicalBlockFile(BarSP, File, 0); I->setDebugLoc(DebugLoc::get(2, 0, BadScope)); - EXPECT_FALSE(SP.Verify()); DIB.finalize(); + EXPECT_TRUE(verifyModule(*M)); } diff --git a/unittests/IR/MetadataTest.cpp b/unittests/IR/MetadataTest.cpp index 51a9e0b..8b4c5db 100644 --- a/unittests/IR/MetadataTest.cpp +++ b/unittests/IR/MetadataTest.cpp @@ -61,8 +61,14 @@ TEST(ContextAndReplaceableUsesTest, takeReplaceableUses) { } class MetadataTest : public testing::Test { +public: + MetadataTest() : M("test", Context), Counter(0) {} + protected: LLVMContext Context; + Module M; + int Counter; + MDNode *getNode() { return MDNode::get(Context, None); } MDNode *getNode(Metadata *MD) { return MDNode::get(Context, MD); } MDNode *getNode(Metadata *MD1, Metadata *MD2) { @@ -70,11 +76,45 @@ protected: return MDNode::get(Context, MDs); } + MDTuple *getTuple() { return MDTuple::getDistinct(Context, None); } + MDSubroutineType *getSubroutineType() { + return MDSubroutineType::getDistinct(Context, 0, getNode(nullptr)); + } MDSubprogram *getSubprogram() { return MDSubprogram::getDistinct(Context, nullptr, "", "", nullptr, 0, nullptr, false, false, 0, nullptr, 0, 0, 0, 0); } + MDScopeRef getSubprogramRef() { return getSubprogram()->getRef(); } + MDFile *getFile() { + return MDFile::getDistinct(Context, "file.c", "/path/to/dir"); + } + MDTypeRef getBasicType(StringRef Name) { + return MDBasicType::get(Context, dwarf::DW_TAG_unspecified_type, Name) + ->getRef(); + } + MDTypeRef getDerivedType() { + return MDDerivedType::getDistinct(Context, dwarf::DW_TAG_pointer_type, "", + nullptr, 0, nullptr, + getBasicType("basictype"), 1, 2, 0, 0) + ->getRef(); + } + Constant *getConstant() { + return ConstantInt::get(Type::getInt32Ty(Context), Counter++); + } + ConstantAsMetadata *getConstantAsMetadata() { + return ConstantAsMetadata::get(getConstant()); + } + MDTypeRef getCompositeType() { + return MDCompositeType::getDistinct( + Context, dwarf::DW_TAG_structure_type, "", nullptr, 0, nullptr, + nullptr, 32, 32, 0, 0, nullptr, 0, nullptr, nullptr, "") + ->getRef(); + } + Function *getFunction(StringRef Name) { + return cast<Function>(M.getOrInsertFunction( + Name, FunctionType::get(Type::getVoidTy(Context), None, false))); + } }; typedef MetadataTest MDStringTest; @@ -593,6 +633,48 @@ TEST_F(MDNodeTest, replaceWithUniqued) { } } +TEST_F(MDNodeTest, replaceWithUniquedResolvingOperand) { + // temp !{} + MDTuple *Op = MDTuple::getTemporary(Context, None).release(); + EXPECT_FALSE(Op->isResolved()); + + // temp !{temp !{}} + Metadata *Ops[] = {Op}; + MDTuple *N = MDTuple::getTemporary(Context, Ops).release(); + EXPECT_FALSE(N->isResolved()); + + // temp !{temp !{}} => !{temp !{}} + ASSERT_EQ(N, MDNode::replaceWithUniqued(TempMDTuple(N))); + EXPECT_FALSE(N->isResolved()); + + // !{temp !{}} => !{!{}} + ASSERT_EQ(Op, MDNode::replaceWithUniqued(TempMDTuple(Op))); + EXPECT_TRUE(Op->isResolved()); + EXPECT_TRUE(N->isResolved()); +} + +TEST_F(MDNodeTest, replaceWithUniquedChangingOperand) { + // i1* @GV + Type *Ty = Type::getInt1PtrTy(Context); + std::unique_ptr<GlobalVariable> GV( + new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage)); + ConstantAsMetadata *Op = ConstantAsMetadata::get(GV.get()); + + // temp !{i1* @GV} + Metadata *Ops[] = {Op}; + MDTuple *N = MDTuple::getTemporary(Context, Ops).release(); + + // temp !{i1* @GV} => !{i1* @GV} + ASSERT_EQ(N, MDNode::replaceWithUniqued(TempMDTuple(N))); + ASSERT_TRUE(N->isUniqued()); + + // !{i1* @GV} => !{null} + GV.reset(); + ASSERT_TRUE(N->isUniqued()); + Metadata *NullOps[] = {nullptr}; + ASSERT_EQ(N, MDTuple::get(Context, NullOps)); +} + TEST_F(MDNodeTest, replaceWithDistinct) { { auto *Empty = MDTuple::get(Context, None); @@ -768,7 +850,7 @@ TEST_F(MDSubrangeTest, get) { auto *N = MDSubrange::get(Context, 5, 7); EXPECT_EQ(dwarf::DW_TAG_subrange_type, N->getTag()); EXPECT_EQ(5, N->getCount()); - EXPECT_EQ(7, N->getLo()); + EXPECT_EQ(7, N->getLowerBound()); EXPECT_EQ(N, MDSubrange::get(Context, 5, 7)); EXPECT_EQ(MDSubrange::get(Context, 5, 0), MDSubrange::get(Context, 5)); @@ -780,7 +862,7 @@ 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(0, N->getLowerBound()); EXPECT_EQ(N, MDSubrange::get(Context, -1, 0)); } @@ -865,15 +947,15 @@ TEST_F(MDTypeTest, setFlags) { MDType *D = MDSubroutineType::getDistinct(Context, 0u, Types); EXPECT_EQ(0u, D->getFlags()); - D->setFlags(DIDescriptor::FlagRValueReference); - EXPECT_EQ(DIDescriptor::FlagRValueReference, D->getFlags()); + D->setFlags(DebugNode::FlagRValueReference); + EXPECT_EQ(DebugNode::FlagRValueReference, D->getFlags()); D->setFlags(0u); EXPECT_EQ(0u, D->getFlags()); TempMDType T = MDSubroutineType::getTemporary(Context, 0u, Types); EXPECT_EQ(0u, T->getFlags()); - T->setFlags(DIDescriptor::FlagRValueReference); - EXPECT_EQ(DIDescriptor::FlagRValueReference, T->getFlags()); + T->setFlags(DebugNode::FlagRValueReference); + EXPECT_EQ(DebugNode::FlagRValueReference, T->getFlags()); T->setFlags(0u); EXPECT_EQ(0u, T->getFlags()); } @@ -881,10 +963,10 @@ TEST_F(MDTypeTest, setFlags) { typedef MetadataTest MDDerivedTypeTest; TEST_F(MDDerivedTypeTest, get) { - Metadata *File = MDTuple::getDistinct(Context, None); - Metadata *Scope = MDTuple::getDistinct(Context, None); - Metadata *BaseType = MDTuple::getDistinct(Context, None); - Metadata *ExtraData = MDTuple::getDistinct(Context, None); + MDFile *File = getFile(); + MDScopeRef Scope = getSubprogramRef(); + MDTypeRef BaseType = getBasicType("basic"); + MDTuple *ExtraData = getTuple(); auto *N = MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something", File, 1, Scope, BaseType, 2, 3, 4, 5, ExtraData); @@ -910,17 +992,17 @@ TEST_F(MDDerivedTypeTest, get) { File, 1, Scope, BaseType, 2, 3, 4, 5, ExtraData)); EXPECT_NE(N, MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, - "something", Scope, 1, Scope, BaseType, 2, 3, - 4, 5, ExtraData)); + "something", getFile(), 1, Scope, BaseType, 2, + 3, 4, 5, ExtraData)); EXPECT_NE(N, MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something", File, 2, Scope, BaseType, 2, 3, 4, 5, ExtraData)); - EXPECT_NE(N, - MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something", - File, 1, File, BaseType, 2, 3, 4, 5, ExtraData)); - EXPECT_NE(N, - MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something", - File, 1, Scope, File, 2, 3, 4, 5, ExtraData)); + EXPECT_NE(N, MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, + "something", File, 1, getSubprogramRef(), + BaseType, 2, 3, 4, 5, ExtraData)); + EXPECT_NE(N, MDDerivedType::get( + Context, dwarf::DW_TAG_pointer_type, "something", File, 1, + Scope, getBasicType("basic2"), 2, 3, 4, 5, ExtraData)); EXPECT_NE(N, MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something", File, 1, Scope, BaseType, 3, 3, 4, 5, ExtraData)); @@ -933,19 +1015,19 @@ TEST_F(MDDerivedTypeTest, get) { EXPECT_NE(N, MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something", File, 1, Scope, BaseType, 2, 3, 4, 4, ExtraData)); - EXPECT_NE(N, - MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something", - File, 1, Scope, BaseType, 2, 3, 4, 5, File)); + EXPECT_NE(N, MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, + "something", File, 1, Scope, BaseType, 2, 3, + 4, 5, getTuple())); TempMDDerivedType Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); } TEST_F(MDDerivedTypeTest, getWithLargeValues) { - Metadata *File = MDTuple::getDistinct(Context, None); - Metadata *Scope = MDTuple::getDistinct(Context, None); - Metadata *BaseType = MDTuple::getDistinct(Context, None); - Metadata *ExtraData = MDTuple::getDistinct(Context, None); + MDFile *File = getFile(); + MDScopeRef Scope = getSubprogramRef(); + MDTypeRef BaseType = getBasicType("basic"); + MDTuple *ExtraData = getTuple(); auto *N = MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something", File, 1, Scope, BaseType, UINT64_MAX, @@ -960,18 +1042,18 @@ typedef MetadataTest MDCompositeTypeTest; TEST_F(MDCompositeTypeTest, get) { unsigned Tag = dwarf::DW_TAG_structure_type; StringRef Name = "some name"; - Metadata *File = MDTuple::getDistinct(Context, None); + MDFile *File = getFile(); unsigned Line = 1; - Metadata *Scope = MDTuple::getDistinct(Context, None); - Metadata *BaseType = MDTuple::getDistinct(Context, None); + MDScopeRef Scope = getSubprogramRef(); + MDTypeRef BaseType = getCompositeType(); uint64_t SizeInBits = 2; uint64_t AlignInBits = 3; uint64_t OffsetInBits = 4; unsigned Flags = 5; - Metadata *Elements = MDTuple::getDistinct(Context, None); + MDTuple *Elements = getTuple(); unsigned RuntimeLang = 6; - Metadata *VTableHolder = MDTuple::getDistinct(Context, None); - Metadata *TemplateParams = MDTuple::getDistinct(Context, None); + MDTypeRef VTableHolder = getCompositeType(); + MDTuple *TemplateParams = getTuple(); StringRef Identifier = "some id"; auto *N = MDCompositeType::get(Context, Tag, Name, File, Line, Scope, @@ -988,10 +1070,10 @@ TEST_F(MDCompositeTypeTest, get) { EXPECT_EQ(AlignInBits, N->getAlignInBits()); EXPECT_EQ(OffsetInBits, N->getOffsetInBits()); EXPECT_EQ(Flags, N->getFlags()); - EXPECT_EQ(Elements, N->getElements()); + EXPECT_EQ(Elements, N->getElements().get()); EXPECT_EQ(RuntimeLang, N->getRuntimeLang()); EXPECT_EQ(VTableHolder, N->getVTableHolder()); - EXPECT_EQ(TemplateParams, N->getTemplateParams()); + EXPECT_EQ(TemplateParams, N->getTemplateParams().get()); EXPECT_EQ(Identifier, N->getIdentifier()); EXPECT_EQ(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope, @@ -1007,7 +1089,7 @@ TEST_F(MDCompositeTypeTest, get) { BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams, Identifier)); - EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, Scope, Line, Scope, + EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, getFile(), Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams, Identifier)); @@ -1015,14 +1097,14 @@ TEST_F(MDCompositeTypeTest, get) { BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams, Identifier)); - EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, File, - BaseType, SizeInBits, AlignInBits, - OffsetInBits, Flags, Elements, RuntimeLang, - VTableHolder, TemplateParams, Identifier)); - EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope, File, - SizeInBits, AlignInBits, OffsetInBits, - Flags, Elements, RuntimeLang, VTableHolder, - TemplateParams, Identifier)); + EXPECT_NE(N, MDCompositeType::get( + Context, Tag, Name, File, Line, getSubprogramRef(), BaseType, + SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, + RuntimeLang, VTableHolder, TemplateParams, Identifier)); + EXPECT_NE(N, MDCompositeType::get( + Context, Tag, Name, File, Line, Scope, getBasicType("other"), + SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, + RuntimeLang, VTableHolder, TemplateParams, Identifier)); EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits + 1, AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, @@ -1039,22 +1121,22 @@ TEST_F(MDCompositeTypeTest, get) { Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags + 1, Elements, RuntimeLang, VTableHolder, TemplateParams, Identifier)); - EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope, - BaseType, SizeInBits, AlignInBits, - OffsetInBits, Flags, File, RuntimeLang, - VTableHolder, TemplateParams, Identifier)); + EXPECT_NE(N, MDCompositeType::get( + Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits, + AlignInBits, OffsetInBits, Flags, getTuple(), RuntimeLang, + VTableHolder, TemplateParams, Identifier)); EXPECT_NE(N, MDCompositeType::get( Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang + 1, VTableHolder, TemplateParams, Identifier)); + EXPECT_NE(N, MDCompositeType::get( + Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits, + AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, + getCompositeType(), TemplateParams, Identifier)); EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, - File, TemplateParams, Identifier)); - EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope, - BaseType, SizeInBits, AlignInBits, - OffsetInBits, Flags, Elements, RuntimeLang, - VTableHolder, File, Identifier)); + VTableHolder, getTuple(), Identifier)); EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, @@ -1077,18 +1159,18 @@ TEST_F(MDCompositeTypeTest, get) { TEST_F(MDCompositeTypeTest, getWithLargeValues) { unsigned Tag = dwarf::DW_TAG_structure_type; StringRef Name = "some name"; - Metadata *File = MDTuple::getDistinct(Context, None); + MDFile *File = getFile(); unsigned Line = 1; - Metadata *Scope = MDTuple::getDistinct(Context, None); - Metadata *BaseType = MDTuple::getDistinct(Context, None); + MDScopeRef Scope = getSubprogramRef(); + MDTypeRef BaseType = getCompositeType(); uint64_t SizeInBits = UINT64_MAX; uint64_t AlignInBits = UINT64_MAX - 1; uint64_t OffsetInBits = UINT64_MAX - 2; unsigned Flags = 5; - Metadata *Elements = MDTuple::getDistinct(Context, None); + MDTuple *Elements = getTuple(); unsigned RuntimeLang = 6; - Metadata *VTableHolder = MDTuple::getDistinct(Context, None); - Metadata *TemplateParams = MDTuple::getDistinct(Context, None); + MDTypeRef VTableHolder = getCompositeType(); + MDTuple *TemplateParams = getTuple(); StringRef Identifier = "some id"; auto *N = MDCompositeType::get(Context, Tag, Name, File, Line, Scope, @@ -1103,10 +1185,10 @@ TEST_F(MDCompositeTypeTest, getWithLargeValues) { TEST_F(MDCompositeTypeTest, replaceOperands) { unsigned Tag = dwarf::DW_TAG_structure_type; StringRef Name = "some name"; - Metadata *File = MDTuple::getDistinct(Context, None); + MDFile *File = getFile(); unsigned Line = 1; - Metadata *Scope = MDTuple::getDistinct(Context, None); - Metadata *BaseType = MDTuple::getDistinct(Context, None); + MDScopeRef Scope = getSubprogramRef(); + MDTypeRef BaseType = getCompositeType(); uint64_t SizeInBits = 2; uint64_t AlignInBits = 3; uint64_t OffsetInBits = 4; @@ -1120,13 +1202,13 @@ TEST_F(MDCompositeTypeTest, replaceOperands) { nullptr, nullptr, Identifier); auto *Elements = MDTuple::getDistinct(Context, None); - EXPECT_EQ(nullptr, N->getElements()); + EXPECT_EQ(nullptr, N->getElements().get()); N->replaceElements(Elements); - EXPECT_EQ(Elements, N->getElements()); + EXPECT_EQ(Elements, N->getElements().get()); N->replaceElements(nullptr); - EXPECT_EQ(nullptr, N->getElements()); + EXPECT_EQ(nullptr, N->getElements().get()); - auto *VTableHolder = MDTuple::getDistinct(Context, None); + MDTypeRef VTableHolder = getCompositeType(); EXPECT_EQ(nullptr, N->getVTableHolder()); N->replaceVTableHolder(VTableHolder); EXPECT_EQ(VTableHolder, N->getVTableHolder()); @@ -1134,28 +1216,27 @@ TEST_F(MDCompositeTypeTest, replaceOperands) { EXPECT_EQ(nullptr, N->getVTableHolder()); auto *TemplateParams = MDTuple::getDistinct(Context, None); - EXPECT_EQ(nullptr, N->getTemplateParams()); + EXPECT_EQ(nullptr, N->getTemplateParams().get()); N->replaceTemplateParams(TemplateParams); - EXPECT_EQ(TemplateParams, N->getTemplateParams()); + EXPECT_EQ(TemplateParams, N->getTemplateParams().get()); N->replaceTemplateParams(nullptr); - EXPECT_EQ(nullptr, N->getTemplateParams()); + EXPECT_EQ(nullptr, N->getTemplateParams().get()); } typedef MetadataTest MDSubroutineTypeTest; TEST_F(MDSubroutineTypeTest, get) { unsigned Flags = 1; - Metadata *TypeArray = MDTuple::getDistinct(Context, None); + MDTuple *TypeArray = getTuple(); auto *N = MDSubroutineType::get(Context, Flags, TypeArray); EXPECT_EQ(dwarf::DW_TAG_subroutine_type, N->getTag()); EXPECT_EQ(Flags, N->getFlags()); - EXPECT_EQ(TypeArray, N->getTypeArray()); + EXPECT_EQ(TypeArray, N->getTypeArray().get()); EXPECT_EQ(N, MDSubroutineType::get(Context, Flags, TypeArray)); EXPECT_NE(N, MDSubroutineType::get(Context, Flags + 1, TypeArray)); - EXPECT_NE(N, MDSubroutineType::get(Context, Flags, - MDTuple::getDistinct(Context, None))); + EXPECT_NE(N, MDSubroutineType::get(Context, Flags, getTuple())); TempMDSubroutineType Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -1166,7 +1247,7 @@ TEST_F(MDSubroutineTypeTest, get) { EXPECT_EQ("", N->getName()); EXPECT_EQ(nullptr, N->getBaseType()); EXPECT_EQ(nullptr, N->getVTableHolder()); - EXPECT_EQ(nullptr, N->getTemplateParams()); + EXPECT_EQ(nullptr, N->getTemplateParams().get()); EXPECT_EQ("", N->getIdentifier()); } @@ -1199,18 +1280,18 @@ typedef MetadataTest MDCompileUnitTest; TEST_F(MDCompileUnitTest, get) { unsigned SourceLanguage = 1; - Metadata *File = MDTuple::getDistinct(Context, None); + MDFile *File = getFile(); StringRef Producer = "some producer"; bool IsOptimized = false; StringRef Flags = "flag after flag"; unsigned RuntimeVersion = 2; StringRef SplitDebugFilename = "another/file"; unsigned EmissionKind = 3; - Metadata *EnumTypes = MDTuple::getDistinct(Context, None); - Metadata *RetainedTypes = MDTuple::getDistinct(Context, None); - Metadata *Subprograms = MDTuple::getDistinct(Context, None); - Metadata *GlobalVariables = MDTuple::getDistinct(Context, None); - Metadata *ImportedEntities = MDTuple::getDistinct(Context, None); + MDTuple *EnumTypes = getTuple(); + MDTuple *RetainedTypes = getTuple(); + MDTuple *Subprograms = getTuple(); + MDTuple *GlobalVariables = getTuple(); + MDTuple *ImportedEntities = getTuple(); auto *N = MDCompileUnit::get( Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, @@ -1225,11 +1306,11 @@ TEST_F(MDCompileUnitTest, get) { EXPECT_EQ(RuntimeVersion, N->getRuntimeVersion()); EXPECT_EQ(SplitDebugFilename, N->getSplitDebugFilename()); EXPECT_EQ(EmissionKind, N->getEmissionKind()); - EXPECT_EQ(EnumTypes, N->getEnumTypes()); - EXPECT_EQ(RetainedTypes, N->getRetainedTypes()); - EXPECT_EQ(Subprograms, N->getSubprograms()); - EXPECT_EQ(GlobalVariables, N->getGlobalVariables()); - EXPECT_EQ(ImportedEntities, N->getImportedEntities()); + EXPECT_EQ(EnumTypes, N->getEnumTypes().get()); + EXPECT_EQ(RetainedTypes, N->getRetainedTypes().get()); + EXPECT_EQ(Subprograms, N->getSubprograms().get()); + EXPECT_EQ(GlobalVariables, N->getGlobalVariables().get()); + EXPECT_EQ(ImportedEntities, N->getImportedEntities().get()); EXPECT_EQ(N, MDCompileUnit::get(Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, @@ -1241,7 +1322,7 @@ TEST_F(MDCompileUnitTest, get) { SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, Subprograms, GlobalVariables, ImportedEntities)); - EXPECT_NE(N, MDCompileUnit::get(Context, SourceLanguage, EnumTypes, Producer, + EXPECT_NE(N, MDCompileUnit::get(Context, SourceLanguage, getFile(), Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, Subprograms, GlobalVariables, @@ -1278,25 +1359,26 @@ TEST_F(MDCompileUnitTest, get) { GlobalVariables, ImportedEntities)); EXPECT_NE(N, MDCompileUnit::get(Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, - SplitDebugFilename, EmissionKind, File, + SplitDebugFilename, EmissionKind, getTuple(), RetainedTypes, Subprograms, GlobalVariables, ImportedEntities)); EXPECT_NE(N, MDCompileUnit::get( Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, - File, Subprograms, GlobalVariables, ImportedEntities)); - EXPECT_NE(N, MDCompileUnit::get( - Context, SourceLanguage, File, Producer, IsOptimized, Flags, - RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, - RetainedTypes, File, GlobalVariables, ImportedEntities)); + getTuple(), Subprograms, GlobalVariables, ImportedEntities)); + EXPECT_NE(N, MDCompileUnit::get(Context, SourceLanguage, File, Producer, + IsOptimized, Flags, RuntimeVersion, + SplitDebugFilename, EmissionKind, EnumTypes, + RetainedTypes, getTuple(), GlobalVariables, + ImportedEntities)); EXPECT_NE(N, MDCompileUnit::get( Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, - RetainedTypes, Subprograms, File, ImportedEntities)); + RetainedTypes, Subprograms, getTuple(), ImportedEntities)); EXPECT_NE(N, MDCompileUnit::get( Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, - RetainedTypes, Subprograms, GlobalVariables, File)); + RetainedTypes, Subprograms, GlobalVariables, getTuple())); TempMDCompileUnit Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -1304,57 +1386,57 @@ TEST_F(MDCompileUnitTest, get) { TEST_F(MDCompileUnitTest, replaceArrays) { unsigned SourceLanguage = 1; - Metadata *File = MDTuple::getDistinct(Context, None); + MDFile *File = getFile(); StringRef Producer = "some producer"; bool IsOptimized = false; StringRef Flags = "flag after flag"; unsigned RuntimeVersion = 2; StringRef SplitDebugFilename = "another/file"; unsigned EmissionKind = 3; - Metadata *EnumTypes = MDTuple::getDistinct(Context, None); - Metadata *RetainedTypes = MDTuple::getDistinct(Context, None); - Metadata *ImportedEntities = MDTuple::getDistinct(Context, None); + MDTuple *EnumTypes = MDTuple::getDistinct(Context, None); + MDTuple *RetainedTypes = MDTuple::getDistinct(Context, None); + MDTuple *ImportedEntities = MDTuple::getDistinct(Context, None); auto *N = MDCompileUnit::get( Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, nullptr, nullptr, ImportedEntities); auto *Subprograms = MDTuple::getDistinct(Context, None); - EXPECT_EQ(nullptr, N->getSubprograms()); + EXPECT_EQ(nullptr, N->getSubprograms().get()); N->replaceSubprograms(Subprograms); - EXPECT_EQ(Subprograms, N->getSubprograms()); + EXPECT_EQ(Subprograms, N->getSubprograms().get()); N->replaceSubprograms(nullptr); - EXPECT_EQ(nullptr, N->getSubprograms()); + EXPECT_EQ(nullptr, N->getSubprograms().get()); auto *GlobalVariables = MDTuple::getDistinct(Context, None); - EXPECT_EQ(nullptr, N->getGlobalVariables()); + EXPECT_EQ(nullptr, N->getGlobalVariables().get()); N->replaceGlobalVariables(GlobalVariables); - EXPECT_EQ(GlobalVariables, N->getGlobalVariables()); + EXPECT_EQ(GlobalVariables, N->getGlobalVariables().get()); N->replaceGlobalVariables(nullptr); - EXPECT_EQ(nullptr, N->getGlobalVariables()); + EXPECT_EQ(nullptr, N->getGlobalVariables().get()); } typedef MetadataTest MDSubprogramTest; TEST_F(MDSubprogramTest, get) { - Metadata *Scope = MDTuple::getDistinct(Context, None); + MDScopeRef Scope = getCompositeType(); StringRef Name = "name"; StringRef LinkageName = "linkage"; - Metadata *File = MDTuple::getDistinct(Context, None); + MDFile *File = getFile(); unsigned Line = 2; - Metadata *Type = MDTuple::getDistinct(Context, None); + MDSubroutineType *Type = getSubroutineType(); bool IsLocalToUnit = false; bool IsDefinition = true; unsigned ScopeLine = 3; - Metadata *ContainingType = MDTuple::getDistinct(Context, None); + MDTypeRef ContainingType = getCompositeType(); unsigned Virtuality = 4; unsigned VirtualIndex = 5; unsigned Flags = 6; bool IsOptimized = false; - Metadata *Function = MDTuple::getDistinct(Context, None); - Metadata *TemplateParams = MDTuple::getDistinct(Context, None); - Metadata *Declaration = MDTuple::getDistinct(Context, None); - Metadata *Variables = MDTuple::getDistinct(Context, None); + llvm::Function *Function = getFunction("foo"); + MDTuple *TemplateParams = getTuple(); + MDSubprogram *Declaration = getSubprogram(); + MDTuple *Variables = getTuple(); auto *N = MDSubprogram::get( Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, @@ -1377,20 +1459,20 @@ TEST_F(MDSubprogramTest, get) { EXPECT_EQ(Flags, N->getFlags()); EXPECT_EQ(IsOptimized, N->isOptimized()); EXPECT_EQ(Function, N->getFunction()); - EXPECT_EQ(TemplateParams, N->getTemplateParams()); + EXPECT_EQ(TemplateParams, N->getTemplateParams().get()); EXPECT_EQ(Declaration, N->getDeclaration()); - EXPECT_EQ(Variables, N->getVariables()); + EXPECT_EQ(Variables, N->getVariables().get()); EXPECT_EQ(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, ScopeLine, ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized, Function, TemplateParams, Declaration, Variables)); - EXPECT_NE(N, MDSubprogram::get(Context, File, Name, LinkageName, File, Line, - Type, IsLocalToUnit, IsDefinition, ScopeLine, - ContainingType, Virtuality, VirtualIndex, - Flags, IsOptimized, Function, TemplateParams, - Declaration, Variables)); + EXPECT_NE(N, MDSubprogram::get(Context, getCompositeType(), Name, LinkageName, + File, Line, Type, IsLocalToUnit, IsDefinition, + ScopeLine, ContainingType, Virtuality, + VirtualIndex, Flags, IsOptimized, Function, + TemplateParams, Declaration, Variables)); EXPECT_NE(N, MDSubprogram::get(Context, Scope, "other", LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, ScopeLine, ContainingType, Virtuality, @@ -1401,21 +1483,21 @@ TEST_F(MDSubprogramTest, get) { ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized, Function, TemplateParams, Declaration, Variables)); - EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, Scope, Line, - Type, IsLocalToUnit, IsDefinition, ScopeLine, - ContainingType, Virtuality, VirtualIndex, - Flags, IsOptimized, Function, TemplateParams, - Declaration, Variables)); + EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, getFile(), + Line, Type, IsLocalToUnit, IsDefinition, + ScopeLine, ContainingType, Virtuality, + VirtualIndex, Flags, IsOptimized, Function, + TemplateParams, Declaration, Variables)); EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line + 1, Type, IsLocalToUnit, IsDefinition, ScopeLine, ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized, Function, TemplateParams, Declaration, Variables)); - EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line, - Scope, IsLocalToUnit, IsDefinition, ScopeLine, - ContainingType, Virtuality, VirtualIndex, - Flags, IsOptimized, Function, TemplateParams, - Declaration, Variables)); + EXPECT_NE(N, MDSubprogram::get( + Context, Scope, Name, LinkageName, File, Line, + getSubroutineType(), IsLocalToUnit, IsDefinition, ScopeLine, + ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized, + Function, TemplateParams, Declaration, Variables)); EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line, Type, !IsLocalToUnit, IsDefinition, ScopeLine, ContainingType, Virtuality, VirtualIndex, @@ -1433,8 +1515,8 @@ TEST_F(MDSubprogramTest, get) { TemplateParams, Declaration, Variables)); EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, ScopeLine, - Type, Virtuality, VirtualIndex, Flags, - IsOptimized, Function, TemplateParams, + getCompositeType(), Virtuality, VirtualIndex, + Flags, IsOptimized, Function, TemplateParams, Declaration, Variables)); EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, ScopeLine, @@ -1459,46 +1541,46 @@ TEST_F(MDSubprogramTest, get) { EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, ScopeLine, ContainingType, Virtuality, VirtualIndex, - Flags, IsOptimized, Type, TemplateParams, - Declaration, Variables)); + Flags, IsOptimized, getFunction("bar"), + TemplateParams, Declaration, Variables)); EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, ScopeLine, ContainingType, Virtuality, VirtualIndex, - Flags, IsOptimized, Function, Type, + Flags, IsOptimized, Function, getTuple(), Declaration, Variables)); EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, ScopeLine, ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized, Function, TemplateParams, - Type, Variables)); + getSubprogram(), Variables)); EXPECT_NE(N, MDSubprogram::get(Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, ScopeLine, ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized, Function, TemplateParams, - Declaration, Type)); + Declaration, getTuple())); TempMDSubprogram Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); } TEST_F(MDSubprogramTest, replaceFunction) { - Metadata *Scope = MDTuple::getDistinct(Context, None); + MDScopeRef Scope = getCompositeType(); StringRef Name = "name"; StringRef LinkageName = "linkage"; - Metadata *File = MDTuple::getDistinct(Context, None); + MDFile *File = getFile(); unsigned Line = 2; - Metadata *Type = MDTuple::getDistinct(Context, None); + MDSubroutineType *Type = getSubroutineType(); bool IsLocalToUnit = false; bool IsDefinition = true; unsigned ScopeLine = 3; - Metadata *ContainingType = MDTuple::getDistinct(Context, None); + MDTypeRef ContainingType = getCompositeType(); unsigned Virtuality = 4; unsigned VirtualIndex = 5; unsigned Flags = 6; bool IsOptimized = false; - Metadata *TemplateParams = MDTuple::getDistinct(Context, None); - Metadata *Declaration = MDTuple::getDistinct(Context, None); - Metadata *Variables = MDTuple::getDistinct(Context, None); + MDTuple *TemplateParams = getTuple(); + MDSubprogram *Declaration = getSubprogram(); + MDTuple *Variables = getTuple(); auto *N = MDSubprogram::get( Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, @@ -1511,7 +1593,7 @@ TEST_F(MDSubprogramTest, replaceFunction) { Function::Create(FunctionType::get(Type::getVoidTy(Context), false), GlobalValue::ExternalLinkage)); N->replaceFunction(F.get()); - EXPECT_EQ(ConstantAsMetadata::get(F.get()), N->getFunction()); + EXPECT_EQ(F.get(), N->getFunction()); N->replaceFunction(nullptr); EXPECT_EQ(nullptr, N->getFunction()); @@ -1520,8 +1602,8 @@ TEST_F(MDSubprogramTest, replaceFunction) { typedef MetadataTest MDLexicalBlockTest; TEST_F(MDLexicalBlockTest, get) { - Metadata *Scope = MDTuple::getDistinct(Context, None); - Metadata *File = MDTuple::getDistinct(Context, None); + MDLocalScope *Scope = getSubprogram(); + MDFile *File = getFile(); unsigned Line = 5; unsigned Column = 8; @@ -1534,8 +1616,9 @@ TEST_F(MDLexicalBlockTest, get) { EXPECT_EQ(Column, N->getColumn()); EXPECT_EQ(N, MDLexicalBlock::get(Context, Scope, File, Line, Column)); - EXPECT_NE(N, MDLexicalBlock::get(Context, File, File, Line, Column)); - EXPECT_NE(N, MDLexicalBlock::get(Context, Scope, Scope, Line, Column)); + EXPECT_NE(N, + MDLexicalBlock::get(Context, getSubprogram(), File, Line, Column)); + EXPECT_NE(N, MDLexicalBlock::get(Context, Scope, getFile(), Line, Column)); EXPECT_NE(N, MDLexicalBlock::get(Context, Scope, File, Line + 1, Column)); EXPECT_NE(N, MDLexicalBlock::get(Context, Scope, File, Line, Column + 1)); @@ -1546,8 +1629,8 @@ TEST_F(MDLexicalBlockTest, get) { typedef MetadataTest MDLexicalBlockFileTest; TEST_F(MDLexicalBlockFileTest, get) { - Metadata *Scope = MDTuple::getDistinct(Context, None); - Metadata *File = MDTuple::getDistinct(Context, None); + MDLocalScope *Scope = getSubprogram(); + MDFile *File = getFile(); unsigned Discriminator = 5; auto *N = MDLexicalBlockFile::get(Context, Scope, File, Discriminator); @@ -1558,8 +1641,10 @@ TEST_F(MDLexicalBlockFileTest, get) { EXPECT_EQ(Discriminator, N->getDiscriminator()); EXPECT_EQ(N, MDLexicalBlockFile::get(Context, Scope, File, Discriminator)); - EXPECT_NE(N, MDLexicalBlockFile::get(Context, File, File, Discriminator)); - EXPECT_NE(N, MDLexicalBlockFile::get(Context, Scope, Scope, Discriminator)); + EXPECT_NE(N, MDLexicalBlockFile::get(Context, getSubprogram(), File, + Discriminator)); + EXPECT_NE(N, + MDLexicalBlockFile::get(Context, Scope, getFile(), Discriminator)); EXPECT_NE(N, MDLexicalBlockFile::get(Context, Scope, File, Discriminator + 1)); @@ -1570,8 +1655,8 @@ TEST_F(MDLexicalBlockFileTest, get) { typedef MetadataTest MDNamespaceTest; TEST_F(MDNamespaceTest, get) { - Metadata *Scope = MDTuple::getDistinct(Context, None); - Metadata *File = MDTuple::getDistinct(Context, None); + MDScope *Scope = getFile(); + MDFile *File = getFile(); StringRef Name = "namespace"; unsigned Line = 5; @@ -1584,8 +1669,8 @@ TEST_F(MDNamespaceTest, get) { EXPECT_EQ(Line, N->getLine()); EXPECT_EQ(N, MDNamespace::get(Context, Scope, File, Name, Line)); - EXPECT_NE(N, MDNamespace::get(Context, File, File, Name, Line)); - EXPECT_NE(N, MDNamespace::get(Context, Scope, Scope, Name, Line)); + EXPECT_NE(N, MDNamespace::get(Context, getFile(), File, Name, Line)); + EXPECT_NE(N, MDNamespace::get(Context, Scope, getFile(), Name, Line)); EXPECT_NE(N, MDNamespace::get(Context, Scope, File, "other", Line)); EXPECT_NE(N, MDNamespace::get(Context, Scope, File, Name, Line + 1)); @@ -1597,8 +1682,7 @@ typedef MetadataTest MDTemplateTypeParameterTest; TEST_F(MDTemplateTypeParameterTest, get) { StringRef Name = "template"; - Metadata *Type = MDTuple::getDistinct(Context, None); - Metadata *Other = MDTuple::getDistinct(Context, None); + MDTypeRef Type = getBasicType("basic"); auto *N = MDTemplateTypeParameter::get(Context, Name, Type); @@ -1608,7 +1692,8 @@ TEST_F(MDTemplateTypeParameterTest, get) { EXPECT_EQ(N, MDTemplateTypeParameter::get(Context, Name, Type)); EXPECT_NE(N, MDTemplateTypeParameter::get(Context, "other", Type)); - EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Name, Other)); + EXPECT_NE(N, + MDTemplateTypeParameter::get(Context, Name, getBasicType("other"))); TempMDTemplateTypeParameter Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -1619,9 +1704,8 @@ typedef MetadataTest MDTemplateValueParameterTest; TEST_F(MDTemplateValueParameterTest, get) { unsigned Tag = dwarf::DW_TAG_template_value_parameter; StringRef Name = "template"; - Metadata *Type = MDTuple::getDistinct(Context, None); - Metadata *Value = MDTuple::getDistinct(Context, None); - Metadata *Other = MDTuple::getDistinct(Context, None); + MDTypeRef Type = getBasicType("basic"); + Metadata *Value = getConstantAsMetadata(); auto *N = MDTemplateValueParameter::get(Context, Tag, Name, Type, Value); EXPECT_EQ(Tag, N->getTag()); @@ -1635,9 +1719,10 @@ TEST_F(MDTemplateValueParameterTest, get) { Type, Value)); EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, "other", Type, Value)); - EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Name, Other, - Value)); - EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Name, Type, Other)); + EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Name, + getBasicType("other"), Value)); + EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Name, Type, + getConstantAsMetadata())); TempMDTemplateValueParameter Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -1646,16 +1731,17 @@ TEST_F(MDTemplateValueParameterTest, get) { typedef MetadataTest MDGlobalVariableTest; TEST_F(MDGlobalVariableTest, get) { - Metadata *Scope = MDTuple::getDistinct(Context, None); + MDScope *Scope = getSubprogram(); StringRef Name = "name"; StringRef LinkageName = "linkage"; - Metadata *File = MDTuple::getDistinct(Context, None); + MDFile *File = getFile(); unsigned Line = 5; - Metadata *Type = MDTuple::getDistinct(Context, None); + MDTypeRef Type = getDerivedType(); bool IsLocalToUnit = false; bool IsDefinition = true; - Metadata *Variable = MDTuple::getDistinct(Context, None); - Metadata *StaticDataMemberDeclaration = MDTuple::getDistinct(Context, None); + Constant *Variable = getConstant(); + MDDerivedType *StaticDataMemberDeclaration = + cast<MDDerivedType>(getDerivedType()); auto *N = MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, Variable, @@ -1675,37 +1761,42 @@ TEST_F(MDGlobalVariableTest, get) { Line, Type, IsLocalToUnit, IsDefinition, Variable, StaticDataMemberDeclaration)); - EXPECT_NE(N, MDGlobalVariable::get(Context, File, Name, LinkageName, File, - Line, Type, IsLocalToUnit, IsDefinition, - Variable, StaticDataMemberDeclaration)); + EXPECT_NE(N, + MDGlobalVariable::get(Context, getSubprogram(), Name, LinkageName, + File, Line, Type, IsLocalToUnit, IsDefinition, + Variable, StaticDataMemberDeclaration)); EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, "other", LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, Variable, StaticDataMemberDeclaration)); EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, "other", File, Line, Type, IsLocalToUnit, IsDefinition, Variable, StaticDataMemberDeclaration)); - EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, Scope, - Line, Type, IsLocalToUnit, IsDefinition, - Variable, StaticDataMemberDeclaration)); + EXPECT_NE(N, + MDGlobalVariable::get(Context, Scope, Name, LinkageName, getFile(), + Line, Type, IsLocalToUnit, IsDefinition, + Variable, StaticDataMemberDeclaration)); EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line + 1, Type, IsLocalToUnit, IsDefinition, Variable, StaticDataMemberDeclaration)); - EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, - Line, Scope, IsLocalToUnit, IsDefinition, - Variable, StaticDataMemberDeclaration)); + EXPECT_NE(N, + MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line, + getDerivedType(), IsLocalToUnit, IsDefinition, + Variable, StaticDataMemberDeclaration)); EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line, Type, !IsLocalToUnit, IsDefinition, Variable, StaticDataMemberDeclaration)); EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, !IsDefinition, Variable, StaticDataMemberDeclaration)); - EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, - Line, Type, IsLocalToUnit, IsDefinition, - Type, StaticDataMemberDeclaration)); - EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, - Line, Type, IsLocalToUnit, IsDefinition, - Variable, Type)); + EXPECT_NE(N, + MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line, + Type, IsLocalToUnit, IsDefinition, + getConstant(), StaticDataMemberDeclaration)); + EXPECT_NE(N, + MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line, + Type, IsLocalToUnit, IsDefinition, Variable, + cast<MDDerivedType>(getDerivedType()))); TempMDGlobalVariable Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -1715,19 +1806,16 @@ typedef MetadataTest MDLocalVariableTest; TEST_F(MDLocalVariableTest, get) { unsigned Tag = dwarf::DW_TAG_arg_variable; - Metadata *Scope = MDTuple::getDistinct(Context, None); + MDLocalScope *Scope = getSubprogram(); StringRef Name = "name"; - Metadata *File = MDTuple::getDistinct(Context, None); + MDFile *File = getFile(); unsigned Line = 5; - Metadata *Type = MDTuple::getDistinct(Context, None); + MDTypeRef Type = getDerivedType(); unsigned Arg = 6; unsigned Flags = 7; - Metadata *InlinedAtScope = MDTuple::getDistinct(Context, None); - Metadata *InlinedAt = - MDLocation::getDistinct(Context, 10, 20, InlinedAtScope); auto *N = MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type, - Arg, Flags, InlinedAt); + Arg, Flags); EXPECT_EQ(Tag, N->getTag()); EXPECT_EQ(Scope, N->getScope()); EXPECT_EQ(Name, N->getName()); @@ -1736,45 +1824,28 @@ TEST_F(MDLocalVariableTest, get) { EXPECT_EQ(Type, N->getType()); EXPECT_EQ(Arg, N->getArg()); EXPECT_EQ(Flags, N->getFlags()); - EXPECT_EQ(InlinedAt, N->getInlinedAt()); EXPECT_EQ(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type, - Arg, Flags, InlinedAt)); + Arg, Flags)); EXPECT_NE(N, MDLocalVariable::get(Context, dwarf::DW_TAG_auto_variable, Scope, - Name, File, Line, Type, Arg, Flags, - InlinedAt)); - EXPECT_NE(N, MDLocalVariable::get(Context, Tag, File, Name, File, Line, - Type, Arg, Flags, InlinedAt)); + Name, File, Line, Type, Arg, Flags)); + EXPECT_NE(N, MDLocalVariable::get(Context, Tag, getSubprogram(), Name, File, + Line, Type, Arg, Flags)); EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, "other", File, Line, - Type, Arg, Flags, InlinedAt)); - EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, Scope, Line, - Type, Arg, Flags, InlinedAt)); + Type, Arg, Flags)); + EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, getFile(), Line, + Type, Arg, Flags)); EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line + 1, - Type, Arg, Flags, InlinedAt)); + Type, Arg, Flags)); EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, - Scope, Arg, Flags, InlinedAt)); - EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type, - Arg + 1, Flags, InlinedAt)); + getDerivedType(), Arg, Flags)); EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type, - Arg, ~Flags, InlinedAt)); + Arg + 1, Flags)); EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type, - Arg, Flags, Scope)); + Arg, ~Flags)); TempMDLocalVariable Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); - - auto *Inlined = N->withoutInline(); - EXPECT_NE(N, Inlined); - EXPECT_EQ(N->getTag(), Inlined->getTag()); - EXPECT_EQ(N->getScope(), Inlined->getScope()); - EXPECT_EQ(N->getName(), Inlined->getName()); - EXPECT_EQ(N->getFile(), Inlined->getFile()); - EXPECT_EQ(N->getLine(), Inlined->getLine()); - EXPECT_EQ(N->getType(), Inlined->getType()); - EXPECT_EQ(N->getArg(), Inlined->getArg()); - EXPECT_EQ(N->getFlags(), Inlined->getFlags()); - EXPECT_EQ(nullptr, Inlined->getInlinedAt()); - EXPECT_EQ(N, Inlined->withInline(cast<MDLocation>(InlinedAt))); } typedef MetadataTest MDExpressionTest; @@ -1836,12 +1907,12 @@ typedef MetadataTest MDObjCPropertyTest; TEST_F(MDObjCPropertyTest, get) { StringRef Name = "name"; - Metadata *File = MDTuple::getDistinct(Context, None); + MDFile *File = getFile(); unsigned Line = 5; StringRef GetterName = "getter"; StringRef SetterName = "setter"; unsigned Attributes = 7; - Metadata *Type = MDTuple::getDistinct(Context, None); + MDType *Type = cast<MDBasicType>(getBasicType("basic")); auto *N = MDObjCProperty::get(Context, Name, File, Line, GetterName, SetterName, Attributes, Type); @@ -1859,7 +1930,7 @@ TEST_F(MDObjCPropertyTest, get) { EXPECT_NE(N, MDObjCProperty::get(Context, "other", File, Line, GetterName, SetterName, Attributes, Type)); - EXPECT_NE(N, MDObjCProperty::get(Context, Name, Type, Line, GetterName, + EXPECT_NE(N, MDObjCProperty::get(Context, Name, getFile(), Line, GetterName, SetterName, Attributes, Type)); EXPECT_NE(N, MDObjCProperty::get(Context, Name, File, Line + 1, GetterName, SetterName, Attributes, Type)); @@ -1870,7 +1941,8 @@ TEST_F(MDObjCPropertyTest, get) { EXPECT_NE(N, MDObjCProperty::get(Context, Name, File, Line, GetterName, SetterName, Attributes + 1, Type)); EXPECT_NE(N, MDObjCProperty::get(Context, Name, File, Line, GetterName, - SetterName, Attributes, File)); + SetterName, Attributes, + cast<MDBasicType>(getBasicType("other")))); TempMDObjCProperty Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -1880,8 +1952,8 @@ typedef MetadataTest MDImportedEntityTest; TEST_F(MDImportedEntityTest, get) { unsigned Tag = dwarf::DW_TAG_imported_module; - Metadata *Scope = MDTuple::getDistinct(Context, None); - Metadata *Entity = MDTuple::getDistinct(Context, None); + MDScope *Scope = getSubprogram(); + DebugNodeRef Entity = getCompositeType(); unsigned Line = 5; StringRef Name = "name"; @@ -1897,8 +1969,10 @@ TEST_F(MDImportedEntityTest, get) { EXPECT_NE(N, MDImportedEntity::get(Context, dwarf::DW_TAG_imported_declaration, Scope, Entity, Line, Name)); - EXPECT_NE(N, MDImportedEntity::get(Context, Tag, Entity, Entity, Line, Name)); - EXPECT_NE(N, MDImportedEntity::get(Context, Tag, Scope, Scope, Line, Name)); + EXPECT_NE(N, MDImportedEntity::get(Context, Tag, getSubprogram(), Entity, + Line, Name)); + EXPECT_NE(N, MDImportedEntity::get(Context, Tag, Scope, getCompositeType(), + Line, Name)); EXPECT_NE(N, MDImportedEntity::get(Context, Tag, Scope, Entity, Line + 1, Name)); EXPECT_NE(N, diff --git a/unittests/IR/ValueHandleTest.cpp b/unittests/IR/ValueHandleTest.cpp index 403d2bc..6000c4a 100644 --- a/unittests/IR/ValueHandleTest.cpp +++ b/unittests/IR/ValueHandleTest.cpp @@ -244,8 +244,11 @@ TEST_F(ValueHandle, CallbackVH_CallbackOnDeletion) { RecordingVH(Value *V) : CallbackVH(V), DeletedCalls(0), AURWCalls(0) {} private: - virtual void deleted() { DeletedCalls++; CallbackVH::deleted(); } - virtual void allUsesReplacedWith(Value *) { AURWCalls++; } + void deleted() override { + DeletedCalls++; + CallbackVH::deleted(); + } + void allUsesReplacedWith(Value *) override { AURWCalls++; } }; RecordingVH RVH; @@ -268,8 +271,11 @@ TEST_F(ValueHandle, CallbackVH_CallbackOnRAUW) { : CallbackVH(V), DeletedCalls(0), AURWArgument(nullptr) {} private: - virtual void deleted() { DeletedCalls++; CallbackVH::deleted(); } - virtual void allUsesReplacedWith(Value *new_value) { + void deleted() override { + DeletedCalls++; + CallbackVH::deleted(); + } + void allUsesReplacedWith(Value *new_value) override { EXPECT_EQ(nullptr, AURWArgument); AURWArgument = new_value; } @@ -298,11 +304,11 @@ TEST_F(ValueHandle, CallbackVH_DeletionCanRAUW) { Context(&getGlobalContext()) {} private: - virtual void deleted() { + void deleted() override { getValPtr()->replaceAllUsesWith(Constant::getNullValue(Type::getInt32Ty(getGlobalContext()))); setValPtr(nullptr); } - virtual void allUsesReplacedWith(Value *new_value) { + void allUsesReplacedWith(Value *new_value) override { ASSERT_TRUE(nullptr != getValPtr()); EXPECT_EQ(1U, getValPtr()->getNumUses()); EXPECT_EQ(nullptr, AURWArgument); @@ -341,12 +347,12 @@ TEST_F(ValueHandle, DestroyingOtherVHOnSameValueDoesntBreakIteration) { setValPtr(V); ToClear[1].reset(new WeakVH(V)); } - virtual void deleted() { + void deleted() override { ToClear[0].reset(); ToClear[1].reset(); CallbackVH::deleted(); } - virtual void allUsesReplacedWith(Value *) { + void allUsesReplacedWith(Value *) override { ToClear[0].reset(); ToClear[1].reset(); } @@ -388,7 +394,7 @@ TEST_F(ValueHandle, AssertingVHCheckedLast) { ToClear[1] = &A1; } - virtual void deleted() { + void deleted() override { *ToClear[0] = nullptr; *ToClear[1] = nullptr; CallbackVH::deleted(); diff --git a/unittests/IR/ValueMapTest.cpp b/unittests/IR/ValueMapTest.cpp index a6bad71..1431a8d 100644 --- a/unittests/IR/ValueMapTest.cpp +++ b/unittests/IR/ValueMapTest.cpp @@ -194,7 +194,8 @@ struct LockMutex : ValueMapConfig<KeyT, MutexT> { } static MutexT *getMutex(const ExtraData &Data) { return Data.M; } }; -#if LLVM_ENABLE_THREADS +// FIXME: These tests started failing on Windows. +#if LLVM_ENABLE_THREADS && !defined(LLVM_ON_WIN32) TYPED_TEST(ValueMapTest, LocksMutex) { sys::Mutex M(false); // Not recursive. bool CalledRAUW = false, CalledDeleted = false; |