aboutsummaryrefslogtreecommitdiff
path: root/lib/AsmParser/LLParser.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-07-29 00:34:02 +0000
committerDevang Patel <dpatel@apple.com>2009-07-29 00:34:02 +0000
commiteff2ab61b5d411fe64ba601d402b7c549644b590 (patch)
tree9ae0776e9d9fe6b7bb3aed32ed6ab3104d00e5c5 /lib/AsmParser/LLParser.cpp
parentf457d1316dec017cf204b54524878310c356bf64 (diff)
Parse named metadata.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77410 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/LLParser.cpp')
-rw-r--r--lib/AsmParser/LLParser.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index b2d2b51b6c..36f714b38e 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -121,6 +121,7 @@ bool LLParser::ParseTopLevelEntities() {
case lltok::LocalVar: if (ParseNamedType()) return true; break;
case lltok::GlobalVar: if (ParseNamedGlobal()) return true; break;
case lltok::Metadata: if (ParseStandaloneMetadata()) return true; break;
+ case lltok::NamedMD: if (ParseNamedMetadata()) return true; break;
// The Global variable production with no name can have many different
// optional leading prefixes, the production is:
@@ -409,6 +410,41 @@ bool LLParser::ParseMDNode(MetadataBase *&Node) {
return false;
}
+///ParseNamedMetadata:
+/// !foo = !{ !1, !2 }
+bool LLParser::ParseNamedMetadata() {
+ assert(Lex.getKind() == lltok::NamedMD);
+ Lex.Lex();
+ std::string Name = Lex.getStrVal();
+
+ if (ParseToken(lltok::equal, "expected '=' here"))
+ return true;
+
+ if (Lex.getKind() != lltok::Metadata)
+ return TokError("Expected '!' here");
+ Lex.Lex();
+
+ if (Lex.getKind() != lltok::lbrace)
+ return TokError("Expected '{' here");
+ Lex.Lex();
+ SmallVector<MetadataBase *, 8> Elts;
+ do {
+ if (Lex.getKind() != lltok::Metadata)
+ return TokError("Expected '!' here");
+ Lex.Lex();
+ MetadataBase *N = 0;
+ if (ParseMDNode(N)) return true;
+ Elts.push_back(N);
+ } while (EatIfPresent(lltok::comma));
+
+ if (ParseToken(lltok::rbrace, "expected end of metadata node"))
+ return true;
+
+ NamedMDNode::Create(Name.c_str(), Name.length(),
+ Elts.data(), Elts.size(), M);
+ return false;
+}
+
/// ParseStandaloneMetadata:
/// !42 = !{...}
bool LLParser::ParseStandaloneMetadata() {