EXPECT_TRUE(T->isTemporary());
}
+#if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG)
+
+TEST_F(MDNodeTest, deathOnNoReplaceTemporaryRAUW) {
+ auto Temp = MDNode::getTemporary(Context, None);
+ Temp->setCanReplace(false);
+ EXPECT_DEATH(Temp->replaceAllUsesWith(nullptr),
+ "Attempted to replace Metadata marked for no replacement");
+ Temp->setCanReplace(true);
+ // Remove the references to Temp; required for teardown.
+ Temp->replaceAllUsesWith(nullptr);
+}
+
+#endif
+
TEST_F(MDNodeTest, getDistinctWithUnresolvedOperands) {
// temporary !{}
auto Temp = MDTuple::getTemporary(Context, None);
EXPECT_FALSE(L->isResolved());
}
+TEST_F(DILocationTest, cloneTemporary) {
+ MDNode *N = MDNode::get(Context, None);
+ auto L = DILocation::getTemporary(Context, 2, 7, N);
+ EXPECT_TRUE(L->isTemporary());
+ auto L2 = L->clone();
+ EXPECT_TRUE(L2->isTemporary());
+}
+
typedef MetadataTest GenericDINodeTest;
TEST_F(GenericDINodeTest, get) {
MDTuple *GlobalVariables = getTuple();
MDTuple *ImportedEntities = getTuple();
uint64_t DWOId = 0x10000000c0ffee;
+ MDTuple *Macros = getTuple();
auto *N = DICompileUnit::getDistinct(
Context, SourceLanguage, File, Producer, IsOptimized, Flags,
RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
- RetainedTypes, Subprograms, GlobalVariables, ImportedEntities, DWOId);
+ RetainedTypes, Subprograms, GlobalVariables, ImportedEntities, Macros,
+ DWOId);
EXPECT_EQ(dwarf::DW_TAG_compile_unit, N->getTag());
EXPECT_EQ(SourceLanguage, N->getSourceLanguage());
EXPECT_EQ(Subprograms, N->getSubprograms().get());
EXPECT_EQ(GlobalVariables, N->getGlobalVariables().get());
EXPECT_EQ(ImportedEntities, N->getImportedEntities().get());
+ EXPECT_EQ(Macros, N->getMacros().get());
EXPECT_EQ(DWOId, N->getDWOId());
TempDICompileUnit Temp = N->clone();
EXPECT_EQ(Subprograms, Temp->getSubprograms().get());
EXPECT_EQ(GlobalVariables, Temp->getGlobalVariables().get());
EXPECT_EQ(ImportedEntities, Temp->getImportedEntities().get());
+ EXPECT_EQ(Macros, Temp->getMacros().get());
EXPECT_EQ(DWOId, Temp->getDWOId());
auto *TempAddress = Temp.get();
auto *N = DICompileUnit::getDistinct(
Context, SourceLanguage, File, Producer, IsOptimized, Flags,
RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
- RetainedTypes, nullptr, nullptr, ImportedEntities, DWOId);
+ RetainedTypes, nullptr, nullptr, ImportedEntities, nullptr, DWOId);
auto *Subprograms = MDTuple::getDistinct(Context, None);
EXPECT_EQ(nullptr, N->getSubprograms().get());
EXPECT_EQ(GlobalVariables, N->getGlobalVariables().get());
N->replaceGlobalVariables(nullptr);
EXPECT_EQ(nullptr, N->getGlobalVariables().get());
+
+ auto *Macros = MDTuple::getDistinct(Context, None);
+ EXPECT_EQ(nullptr, N->getMacros().get());
+ N->replaceMacros(Macros);
+ EXPECT_EQ(Macros, N->getMacros().get());
+ N->replaceMacros(nullptr);
+ EXPECT_EQ(nullptr, N->getMacros().get());
}
typedef MetadataTest DISubprogramTest;