diff options
| author | 2018-04-06 14:26:03 +0000 | |
|---|---|---|
| committer | 2018-04-06 14:26:03 +0000 | |
| commit | bdabc2f19ffb9e20600dad6e8a300842a7bda50e (patch) | |
| tree | c50e7b2e5449b074651bb82a58517a8ebc4a8cf7 /gnu/llvm/unittests/IR/MetadataTest.cpp | |
| parent | Print a 'p' flag for file descriptors that were opened after pledge(2). (diff) | |
| download | wireguard-openbsd-bdabc2f19ffb9e20600dad6e8a300842a7bda50e.tar.xz wireguard-openbsd-bdabc2f19ffb9e20600dad6e8a300842a7bda50e.zip | |
Import LLVM 6.0.1 release including clang, lld and lldb.
"where is the kaboom?" deraadt@
Diffstat (limited to 'gnu/llvm/unittests/IR/MetadataTest.cpp')
| -rw-r--r-- | gnu/llvm/unittests/IR/MetadataTest.cpp | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/gnu/llvm/unittests/IR/MetadataTest.cpp b/gnu/llvm/unittests/IR/MetadataTest.cpp index e47afca532d..672de55fbde 100644 --- a/gnu/llvm/unittests/IR/MetadataTest.cpp +++ b/gnu/llvm/unittests/IR/MetadataTest.cpp @@ -92,10 +92,10 @@ protected: return DIFile::getDistinct(Context, "file.c", "/path/to/dir"); } DICompileUnit *getUnit() { - return DICompileUnit::getDistinct(Context, 1, getFile(), "clang", false, - "-g", 2, "", DICompileUnit::FullDebug, - getTuple(), getTuple(), getTuple(), - getTuple(), getTuple(), 0, true, false); + return DICompileUnit::getDistinct( + Context, 1, getFile(), "clang", false, "-g", 2, "", + DICompileUnit::FullDebug, getTuple(), getTuple(), getTuple(), + getTuple(), getTuple(), 0, true, false, false); } DIType *getBasicType(StringRef Name) { return DIBasicType::get(Context, dwarf::DW_TAG_unspecified_type, Name); @@ -1314,6 +1314,11 @@ TEST_F(DICompositeTypeTest, replaceOperands) { EXPECT_EQ(nullptr, N->getVTableHolder()); N->replaceVTableHolder(VTableHolder); EXPECT_EQ(VTableHolder, N->getVTableHolder()); + // As an extension, the containing type can be anything. This is + // used by Rust to associate vtables with their concrete type. + DIType *BasicType = getBasicType("basic"); + N->replaceVTableHolder(BasicType); + EXPECT_EQ(BasicType, N->getVTableHolder()); N->replaceVTableHolder(nullptr); EXPECT_EQ(nullptr, N->getVTableHolder()); @@ -1383,7 +1388,8 @@ TEST_F(DIFileTest, get) { EXPECT_NE(N, DIFile::get(Context, "other", Directory, CSKind, Checksum)); EXPECT_NE(N, DIFile::get(Context, Filename, "other", CSKind, Checksum)); - EXPECT_NE(N, DIFile::get(Context, Filename, Directory, DIFile::CSK_SHA1, Checksum)); + EXPECT_NE( + N, DIFile::get(Context, Filename, Directory, DIFile::CSK_SHA1, Checksum)); EXPECT_NE(N, DIFile::get(Context, Filename, Directory)); TempDIFile Temp = N->clone(); @@ -1417,7 +1423,7 @@ TEST_F(DICompileUnitTest, get) { Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId, true, - false); + false, false); EXPECT_EQ(dwarf::DW_TAG_compile_unit, N->getTag()); EXPECT_EQ(SourceLanguage, N->getSourceLanguage()); @@ -1474,7 +1480,8 @@ TEST_F(DICompileUnitTest, replaceArrays) { auto *N = DICompileUnit::getDistinct( Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, - RetainedTypes, nullptr, ImportedEntities, nullptr, DWOId, true, false); + RetainedTypes, nullptr, ImportedEntities, nullptr, DWOId, true, false, + false); auto *GlobalVariables = MDTuple::getDistinct(Context, None); EXPECT_EQ(nullptr, N->getGlobalVariables().get()); @@ -2024,6 +2031,18 @@ TEST_F(DIExpressionTest, get) { TempDIExpression Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); + + // Test DIExpression::prepend(). + uint64_t Elts0[] = {dwarf::DW_OP_LLVM_fragment, 0, 32}; + auto *N0 = DIExpression::get(Context, Elts0); + N0 = DIExpression::prepend(N0, true, 64, true, true); + uint64_t Elts1[] = {dwarf::DW_OP_deref, + dwarf::DW_OP_plus_uconst, 64, + dwarf::DW_OP_deref, + dwarf::DW_OP_stack_value, + dwarf::DW_OP_LLVM_fragment, 0, 32}; + auto *N1 = DIExpression::get(Context, Elts1); + EXPECT_EQ(N0, N1); } TEST_F(DIExpressionTest, isValid) { @@ -2466,8 +2485,12 @@ TEST_F(DistinctMDOperandPlaceholderTest, replaceUseWithNoUser) { DistinctMDOperandPlaceholder(7).replaceUseWith(MDTuple::get(Context, None)); } -#ifndef NDEBUG -#ifdef GTEST_HAS_DEATH_TEST +// Test various assertions in metadata tracking. Don't run these tests if gtest +// will use SEH to recover from them. Two of these tests get halfway through +// inserting metadata into DenseMaps for tracking purposes, and then they +// assert, and we attempt to destroy an LLVMContext with broken invariants, +// leading to infinite loops. +#if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG) && !defined(GTEST_HAS_SEH) TEST_F(DistinctMDOperandPlaceholderTest, MetadataAsValue) { // This shouldn't crash. DistinctMDOperandPlaceholder PH(7); @@ -2509,6 +2532,5 @@ TEST_F(DistinctMDOperandPlaceholderTest, TrackingMDRefAndDistinctMDNode) { } } #endif -#endif } // end namespace |
