[llvm-commits] [llvm] r77550 - /llvm/trunk/unittests/VMCore/MetadataTest.cpp

Devang Patel dpatel at apple.com
Wed Jul 29 17:03:41 PDT 2009


Author: dpatel
Date: Wed Jul 29 19:03:41 2009
New Revision: 77550

URL: http://llvm.org/viewvc/llvm-project?rev=77550&view=rev
Log:
Add NamedMDNode test.

Modified:
    llvm/trunk/unittests/VMCore/MetadataTest.cpp

Modified: llvm/trunk/unittests/VMCore/MetadataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/MetadataTest.cpp?rev=77550&r1=77549&r2=77550&view=diff

==============================================================================
--- llvm/trunk/unittests/VMCore/MetadataTest.cpp (original)
+++ llvm/trunk/unittests/VMCore/MetadataTest.cpp Wed Jul 29 19:03:41 2009
@@ -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 @@
   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());
+}
 }





More information about the llvm-commits mailing list