/// \brief Check if node is fully resolved.
bool isResolved() const;
- /// \brief Check if node is distinct.
- ///
- /// Distinct nodes are not uniqued, and will not be returned by \a
- /// MDNode::get().
- bool isDistinct() const {
- return isStoredDistinctInContext() || isa<MDNodeFwdDecl>(this);
- }
+ bool isUniqued() const { return Storage == Uniqued; }
+ bool isDistinct() const { return Storage == Distinct; }
+ bool isTemporary() const { return Storage == Temporary; }
protected:
/// \brief Set an operand.
ValueToValueMapTy &VM, RemapFlags Flags,
ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
- assert(!Node->isDistinct() && "Expected uniqued node");
+ assert(Node->isUniqued() && "Expected uniqued node");
// Create a dummy node in case we have a metadata cycle.
MDNodeFwdDecl *Dummy = MDNode::getTemporary(Node->getContext(), None);
ASSERT_EQ(Empty, MDNode::get(Context, None));
}
-TEST_F(MDNodeTest, TempIsDistinct) {
- MDNode *T = MDNode::getTemporary(Context, None);
- EXPECT_TRUE(T->isDistinct());
+TEST_F(MDNodeTest, isUniqued) {
+ MDNode *U = MDTuple::get(Context, None);
+ MDNode *D = MDTuple::getDistinct(Context, None);
+ MDNode *T = MDTuple::getTemporary(Context, None);
+ EXPECT_TRUE(U->isUniqued());
+ EXPECT_FALSE(D->isUniqued());
+ EXPECT_FALSE(T->isUniqued());
+ MDNode::deleteTemporary(T);
+}
+
+TEST_F(MDNodeTest, isDistinct) {
+ MDNode *U = MDTuple::get(Context, None);
+ MDNode *D = MDTuple::getDistinct(Context, None);
+ MDNode *T = MDTuple::getTemporary(Context, None);
+ EXPECT_FALSE(U->isDistinct());
+ EXPECT_TRUE(D->isDistinct());
+ EXPECT_FALSE(T->isDistinct());
+ MDNode::deleteTemporary(T);
+}
+
+TEST_F(MDNodeTest, isTemporary) {
+ MDNode *U = MDTuple::get(Context, None);
+ MDNode *D = MDTuple::getDistinct(Context, None);
+ MDNode *T = MDTuple::getTemporary(Context, None);
+ EXPECT_FALSE(U->isTemporary());
+ EXPECT_FALSE(D->isTemporary());
+ EXPECT_TRUE(T->isTemporary());
MDNode::deleteTemporary(T);
}