diff options
Diffstat (limited to 'llvm/unittests/CodeGen/LexicalScopesTest.cpp')
| -rw-r--r-- | llvm/unittests/CodeGen/LexicalScopesTest.cpp | 43 |
1 files changed, 11 insertions, 32 deletions
diff --git a/llvm/unittests/CodeGen/LexicalScopesTest.cpp b/llvm/unittests/CodeGen/LexicalScopesTest.cpp index 34bd37a4afdc..563d496d1e60 100644 --- a/llvm/unittests/CodeGen/LexicalScopesTest.cpp +++ b/llvm/unittests/CodeGen/LexicalScopesTest.cpp @@ -44,7 +44,6 @@ public: std::unique_ptr<MachineFunction> MF; DICompileUnit *OurCU; DIFile *OurFile; - DISubroutineType *OurSubT; DISubprogram *OurFunc; DILexicalBlock *OurBlock, *AnotherBlock; DISubprogram *ToInlineFunc; @@ -104,7 +103,7 @@ public: OurFile = DIB.createFile("xyzzy.c", "/cave"); OurCU = DIB.createCompileUnit(dwarf::DW_LANG_C99, OurFile, "nou", false, "", 0); - OurSubT = DIB.createSubroutineType(DIB.getOrCreateTypeArray({})); + auto OurSubT = DIB.createSubroutineType(DIB.getOrCreateTypeArray({})); OurFunc = DIB.createFunction(OurCU, "bees", "", OurFile, 1, OurSubT, 1, DINode::FlagZero, DISubprogram::SPFlagDefinition); @@ -137,10 +136,10 @@ TEST_F(LexicalScopesTest, FlatLayout) { LexicalScopes LS; EXPECT_TRUE(LS.empty()); - LS.resetFunction(); + LS.reset(); EXPECT_EQ(LS.getCurrentFunctionScope(), nullptr); - LS.scanFunction(*MF); + LS.initialize(*MF); EXPECT_FALSE(LS.empty()); LexicalScope *FuncScope = LS.getCurrentFunctionScope(); EXPECT_EQ(FuncScope->getParent(), nullptr); @@ -183,7 +182,7 @@ TEST_F(LexicalScopesTest, BlockScopes) { BuildMI(*MBB4, MBB4->end(), InBlockLoc, BeanInst); LexicalScopes LS; - LS.scanFunction(*MF); + LS.initialize(*MF); LexicalScope *FuncScope = LS.getCurrentFunctionScope(); EXPECT_EQ(FuncScope->getDesc(), OurFunc); auto &Children = FuncScope->getChildren(); @@ -218,7 +217,7 @@ TEST_F(LexicalScopesTest, InlinedScopes) { BuildMI(*MBB4, MBB4->end(), InlinedLoc, BeanInst); LexicalScopes LS; - LS.scanFunction(*MF); + LS.initialize(*MF); LexicalScope *FuncScope = LS.getCurrentFunctionScope(); auto &Children = FuncScope->getChildren(); ASSERT_EQ(Children.size(), 1u); @@ -253,7 +252,7 @@ TEST_F(LexicalScopesTest, FuncWithEmptyGap) { BuildMI(*MBB4, MBB4->end(), OutermostLoc, BeanInst); LexicalScopes LS; - LS.scanFunction(*MF); + LS.initialize(*MF); LexicalScope *FuncScope = LS.getCurrentFunctionScope(); // A gap in a range that contains no other location, is not actually a @@ -274,7 +273,7 @@ TEST_F(LexicalScopesTest, FuncWithRealGap) { MachineInstr *LastI = BuildMI(*MBB4, MBB4->end(), InBlockLoc, BeanInst); LexicalScopes LS; - LS.scanFunction(*MF); + LS.initialize(*MF); LexicalScope *BlockScope = LS.findLexicalScope(InBlockLoc.get()); ASSERT_NE(BlockScope, nullptr); @@ -307,7 +306,7 @@ TEST_F(LexicalScopesTest, NotNested) { MachineInstr *FourthI = BuildMI(*MBB4, MBB4->end(), InBlockLoc, BeanInst); LexicalScopes LS; - LS.scanFunction(*MF); + LS.initialize(*MF); LexicalScope *FuncScope = LS.getCurrentFunctionScope(); LexicalScope *BlockScope = LS.findLexicalScope(InBlockLoc.get()); LexicalScope *OtherBlockScope = LS.findLexicalScope(NotNestedBlockLoc.get()); @@ -345,7 +344,7 @@ TEST_F(LexicalScopesTest, TestDominates) { BuildMI(*MBB4, MBB4->end(), InBlockLoc, BeanInst); LexicalScopes LS; - LS.scanFunction(*MF); + LS.initialize(*MF); LexicalScope *FuncScope = LS.getCurrentFunctionScope(); LexicalScope *BlockScope = LS.findLexicalScope(InBlockLoc.get()); LexicalScope *OtherBlockScope = LS.findLexicalScope(NotNestedBlockLoc.get()); @@ -387,7 +386,7 @@ TEST_F(LexicalScopesTest, TestGetBlocks) { BuildMI(*MBB4, MBB4->end(), InBlockLoc, BeanInst); LexicalScopes LS; - LS.scanFunction(*MF); + LS.initialize(*MF); LexicalScope *FuncScope = LS.getCurrentFunctionScope(); LexicalScope *BlockScope = LS.findLexicalScope(InBlockLoc.get()); LexicalScope *OtherBlockScope = LS.findLexicalScope(NotNestedBlockLoc.get()); @@ -444,7 +443,7 @@ TEST_F(LexicalScopesTest, TestMetaInst) { BuildMI(*MBB4, MBB4->end(), InBlockLoc, BeanInst); LexicalScopes LS; - LS.scanFunction(*MF); + LS.initialize(*MF); LexicalScope *FuncScope = LS.getCurrentFunctionScope(); LexicalScope *BlockScope = LS.findLexicalScope(InBlockLoc.get()); ASSERT_NE(FuncScope, nullptr); @@ -460,24 +459,4 @@ TEST_F(LexicalScopesTest, TestMetaInst) { EXPECT_TRUE(LS.dominates(InBlockLoc.get(), MBB4)); } -// Test function map creation. -TEST_F(LexicalScopesTest, TestFunctionScan) { - auto MF2 = createMachineFunction(Ctx, Mod, "Test2"); - DIBuilder DIB(Mod, false, OurCU); - DISubprogram *Func2 = - DIB.createFunction(OurCU, "Func2", "", OurFile, 1, OurSubT, 1, - DINode::FlagZero, DISubprogram::SPFlagDefinition); - DISubprogram *UnattachedFunc = - DIB.createFunction(OurCU, "UnattachedFunc", "", OurFile, 1, OurSubT, 1, - DINode::FlagZero, DISubprogram::SPFlagDefinition); - MF2->getFunction().setSubprogram(Func2); - DIB.finalize(); - - LexicalScopes LS; - LS.initialize(Mod); - ASSERT_EQ(LS.getFunction(OurFunc), &MF->getFunction()); - ASSERT_EQ(LS.getFunction(Func2), &MF2->getFunction()); - ASSERT_EQ(LS.getFunction(UnattachedFunc), nullptr); -} - } // anonymous namespace |
