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

@ -746,6 +746,7 @@ lltok::Kind LLLexer::LexIdentifier() {
}
DWKEYWORD(TAG, DwarfTag);
DWKEYWORD(ATE, DwarfAttEncoding);
DWKEYWORD(LANG, DwarfLang);
#undef DWKEYWORD
// Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by

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, );

View File

@ -200,6 +200,7 @@ namespace lltok {
StringConstant, // "foo"
DwarfTag, // DW_TAG_foo (includes "DW_TAG_")
DwarfAttEncoding, // DW_ATE_foo (includes "DW_ATE_")
DwarfLang, // DW_LANG_foo (includes "DW_LANG_")
// Type valued tokens (TyVal).
Type,

View File

@ -1461,8 +1461,14 @@ static void writeMDCompositeType(raw_ostream &Out, const MDCompositeType *N,
writeMetadataAsOperand(Out, N->getElements(), TypePrinter, Machine,
Context);
}
if (N->getRuntimeLang())
Out << FS << "runtimeLang: " << N->getRuntimeLang();
if (unsigned Lang = N->getRuntimeLang()) {
Out << FS << "runtimeLang: ";
if (const char *S = dwarf::LanguageString(Lang))
Out << S;
else
Out << Lang;
}
if (N->getVTableHolder()) {
Out << FS << "vtableHolder: ";
writeMetadataAsOperand(Out, N->getVTableHolder(), TypePrinter, Machine,

View File

@ -1,8 +1,8 @@
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
; RUN: verify-uselistorder %s
; CHECK: !named = !{!0, !0, !1, !2, !3, !4, !5, !6, !7, !8, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23}
!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25}
; CHECK: !named = !{!0, !0, !1, !2, !3, !4, !5, !6, !7, !8, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24}
!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26}
; CHECK: !0 = !MDSubrange(count: 3)
; CHECK-NEXT: !1 = !MDSubrange(count: 3, lowerBound: 4)
@ -41,22 +41,24 @@
!15 = !MDDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32, align: 32)
; CHECK-NEXT: !14 = !MDCompositeType(tag: DW_TAG_structure_type, name: "MyType", file: !9, line: 2, size: 32, align: 32, identifier: "MangledMyType")
; CHECK-NEXT: !15 = distinct !MDCompositeType(tag: DW_TAG_structure_type, name: "Base", file: !9, line: 3, scope: !14, size: 128, align: 32, offset: 64, flags: 3, elements: !16, runtimeLang: 6, vtableHolder: !15, templateParams: !18, identifier: "MangledBase")
; CHECK-NEXT: !15 = distinct !MDCompositeType(tag: DW_TAG_structure_type, name: "Base", file: !9, line: 3, scope: !14, size: 128, align: 32, offset: 64, flags: 3, elements: !16, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !15, templateParams: !18, identifier: "MangledBase")
; CHECK-NEXT: !16 = !{!17}
; CHECK-NEXT: !17 = !MDDerivedType(tag: DW_TAG_member, name: "field", file: !9, line: 4, scope: !15, baseType: !6, size: 32, align: 32, offset: 32, flags: 3)
; CHECK-NEXT: !18 = !{!6}
; CHECK-NEXT: !19 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Derived", file: !9, line: 3, scope: !14, baseType: !15, size: 128, align: 32, offset: 64, flags: 3, elements: !20, runtimeLang: 6, vtableHolder: !15, templateParams: !18, identifier: "MangledBase")
; CHECK-NEXT: !19 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Derived", file: !9, line: 3, scope: !14, baseType: !15, size: 128, align: 32, offset: 64, flags: 3, elements: !20, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !15, templateParams: !18, identifier: "MangledBase")
; CHECK-NEXT: !20 = !{!21}
; CHECK-NEXT: !21 = !MDDerivedType(tag: DW_TAG_inheritance, scope: !19, baseType: !15)
; CHECK-NEXT: !22 = !MDDerivedType(tag: DW_TAG_ptr_to_member_type, baseType: !6, size: 32, align: 32, extraData: !15)
; CHECK-NEXT: !23 = !MDCompositeType(tag: DW_TAG_structure_type)
; CHECK-NEXT: !24 = !MDCompositeType(tag: DW_TAG_structure_type, runtimeLang: DW_LANG_Cobol85)
!16 = !MDCompositeType(tag: DW_TAG_structure_type, name: "MyType", file: !11, line: 2, size: 32, align: 32, identifier: "MangledMyType")
!17 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Base", file: !11, line: 3, scope: !16, size: 128, align: 32, offset: 64, flags: 3, elements: !18, runtimeLang: 6, vtableHolder: !17, templateParams: !20, identifier: "MangledBase")
!17 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Base", file: !11, line: 3, scope: !16, size: 128, align: 32, offset: 64, flags: 3, elements: !18, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !17, templateParams: !20, identifier: "MangledBase")
!18 = !{!19}
!19 = !MDDerivedType(tag: DW_TAG_member, name: "field", file: !11, line: 4, scope: !17, baseType: !7, size: 32, align: 32, offset: 32, flags: 3)
!20 = !{!7}
!21 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Derived", file: !11, line: 3, scope: !16, baseType: !17, size: 128, align: 32, offset: 64, flags: 3, elements: !22, runtimeLang: 6, vtableHolder: !17, templateParams: !20, identifier: "MangledBase")
!21 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Derived", file: !11, line: 3, scope: !16, baseType: !17, size: 128, align: 32, offset: 64, flags: 3, elements: !22, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !17, templateParams: !20, identifier: "MangledBase")
!22 = !{!23}
!23 = !MDDerivedType(tag: DW_TAG_inheritance, scope: !21, baseType: !17)
!24 = !MDDerivedType(tag: DW_TAG_ptr_to_member_type, baseType: !7, size: 32, align: 32, extraData: !17)
!25 = !MDCompositeType(tag: DW_TAG_structure_type)
!26 = !MDCompositeType(tag: DW_TAG_structure_type, runtimeLang: 6)

View File

@ -79,6 +79,7 @@ syn match llvmIdentifier /![-a-zA-Z$._][-a-zA-Z$._0-9]*\ze\s*[=!]/
syn match llvmType /!\zs\a\+\ze\s*(/
syn match llvmConstant /\<DW_TAG_[a-z_]\+\>/
syn match llvmConstant /\<DW_ATE_[a-zA-Z_]\+\>/
syn match llvmConstant /\<DW_LANG_[a-zA-Z0-9_]\+\>/
" Syntax-highlight dejagnu test commands.
syn match llvmSpecialComment /;\s*RUN:.*$/