aboutsummaryrefslogtreecommitdiff
path: root/lib/AsmParser/LLParser.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2009-05-10 20:57:05 +0000
committerNick Lewycky <nicholas@mxc.ca>2009-05-10 20:57:05 +0000
commitcb33799b9f4e152e3460faa83e59b53ff604c87d (patch)
treedd87d965d590665a7ebdb4f4939b364364fe5e18 /lib/AsmParser/LLParser.cpp
parentaf3fdb5dc4edf052ee4a3a169250fc3be304d1a7 (diff)
Make MDNode use CallbackVH. Also change MDNode to store Value* instead of
Constant* in preperation of a future change to support holding non-Constants in an MDNode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71407 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/LLParser.cpp')
-rw-r--r--lib/AsmParser/LLParser.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index a2edf05050..21243975f1 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -18,6 +18,7 @@
#include "llvm/DerivedTypes.h"
#include "llvm/InlineAsm.h"
#include "llvm/Instructions.h"
+#include "llvm/MDNode.h"
#include "llvm/Module.h"
#include "llvm/ValueSymbolTable.h"
#include "llvm/ADT/SmallPtrSet.h"
@@ -1571,13 +1572,11 @@ bool LLParser::ParseValID(ValID &ID) {
ID.Kind = ValID::t_Constant;
Lex.Lex();
if (Lex.getKind() == lltok::lbrace) {
- // MDNode:
- // ::= '!' '{' TypeAndValue (',' TypeAndValue)* '}'
- SmallVector<Constant*, 16> Elts;
+ SmallVector<Value*, 16> Elts;
if (ParseMDNodeVector(Elts) ||
ParseToken(lltok::rbrace, "expected end of metadata node"))
return true;
-
+
ID.ConstantVal = MDNode::get(&Elts[0], Elts.size());
return false;
}
@@ -3257,14 +3256,23 @@ bool LLParser::ParseInsertValue(Instruction *&Inst, PerFunctionState &PFS) {
//===----------------------------------------------------------------------===//
/// ParseMDNodeVector
-/// ::= TypeAndValue (',' TypeAndValue)*
-bool LLParser::ParseMDNodeVector(SmallVectorImpl<Constant*> &Elts) {
+/// ::= Element (',' Element)*
+/// Element
+/// ::= 'null' | TypeAndValue
+bool LLParser::ParseMDNodeVector(SmallVectorImpl<Value*> &Elts) {
assert(Lex.getKind() == lltok::lbrace);
Lex.Lex();
do {
- Constant *C;
- if (ParseGlobalTypeAndValue(C)) return true;
- Elts.push_back(C);
+ Value *V;
+ if (Lex.getKind() == lltok::kw_null) {
+ Lex.Lex();
+ V = 0;
+ } else {
+ Constant *C;
+ if (ParseGlobalTypeAndValue(C)) return true;
+ V = C;
+ }
+ Elts.push_back(V);
} while (EatIfPresent(lltok::comma));
return false;