aboutsummaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-07-30 00:03:41 +0000
committerDevang Patel <dpatel@apple.com>2009-07-30 00:03:41 +0000
commitfa7c4dcef21003aec7f4630eec3d0e1117fb2259 (patch)
treece50b266a2c96b27189bd67d31b9a9aa4fa00b11 /unittests
parentc29d5b378ece00608ec96a5ccd2b0f53999f1957 (diff)
downloadexternal_llvm-fa7c4dcef21003aec7f4630eec3d0e1117fb2259.zip
external_llvm-fa7c4dcef21003aec7f4630eec3d0e1117fb2259.tar.gz
external_llvm-fa7c4dcef21003aec7f4630eec3d0e1117fb2259.tar.bz2
Add NamedMDNode test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77550 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/VMCore/MetadataTest.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/unittests/VMCore/MetadataTest.cpp b/unittests/VMCore/MetadataTest.cpp
index 51df79f..22b9099 100644
--- a/unittests/VMCore/MetadataTest.cpp
+++ b/unittests/VMCore/MetadataTest.cpp
@@ -11,6 +11,7 @@
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
#include "llvm/Metadata.h"
+#include "llvm/Module.h"
#include "llvm/Type.h"
#include "llvm/Support/ValueHandle.h"
#include <sstream>
@@ -117,4 +118,25 @@ TEST(MDNodeTest, Delete) {
wvh->print(oss);
EXPECT_STREQ("!0 = metadata !{null}\n", oss.str().c_str());
}
+
+TEST(NamedMDNodeTest, Search) {
+ Constant *C = ConstantInt::get(Type::Int32Ty, 1);
+ Constant *C2 = ConstantInt::get(Type::Int32Ty, 2);
+
+ Value *const V = C;
+ Value *const V2 = C2;
+ MDNode *n = getGlobalContext().getMDNode(&V, 1);
+ MDNode *n2 = getGlobalContext().getMDNode(&V2, 1);
+
+ MetadataBase *Nodes[2] = { n, n2 };
+
+ Module *M = new Module("MyModule", getGlobalContext());
+ const char *Name = "llvm.NMD1";
+ NamedMDNode *NMD = NamedMDNode::Create(Name, &Nodes[0], 2, M);
+ std::ostringstream oss;
+ NMD->print(oss);
+ EXPECT_STREQ("!llvm.NMD1 = !{!0, !1}\n!0 = metadata !{i32 1}\n"
+ "!1 = metadata !{i32 2}\n",
+ oss.str().c_str());
+}
}