aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-07-01 20:59:15 +0000
committerDevang Patel <dpatel@apple.com>2009-07-01 20:59:15 +0000
commitfcd65ae28fe797c174be350a07955713fd42d110 (patch)
tree7ce437e6336b87d85057464a0d58b19e82d7cf88
parent8a156021199565fb1f35bf1749ae4b937b56c605 (diff)
Fix metadata unittests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74638 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/VMCore/AsmWriter.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index 6ca08bbc7a..cbf7070d17 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -1103,6 +1103,7 @@ public:
void writeOperand(const Value *Op, bool PrintType);
void writeParamOperand(const Value *Operand, Attributes Attrs);
+ void printMDNode(const MDNode *Node, bool StandAlone);
const Module* getModule() { return TheModule; }
@@ -1110,7 +1111,6 @@ private:
void printModule(const Module *M);
void printTypeSymbolTable(const TypeSymbolTable &ST);
void printGlobal(const GlobalVariable *GV);
- void printMDNode(const MDNode *Node, bool StandAlone);
void printAlias(const GlobalAlias *GV);
void printFunction(const Function *F);
void printArgument(const Argument *FA, Attributes Attrs);
@@ -1314,7 +1314,7 @@ void AssemblyWriter::printMDNode(const MDNode *Node,
// id number.
if (MI != MDNodes.end()) {
if (!StandAlone)
- Out << "metadata !" << MI->second;
+ Out << "!" << MI->second;
return;
}
@@ -1324,14 +1324,18 @@ void AssemblyWriter::printMDNode(const MDNode *Node,
Out << "!" << MetadataIDNo << " = ";
Out << "constant metadata ";
}
+
Out << "!{";
for (MDNode::const_elem_iterator I = Node->elem_begin(), E = Node->elem_end();
I != E;) {
const Value *TV = *I;
if (!TV)
Out << "null";
- else if (const MDNode *N = dyn_cast<MDNode>(TV))
+ else if (const MDNode *N = dyn_cast<MDNode>(TV)) {
+ TypePrinter.print(N->getType(), Out);
+ Out << ' ';
printMDNode(N, StandAlone);
+ }
else if (!*I)
Out << "null";
else
@@ -1901,6 +1905,14 @@ void Value::print(raw_ostream &OS, AssemblyAnnotationWriter *AAW) const {
SlotTracker SlotTable(GV->getParent());
AssemblyWriter W(OS, SlotTable, GV->getParent(), AAW);
W.write(GV);
+ } else if (const MDNode *N = dyn_cast<MDNode>(this)) {
+ TypePrinting TypePrinter;
+ TypePrinter.print(N->getType(), OS);
+ OS << ' ';
+ // FIXME: Do we need a slot tracker for metadata ?
+ SlotTracker SlotTable((const Function *)NULL);
+ AssemblyWriter W(OS, SlotTable, NULL, AAW);
+ W.printMDNode(N, false);
} else if (const Constant *C = dyn_cast<Constant>(this)) {
TypePrinting TypePrinter;
TypePrinter.print(C->getType(), OS);