llvm.org GIT mirror llvm / 4730b90
AsmWriter: MDSubprogram: Recognize DW_VIRTUALITY in 'virtuality' git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229015 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 5 years ago
6 changed file(s) with 38 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
745745 }
746746 DWKEYWORD(TAG, DwarfTag);
747747 DWKEYWORD(ATE, DwarfAttEncoding);
748 DWKEYWORD(VIRTUALITY, DwarfVirtuality);
748749 DWKEYWORD(LANG, DwarfLang);
749750 #undef DWKEYWORD
750751
29482948 struct DwarfAttEncodingField : public MDUnsignedField {
29492949 DwarfAttEncodingField() : MDUnsignedField(0, dwarf::DW_ATE_hi_user) {}
29502950 };
2951 struct DwarfVirtualityField : public MDUnsignedField {
2952 DwarfVirtualityField() : MDUnsignedField(0, dwarf::DW_VIRTUALITY_max) {}
2953 };
29512954 struct DwarfLangField : public MDUnsignedField {
29522955 DwarfLangField() : MDUnsignedField(0, dwarf::DW_LANG_hi_user) {}
29532956 };
30213024 assert(Tag <= Result.Max && "Expected valid DWARF tag");
30223025
30233026 Result.assign(Tag);
3027 Lex.Lex();
3028 return false;
3029 }
3030
3031 template <>
3032 bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
3033 DwarfVirtualityField &Result) {
3034 if (Lex.getKind() == lltok::APSInt)
3035 return ParseMDField(Loc, Name, static_cast(Result));
3036
3037 if (Lex.getKind() != lltok::DwarfVirtuality)
3038 return TokError("expected DWARF virtuality code");
3039
3040 unsigned Virtuality = dwarf::getVirtuality(Lex.getStrVal());
3041 if (!Virtuality)
3042 return TokError("invalid DWARF virtuality code" + Twine(" '") +
3043 Lex.getStrVal() + "'");
3044 assert(Virtuality <= Result.Max && "Expected valid DWARF virtuality code");
3045 Result.assign(Virtuality);
30243046 Lex.Lex();
30253047 return false;
30263048 }
34073429 /// ::= !MDSubprogram(scope: !0, name: "foo", linkageName: "_Zfoo",
34083430 /// file: !1, line: 7, type: !2, isLocal: false,
34093431 /// isDefinition: true, scopeLine: 8, containingType: !3,
3410 /// virtuality: 2, virtualIndex: 10, flags: 11,
3432 /// virtuality: DW_VIRTUALTIY_pure_virtual,
3433 /// virtualIndex: 10, flags: 11,
34113434 /// isOptimized: false, function: void ()* @_Z3foov,
34123435 /// templateParams: !4, declaration: !5, variables: !6)
34133436 bool LLParser::ParseMDSubprogram(MDNode *&Result, bool IsDistinct) {
34223445 OPTIONAL(isDefinition, MDBoolField, (true)); \
34233446 OPTIONAL(scopeLine, LineField, ); \
34243447 OPTIONAL(containingType, MDField, ); \
3425 OPTIONAL(virtuality, MDUnsignedField, (0, dwarf::DW_VIRTUALITY_max)); \
3448 OPTIONAL(virtuality, DwarfVirtualityField, ); \
34263449 OPTIONAL(virtualIndex, MDUnsignedField, (0, UINT32_MAX)); \
34273450 OPTIONAL(flags, MDUnsignedField, (0, UINT32_MAX)); \
34283451 OPTIONAL(isOptimized, MDBoolField, ); \
199199 StringConstant, // "foo"
200200 DwarfTag, // DW_TAG_foo (includes "DW_TAG_")
201201 DwarfAttEncoding, // DW_ATE_foo (includes "DW_ATE_")
202 DwarfVirtuality, // DW_VIRTUALITY_foo (includes "DW_VIRTUALITY_")
202203 DwarfLang, // DW_LANG_foo (includes "DW_LANG_")
203204
204205 // Type valued tokens (TyVal).
15871587 writeMetadataAsOperand(Out, N->getContainingType(), TypePrinter, Machine,
15881588 Context);
15891589 }
1590 if (N->getVirtuality())
1591 Out << FS << "virtuality: " << N->getVirtuality();
1590 if (unsigned V = N->getVirtuality()) {
1591 Out << FS << "virtuality: ";
1592 if (const char *S = dwarf::VirtualityString(V))
1593 Out << S;
1594 else
1595 Out << V;
1596 }
15921597 if (N->getVirtualIndex())
15931598 Out << FS << "virtualIndex: " << N->getVirtualIndex();
15941599 if (N->getFlags())
1414 !6 = distinct !{}
1515 !7 = distinct !{}
1616
17 ; CHECK: !8 = !MDSubprogram(scope: !0, name: "foo", linkageName: "_Zfoov", file: !2, line: 7, type: !3, isLocal: true, isDefinition: false, scopeLine: 8, containingType: !4, virtuality: 2, virtualIndex: 10, flags: 11, isOptimized: true, function: void ()* @_Z3foov, templateParams: !5, declaration: !6, variables: !7)
17 ; CHECK: !8 = !MDSubprogram(scope: !0, name: "foo", linkageName: "_Zfoov", file: !2, line: 7, type: !3, isLocal: true, isDefinition: false, scopeLine: 8, containingType: !4, virtuality: DW_VIRTUALITY_pure_virtual, virtualIndex: 10, flags: 11, isOptimized: true, function: void ()* @_Z3foov, templateParams: !5, declaration: !6, variables: !7)
1818 !8 = !MDSubprogram(scope: !0, name: "foo", linkageName: "_Zfoov",
1919 file: !2, line: 7, type: !3, isLocal: true,
2020 isDefinition: false, scopeLine: 8, containingType: !4,
21 virtuality: 2, virtualIndex: 10, flags: 11,
22 isOptimized: true, function: void ()* @_Z3foov,
21 virtuality: DW_VIRTUALITY_pure_virtual, virtualIndex: 10,
22 flags: 11, isOptimized: true, function: void ()* @_Z3foov,
2323 templateParams: !5, declaration: !6, variables: !7)
2424
2525 ; CHECK: !9 = !MDSubprogram(scope: null, name: "bar", isLocal: false, isDefinition: true, isOptimized: false)
7979 syn match llvmConstant /\/
8080 syn match llvmConstant /\/
8181 syn match llvmConstant /\/
82 syn match llvmConstant /\/
8283
8384 " Syntax-highlight dejagnu test commands.
8485 syn match llvmSpecialComment /;\s*RUN:.*$/