OSDN Git Service

IR: Add MDLocation::getTemporary()
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 19 Jan 2015 20:37:44 +0000 (20:37 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 19 Jan 2015 20:37:44 +0000 (20:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226502 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Metadata.h
unittests/IR/MetadataTest.cpp

index 6f02ee1..2b37412 100644 (file)
@@ -945,6 +945,11 @@ public:
                                  Metadata *InlinedAt = nullptr) {
     return getImpl(Context, Line, Column, Scope, InlinedAt, Distinct);
   }
+  static MDLocation *getTemporary(LLVMContext &Context, unsigned Line,
+                                  unsigned Column, Metadata *Scope,
+                                  Metadata *InlinedAt = nullptr) {
+    return getImpl(Context, Line, Column, Scope, InlinedAt, Temporary);
+  }
 
   unsigned getLine() const { return MDNodeSubclassData; }
   unsigned getColumn() const { return SubclassData16; }
index 9515f0d..498728e 100644 (file)
@@ -483,6 +483,14 @@ TEST_F(MDLocationTest, getDistinct) {
   EXPECT_EQ(L1, MDLocation::get(Context, 2, 7, N));
 }
 
+TEST_F(MDLocationTest, getTemporary) {
+  MDNode *N = MDNode::get(Context, None);
+  MDLocation *L = MDLocation::getTemporary(Context, 2, 7, N);
+  EXPECT_TRUE(L->isTemporary());
+  EXPECT_FALSE(L->isResolved());
+  MDNode::deleteTemporary(L);
+}
+
 typedef MetadataTest MetadataAsValueTest;
 
 TEST_F(MetadataAsValueTest, MDNode) {