forked from OSchip/llvm-project
AsmWriter: MDSubprogram: Recognize DW_VIRTUALITY in 'virtuality'
llvm-svn: 229015
This commit is contained in:
parent
19fc5ed7db
commit
890533e987
|
@ -746,6 +746,7 @@ lltok::Kind LLLexer::LexIdentifier() {
|
|||
}
|
||||
DWKEYWORD(TAG, DwarfTag);
|
||||
DWKEYWORD(ATE, DwarfAttEncoding);
|
||||
DWKEYWORD(VIRTUALITY, DwarfVirtuality);
|
||||
DWKEYWORD(LANG, DwarfLang);
|
||||
#undef DWKEYWORD
|
||||
|
||||
|
|
|
@ -2949,6 +2949,9 @@ struct DwarfTagField : public MDUnsignedField {
|
|||
struct DwarfAttEncodingField : public MDUnsignedField {
|
||||
DwarfAttEncodingField() : MDUnsignedField(0, dwarf::DW_ATE_hi_user) {}
|
||||
};
|
||||
struct DwarfVirtualityField : public MDUnsignedField {
|
||||
DwarfVirtualityField() : MDUnsignedField(0, dwarf::DW_VIRTUALITY_max) {}
|
||||
};
|
||||
struct DwarfLangField : public MDUnsignedField {
|
||||
DwarfLangField() : MDUnsignedField(0, dwarf::DW_LANG_hi_user) {}
|
||||
};
|
||||
|
@ -3026,6 +3029,25 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result) {
|
|||
return false;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
|
||||
DwarfVirtualityField &Result) {
|
||||
if (Lex.getKind() == lltok::APSInt)
|
||||
return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result));
|
||||
|
||||
if (Lex.getKind() != lltok::DwarfVirtuality)
|
||||
return TokError("expected DWARF virtuality code");
|
||||
|
||||
unsigned Virtuality = dwarf::getVirtuality(Lex.getStrVal());
|
||||
if (!Virtuality)
|
||||
return TokError("invalid DWARF virtuality code" + Twine(" '") +
|
||||
Lex.getStrVal() + "'");
|
||||
assert(Virtuality <= Result.Max && "Expected valid DWARF virtuality code");
|
||||
Result.assign(Virtuality);
|
||||
Lex.Lex();
|
||||
return false;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfLangField &Result) {
|
||||
if (Lex.getKind() == lltok::APSInt)
|
||||
|
@ -3408,7 +3430,8 @@ bool LLParser::ParseMDCompileUnit(MDNode *&Result, bool IsDistinct) {
|
|||
/// ::= !MDSubprogram(scope: !0, name: "foo", linkageName: "_Zfoo",
|
||||
/// file: !1, line: 7, type: !2, isLocal: false,
|
||||
/// isDefinition: true, scopeLine: 8, containingType: !3,
|
||||
/// virtuality: 2, virtualIndex: 10, flags: 11,
|
||||
/// virtuality: DW_VIRTUALTIY_pure_virtual,
|
||||
/// virtualIndex: 10, flags: 11,
|
||||
/// isOptimized: false, function: void ()* @_Z3foov,
|
||||
/// templateParams: !4, declaration: !5, variables: !6)
|
||||
bool LLParser::ParseMDSubprogram(MDNode *&Result, bool IsDistinct) {
|
||||
|
@ -3423,7 +3446,7 @@ bool LLParser::ParseMDSubprogram(MDNode *&Result, bool IsDistinct) {
|
|||
OPTIONAL(isDefinition, MDBoolField, (true)); \
|
||||
OPTIONAL(scopeLine, LineField, ); \
|
||||
OPTIONAL(containingType, MDField, ); \
|
||||
OPTIONAL(virtuality, MDUnsignedField, (0, dwarf::DW_VIRTUALITY_max)); \
|
||||
OPTIONAL(virtuality, DwarfVirtualityField, ); \
|
||||
OPTIONAL(virtualIndex, MDUnsignedField, (0, UINT32_MAX)); \
|
||||
OPTIONAL(flags, MDUnsignedField, (0, UINT32_MAX)); \
|
||||
OPTIONAL(isOptimized, MDBoolField, ); \
|
||||
|
|
|
@ -200,6 +200,7 @@ namespace lltok {
|
|||
StringConstant, // "foo"
|
||||
DwarfTag, // DW_TAG_foo (includes "DW_TAG_")
|
||||
DwarfAttEncoding, // DW_ATE_foo (includes "DW_ATE_")
|
||||
DwarfVirtuality, // DW_VIRTUALITY_foo (includes "DW_VIRTUALITY_")
|
||||
DwarfLang, // DW_LANG_foo (includes "DW_LANG_")
|
||||
|
||||
// Type valued tokens (TyVal).
|
||||
|
|
|
@ -1588,8 +1588,13 @@ static void writeMDSubprogram(raw_ostream &Out, const MDSubprogram *N,
|
|||
writeMetadataAsOperand(Out, N->getContainingType(), TypePrinter, Machine,
|
||||
Context);
|
||||
}
|
||||
if (N->getVirtuality())
|
||||
Out << FS << "virtuality: " << N->getVirtuality();
|
||||
if (unsigned V = N->getVirtuality()) {
|
||||
Out << FS << "virtuality: ";
|
||||
if (const char *S = dwarf::VirtualityString(V))
|
||||
Out << S;
|
||||
else
|
||||
Out << V;
|
||||
}
|
||||
if (N->getVirtualIndex())
|
||||
Out << FS << "virtualIndex: " << N->getVirtualIndex();
|
||||
if (N->getFlags())
|
||||
|
|
|
@ -15,12 +15,12 @@ declare void @_Z3foov()
|
|||
!6 = distinct !{}
|
||||
!7 = distinct !{}
|
||||
|
||||
; 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)
|
||||
; 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)
|
||||
!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,
|
||||
virtuality: DW_VIRTUALITY_pure_virtual, virtualIndex: 10,
|
||||
flags: 11, isOptimized: true, function: void ()* @_Z3foov,
|
||||
templateParams: !5, declaration: !6, variables: !7)
|
||||
|
||||
; CHECK: !9 = !MDSubprogram(scope: null, name: "bar", isLocal: false, isDefinition: true, isOptimized: false)
|
||||
|
|
|
@ -80,6 +80,7 @@ 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_]\+\>/
|
||||
syn match llvmConstant /\<DW_VIRTUALITY_[a-z_]\+\>/
|
||||
|
||||
" Syntax-highlight dejagnu test commands.
|
||||
syn match llvmSpecialComment /;\s*RUN:.*$/
|
||||
|
|
Loading…
Reference in New Issue