summaryrefslogtreecommitdiff
path: root/lib/AsmParser/LLParser.cpp
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2010-01-05 22:22:14 +0000
committerVictor Hernandez <vhernandez@apple.com>2010-01-05 22:22:14 +0000
commitbf170d4c2ffd9dc99fad1fabfbf1f90f980a9782 (patch)
treeabeb38e93face65578a32e67a86a335427484564 /lib/AsmParser/LLParser.cpp
parent7a34d6c450035dad9d494502c7c742137c42958e (diff)
downloadllvm-bf170d4c2ffd9dc99fad1fabfbf1f90f980a9782.tar.gz
llvm-bf170d4c2ffd9dc99fad1fabfbf1f90f980a9782.tar.bz2
llvm-bf170d4c2ffd9dc99fad1fabfbf1f90f980a9782.tar.xz
Re-add parsing of function-local metadata; this time with testcase.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92793 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/LLParser.cpp')
-rw-r--r--lib/AsmParser/LLParser.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 99ddeb682b..a917d858f5 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -548,7 +548,7 @@ bool LLParser::ParseStandaloneMetadata() {
ParseType(Ty, TyLoc) ||
ParseToken(lltok::exclaim, "Expected '!' here") ||
ParseToken(lltok::lbrace, "Expected '{' here") ||
- ParseMDNodeVector(Elts) ||
+ ParseMDNodeVector(Elts, NULL) ||
ParseToken(lltok::rbrace, "expected end of metadata node"))
return true;
@@ -1885,7 +1885,7 @@ BasicBlock *LLParser::PerFunctionState::DefineBB(const std::string &Name,
/// type implied. For example, if we parse "4" we don't know what integer type
/// it has. The value will later be combined with its type and checked for
/// sanity.
-bool LLParser::ParseValID(ValID &ID) {
+bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
ID.Loc = Lex.getLoc();
switch (Lex.getKind()) {
default: return TokError("expected value token");
@@ -1911,7 +1911,7 @@ bool LLParser::ParseValID(ValID &ID) {
if (EatIfPresent(lltok::lbrace)) {
SmallVector<Value*, 16> Elts;
- if (ParseMDNodeVector(Elts) ||
+ if (ParseMDNodeVector(Elts, PFS) ||
ParseToken(lltok::rbrace, "expected end of metadata node"))
return true;
@@ -2444,9 +2444,10 @@ bool LLParser::ConvertGlobalValIDToValue(const Type *Ty, ValID &ID,
}
/// ConvertGlobalOrMetadataValIDToValue - Apply a type to a ValID to get a fully
-/// resolved constant or metadata value.
+/// resolved constant, metadata, or function-local value
bool LLParser::ConvertGlobalOrMetadataValIDToValue(const Type *Ty, ValID &ID,
- Value *&V) {
+ Value *&V,
+ PerFunctionState *PFS) {
switch (ID.Kind) {
case ValID::t_MDNode:
if (!Ty->isMetadataTy())
@@ -2458,6 +2459,12 @@ bool LLParser::ConvertGlobalOrMetadataValIDToValue(const Type *Ty, ValID &ID,
return Error(ID.Loc, "metadata value must have metadata type");
V = ID.MDStringVal;
return false;
+ case ValID::t_LocalID:
+ case ValID::t_LocalName:
+ if (!PFS)
+ return Error(ID.Loc, "invalid use of function-local name");
+ if (ConvertValIDToValue(Ty, ID, V, *PFS)) return true;
+ return false;
default:
Constant *C;
if (ConvertGlobalValIDToValue(Ty, ID, C)) return true;
@@ -2516,7 +2523,7 @@ bool LLParser::ConvertValIDToValue(const Type *Ty, ValID &ID, Value *&V,
return false;
}
default:
- return ConvertGlobalOrMetadataValIDToValue(Ty, ID, V);
+ return ConvertGlobalOrMetadataValIDToValue(Ty, ID, V, &PFS);
}
return V == 0;
@@ -2525,7 +2532,7 @@ bool LLParser::ConvertValIDToValue(const Type *Ty, ValID &ID, Value *&V,
bool LLParser::ParseValue(const Type *Ty, Value *&V, PerFunctionState &PFS) {
V = 0;
ValID ID;
- return ParseValID(ID) ||
+ return ParseValID(ID, &PFS) ||
ConvertValIDToValue(Ty, ID, V, PFS);
}
@@ -3842,7 +3849,8 @@ int LLParser::ParseInsertValue(Instruction *&Inst, PerFunctionState &PFS) {
/// ::= Element (',' Element)*
/// Element
/// ::= 'null' | TypeAndValue
-bool LLParser::ParseMDNodeVector(SmallVectorImpl<Value*> &Elts) {
+bool LLParser::ParseMDNodeVector(SmallVectorImpl<Value*> &Elts,
+ PerFunctionState *PFS) {
do {
// Null is a special case since it is typeless.
if (EatIfPresent(lltok::kw_null)) {
@@ -3853,8 +3861,8 @@ bool LLParser::ParseMDNodeVector(SmallVectorImpl<Value*> &Elts) {
Value *V = 0;
PATypeHolder Ty(Type::getVoidTy(Context));
ValID ID;
- if (ParseType(Ty) || ParseValID(ID) ||
- ConvertGlobalOrMetadataValIDToValue(Ty, ID, V))
+ if (ParseType(Ty) || ParseValID(ID, PFS) ||
+ ConvertGlobalOrMetadataValIDToValue(Ty, ID, V, PFS))
return true;
Elts.push_back(V);