AsmWriter: MDCompositeType: Recognize DW_LANG in 'runtimeLang'

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229010 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-02-13 01:21:25 +00:00
parent dacf0004cb
commit 65e1227b37
6 changed files with 60 additions and 9 deletions

View File

@@ -2949,6 +2949,9 @@ struct DwarfTagField : public MDUnsignedField {
struct DwarfAttEncodingField : public MDUnsignedField {
DwarfAttEncodingField() : MDUnsignedField(0, dwarf::DW_ATE_hi_user) {}
};
struct DwarfLangField : public MDUnsignedField {
DwarfLangField() : MDUnsignedField(0, dwarf::DW_LANG_hi_user) {}
};
struct MDSignedField : public MDFieldImpl<int64_t> {
int64_t Min;
@@ -2960,6 +2963,9 @@ struct MDSignedField : public MDFieldImpl<int64_t> {
: ImplTy(Default), Min(Min), Max(Max) {}
};
struct MDBoolField : public MDFieldImpl<bool> {
MDBoolField(bool Default = false) : ImplTy(Default) {}
};
struct MDField : public MDFieldImpl<Metadata *> {
MDField() : ImplTy(nullptr) {}
};
@@ -3017,6 +3023,24 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result) {
return false;
}
template <>
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfLangField &Result) {
if (Lex.getKind() == lltok::APSInt)
return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result));
if (Lex.getKind() != lltok::DwarfLang)
return TokError("expected DWARF language");
unsigned Lang = dwarf::getLanguage(Lex.getStrVal());
if (!Lang)
return TokError("invalid DWARF language" + Twine(" '") + Lex.getStrVal() +
"'");
assert(Lang <= Result.Max && "Expected valid DWARF language");
Result.assign(Lang);
Lex.Lex();
return false;
}
template <>
bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
DwarfAttEncodingField &Result) {
@@ -3056,6 +3080,22 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
return false;
}
template <>
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDBoolField &Result) {
switch (Lex.getKind()) {
default:
return TokError("expected 'true' or 'false'");
case lltok::kw_true:
Result.assign(true);
break;
case lltok::kw_false:
Result.assign(false);
break;
}
Lex.Lex();
return false;
}
template <>
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDField &Result) {
Metadata *MD;
@@ -3273,7 +3313,7 @@ bool LLParser::ParseMDCompositeType(MDNode *&Result, bool IsDistinct) {
OPTIONAL(offset, MDUnsignedField, (0, UINT32_MAX)); \
OPTIONAL(flags, MDUnsignedField, (0, UINT32_MAX)); \
OPTIONAL(elements, MDField, ); \
OPTIONAL(runtimeLang, MDUnsignedField, (0, UINT32_MAX)); \
OPTIONAL(runtimeLang, DwarfLangField, ); \
OPTIONAL(vtableHolder, MDField, ); \
OPTIONAL(templateParams, MDField, ); \
OPTIONAL(identifier, MDStringField, );