AsmParser: Add stubs for specialized MDNodes, NFC

Well, the exact error from the failed parse will change, but...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228644 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2015-02-10 01:08:16 +00:00
parent 69114ee016
commit f4293bcf4e
3 changed files with 109 additions and 37 deletions

View File

@ -13,7 +13,9 @@
#if !(defined HANDLE_METADATA || defined HANDLE_METADATA_LEAF || \
defined HANDLE_METADATA_BRANCH || defined HANDLE_MDNODE_LEAF || \
defined HANDLE_MDNODE_BRANCH)
defined HANDLE_MDNODE_BRANCH || \
defined HANDLE_SPECIALIZED_MDNODE_LEAF || \
defined HANDLE_SPECIALIZED_MDNODE_BRANCH)
#error "Missing macro definition of HANDLE_METADATA*"
#endif
@ -42,44 +44,56 @@
#define HANDLE_MDNODE_BRANCH(CLASS) HANDLE_METADATA_BRANCH(CLASS)
#endif
// Handler for specialized leaf nodes under MDNode.
#ifndef HANDLE_SPECIALIZED_MDNODE_LEAF
#define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) HANDLE_MDNODE_LEAF(CLASS)
#endif
// Handler for specialized non-leaf nodes under MDNode.
#ifndef HANDLE_SPECIALIZED_MDNODE_BRANCH
#define HANDLE_SPECIALIZED_MDNODE_BRANCH(CLASS) HANDLE_MDNODE_BRANCH(CLASS)
#endif
HANDLE_METADATA_LEAF(MDString)
HANDLE_METADATA_BRANCH(ValueAsMetadata)
HANDLE_METADATA_LEAF(ConstantAsMetadata)
HANDLE_METADATA_LEAF(LocalAsMetadata)
HANDLE_MDNODE_BRANCH(MDNode)
HANDLE_MDNODE_LEAF(MDTuple)
HANDLE_MDNODE_LEAF(MDLocation)
HANDLE_MDNODE_BRANCH(DebugNode)
HANDLE_MDNODE_LEAF(GenericDebugNode)
HANDLE_MDNODE_LEAF(MDSubrange)
HANDLE_MDNODE_LEAF(MDEnumerator)
HANDLE_MDNODE_BRANCH(MDScope)
HANDLE_MDNODE_BRANCH(MDType)
HANDLE_MDNODE_LEAF(MDBasicType)
HANDLE_MDNODE_BRANCH(MDDerivedTypeBase)
HANDLE_MDNODE_LEAF(MDDerivedType)
HANDLE_MDNODE_BRANCH(MDCompositeTypeBase)
HANDLE_MDNODE_LEAF(MDCompositeType)
HANDLE_MDNODE_LEAF(MDSubroutineType)
HANDLE_MDNODE_LEAF(MDFile)
HANDLE_MDNODE_LEAF(MDCompileUnit)
HANDLE_MDNODE_LEAF(MDSubprogram)
HANDLE_MDNODE_BRANCH(MDLexicalBlockBase)
HANDLE_MDNODE_LEAF(MDLexicalBlock)
HANDLE_MDNODE_LEAF(MDLexicalBlockFile)
HANDLE_MDNODE_LEAF(MDNamespace)
HANDLE_MDNODE_BRANCH(MDTemplateParameter)
HANDLE_MDNODE_LEAF(MDTemplateTypeParameter)
HANDLE_MDNODE_LEAF(MDTemplateValueParameter)
HANDLE_MDNODE_BRANCH(MDVariable)
HANDLE_MDNODE_LEAF(MDGlobalVariable)
HANDLE_MDNODE_LEAF(MDLocalVariable)
HANDLE_MDNODE_LEAF(MDExpression)
HANDLE_MDNODE_LEAF(MDObjCProperty)
HANDLE_MDNODE_LEAF(MDImportedEntity)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDLocation)
HANDLE_SPECIALIZED_MDNODE_BRANCH(DebugNode)
HANDLE_SPECIALIZED_MDNODE_LEAF(GenericDebugNode)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDSubrange)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDEnumerator)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDScope)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDType)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDBasicType)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDDerivedTypeBase)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDDerivedType)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDCompositeTypeBase)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDCompositeType)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDSubroutineType)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDFile)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDCompileUnit)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDSubprogram)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDLexicalBlockBase)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDLexicalBlock)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDLexicalBlockFile)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDNamespace)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDTemplateParameter)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDTemplateTypeParameter)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDTemplateValueParameter)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDVariable)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDGlobalVariable)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDLocalVariable)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDExpression)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDObjCProperty)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDImportedEntity)
#undef HANDLE_METADATA
#undef HANDLE_METADATA_LEAF
#undef HANDLE_METADATA_BRANCH
#undef HANDLE_MDNODE_LEAF
#undef HANDLE_MDNODE_BRANCH
#undef HANDLE_SPECIALIZED_MDNODE_LEAF
#undef HANDLE_SPECIALIZED_MDNODE_BRANCH

View File

@ -3083,13 +3083,11 @@ bool LLParser::ParseMDField(StringRef Name, FieldTy &Result) {
bool LLParser::ParseSpecializedMDNode(MDNode *&N, bool IsDistinct) {
assert(Lex.getKind() == lltok::MetadataVar && "Expected metadata type name");
#define DISPATCH_TO_PARSER(CLASS) \
#define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) \
if (Lex.getStrVal() == #CLASS) \
return Parse##CLASS(N, IsDistinct);
DISPATCH_TO_PARSER(MDLocation);
DISPATCH_TO_PARSER(GenericDebugNode);
#undef DISPATCH_TO_PARSER
#include "llvm/IR/Metadata.def"
return TokError("expected metadata type");
}
@ -3146,6 +3144,64 @@ bool LLParser::ParseGenericDebugNode(MDNode *&Result, bool IsDistinct) {
(Context, tag.Val, header.Val, operands.Val));
return false;
}
bool LLParser::ParseMDSubrange(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDEnumerator(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDBasicType(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDDerivedType(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDCompositeType(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDSubroutineType(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDFile(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDCompileUnit(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDSubprogram(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDLexicalBlock(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDLexicalBlockFile(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDNamespace(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDTemplateTypeParameter(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDTemplateValueParameter(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDGlobalVariable(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDLocalVariable(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDExpression(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDObjCProperty(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
bool LLParser::ParseMDImportedEntity(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
#undef PARSE_MD_FIELD
#undef NOP_FIELD
#undef REQUIRE_FIELD

View File

@ -401,8 +401,10 @@ namespace llvm {
template <class ParserTy>
bool ParseMDFieldsImpl(ParserTy parseField, LocTy &ClosingLoc);
bool ParseSpecializedMDNode(MDNode *&N, bool IsDistinct = false);
bool ParseMDLocation(MDNode *&Result, bool IsDistinct);
bool ParseGenericDebugNode(MDNode *&Result, bool IsDistinct);
#define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) \
bool Parse##CLASS(MDNode *&Result, bool IsDistinct);
#include "llvm/IR/Metadata.def"
// Function Parsing.
struct ArgInfo {