llvm.org GIT mirror llvm / 65e1227
AsmWriter: MDCompositeType: Recognize DW_LANG in 'runtimeLang' git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229010 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 4 years ago
6 changed file(s) with 60 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
745745 }
746746 DWKEYWORD(TAG, DwarfTag);
747747 DWKEYWORD(ATE, DwarfAttEncoding);
748 DWKEYWORD(LANG, DwarfLang);
748749 #undef DWKEYWORD
749750
750751 // Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by
29482948 struct DwarfAttEncodingField : public MDUnsignedField {
29492949 DwarfAttEncodingField() : MDUnsignedField(0, dwarf::DW_ATE_hi_user) {}
29502950 };
2951 struct DwarfLangField : public MDUnsignedField {
2952 DwarfLangField() : MDUnsignedField(0, dwarf::DW_LANG_hi_user) {}
2953 };
29512954
29522955 struct MDSignedField : public MDFieldImpl {
29532956 int64_t Min;
29592962 : ImplTy(Default), Min(Min), Max(Max) {}
29602963 };
29612964
2965 struct MDBoolField : public MDFieldImpl {
2966 MDBoolField(bool Default = false) : ImplTy(Default) {}
2967 };
29622968 struct MDField : public MDFieldImpl {
29632969 MDField() : ImplTy(nullptr) {}
29642970 };
30123018 assert(Tag <= Result.Max && "Expected valid DWARF tag");
30133019
30143020 Result.assign(Tag);
3021 Lex.Lex();
3022 return false;
3023 }
3024
3025 template <>
3026 bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfLangField &Result) {
3027 if (Lex.getKind() == lltok::APSInt)
3028 return ParseMDField(Loc, Name, static_cast(Result));
3029
3030 if (Lex.getKind() != lltok::DwarfLang)
3031 return TokError("expected DWARF language");
3032
3033 unsigned Lang = dwarf::getLanguage(Lex.getStrVal());
3034 if (!Lang)
3035 return TokError("invalid DWARF language" + Twine(" '") + Lex.getStrVal() +
3036 "'");
3037 assert(Lang <= Result.Max && "Expected valid DWARF language");
3038 Result.assign(Lang);
30153039 Lex.Lex();
30163040 return false;
30173041 }
30513075 Result.assign(S.getExtValue());
30523076 assert(Result.Val >= Result.Min && "Expected value in range");
30533077 assert(Result.Val <= Result.Max && "Expected value in range");
3078 Lex.Lex();
3079 return false;
3080 }
3081
3082 template <>
3083 bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDBoolField &Result) {
3084 switch (Lex.getKind()) {
3085 default:
3086 return TokError("expected 'true' or 'false'");
3087 case lltok::kw_true:
3088 Result.assign(true);
3089 break;
3090 case lltok::kw_false:
3091 Result.assign(false);
3092 break;
3093 }
30543094 Lex.Lex();
30553095 return false;
30563096 }
32723312 OPTIONAL(offset, MDUnsignedField, (0, UINT32_MAX)); \
32733313 OPTIONAL(flags, MDUnsignedField, (0, UINT32_MAX)); \
32743314 OPTIONAL(elements, MDField, ); \
3275 OPTIONAL(runtimeLang, MDUnsignedField, (0, UINT32_MAX)); \
3315 OPTIONAL(runtimeLang, DwarfLangField, ); \
32763316 OPTIONAL(vtableHolder, MDField, ); \
32773317 OPTIONAL(templateParams, MDField, ); \
32783318 OPTIONAL(identifier, MDStringField, );
199199 StringConstant, // "foo"
200200 DwarfTag, // DW_TAG_foo (includes "DW_TAG_")
201201 DwarfAttEncoding, // DW_ATE_foo (includes "DW_ATE_")
202 DwarfLang, // DW_LANG_foo (includes "DW_LANG_")
202203
203204 // Type valued tokens (TyVal).
204205 Type,
14601460 writeMetadataAsOperand(Out, N->getElements(), TypePrinter, Machine,
14611461 Context);
14621462 }
1463 if (N->getRuntimeLang())
1464 Out << FS << "runtimeLang: " << N->getRuntimeLang();
1463 if (unsigned Lang = N->getRuntimeLang()) {
1464 Out << FS << "runtimeLang: ";
1465 if (const char *S = dwarf::LanguageString(Lang))
1466 Out << S;
1467 else
1468 Out << Lang;
1469 }
1470
14651471 if (N->getVTableHolder()) {
14661472 Out << FS << "vtableHolder: ";
14671473 writeMetadataAsOperand(Out, N->getVTableHolder(), TypePrinter, Machine,
0 ; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
11 ; RUN: verify-uselistorder %s
22
3 ; 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}
4 !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}
3 ; 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}
4 !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}
55
66 ; CHECK: !0 = !MDSubrange(count: 3)
77 ; CHECK-NEXT: !1 = !MDSubrange(count: 3, lowerBound: 4)
4040 !15 = !MDDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32, align: 32)
4141
4242 ; CHECK-NEXT: !14 = !MDCompositeType(tag: DW_TAG_structure_type, name: "MyType", file: !9, line: 2, size: 32, align: 32, identifier: "MangledMyType")
43 ; 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")
43 ; 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")
4444 ; CHECK-NEXT: !16 = !{!17}
4545 ; 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)
4646 ; CHECK-NEXT: !18 = !{!6}
47 ; 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")
47 ; 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")
4848 ; CHECK-NEXT: !20 = !{!21}
4949 ; CHECK-NEXT: !21 = !MDDerivedType(tag: DW_TAG_inheritance, scope: !19, baseType: !15)
5050 ; CHECK-NEXT: !22 = !MDDerivedType(tag: DW_TAG_ptr_to_member_type, baseType: !6, size: 32, align: 32, extraData: !15)
5151 ; CHECK-NEXT: !23 = !MDCompositeType(tag: DW_TAG_structure_type)
52 ; CHECK-NEXT: !24 = !MDCompositeType(tag: DW_TAG_structure_type, runtimeLang: DW_LANG_Cobol85)
5253 !16 = !MDCompositeType(tag: DW_TAG_structure_type, name: "MyType", file: !11, line: 2, size: 32, align: 32, identifier: "MangledMyType")
53 !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")
54 !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")
5455 !18 = !{!19}
5556 !19 = !MDDerivedType(tag: DW_TAG_member, name: "field", file: !11, line: 4, scope: !17, baseType: !7, size: 32, align: 32, offset: 32, flags: 3)
5657 !20 = !{!7}
57 !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")
58 !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")
5859 !22 = !{!23}
5960 !23 = !MDDerivedType(tag: DW_TAG_inheritance, scope: !21, baseType: !17)
6061 !24 = !MDDerivedType(tag: DW_TAG_ptr_to_member_type, baseType: !7, size: 32, align: 32, extraData: !17)
6162 !25 = !MDCompositeType(tag: DW_TAG_structure_type)
63 !26 = !MDCompositeType(tag: DW_TAG_structure_type, runtimeLang: 6)
7878 syn match llvmType /!\zs\a\+\ze\s*(/
7979 syn match llvmConstant /\/
8080 syn match llvmConstant /\/
81 syn match llvmConstant /\/
8182
8283 " Syntax-highlight dejagnu test commands.
8384 syn match llvmSpecialComment /;\s*RUN:.*$/