summaryrefslogtreecommitdiffstats
path: root/llvm/lib/AsmParser/LLParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/AsmParser/LLParser.cpp')
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 42ce206e3af..33f395a1f5a 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -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) {}
};
@@ -3018,6 +3024,24 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result) {
}
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) {
if (Lex.getKind() == lltok::APSInt)
@@ -3057,6 +3081,22 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
}
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;
if (ParseMetadata(MD, nullptr))
@@ -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, );
OpenPOWER on IntegriCloud