[llvm] r229015 - AsmWriter: MDSubprogram: Recognize DW_VIRTUALITY in 'virtuality'
Duncan P. N. Exon Smith
dexonsmith at apple.com
Thu Feb 12 17:28:17 PST 2015
Author: dexonsmith
Date: Thu Feb 12 19:28:16 2015
New Revision: 229015
URL: http://llvm.org/viewvc/llvm-project?rev=229015&view=rev
Log:
AsmWriter: MDSubprogram: Recognize DW_VIRTUALITY in 'virtuality'
Modified:
llvm/trunk/lib/AsmParser/LLLexer.cpp
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/AsmParser/LLToken.h
llvm/trunk/lib/IR/AsmWriter.cpp
llvm/trunk/test/Assembler/mdsubprogram.ll
llvm/trunk/utils/vim/llvm.vim
Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=229015&r1=229014&r2=229015&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLLexer.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLLexer.cpp Thu Feb 12 19:28:16 2015
@@ -746,6 +746,7 @@ lltok::Kind LLLexer::LexIdentifier() {
}
DWKEYWORD(TAG, DwarfTag);
DWKEYWORD(ATE, DwarfAttEncoding);
+ DWKEYWORD(VIRTUALITY, DwarfVirtuality);
DWKEYWORD(LANG, DwarfLang);
#undef DWKEYWORD
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=229015&r1=229014&r2=229015&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Thu Feb 12 19:28:16 2015
@@ -2949,6 +2949,9 @@ struct DwarfTagField : public MDUnsigned
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) {}
};
@@ -3027,6 +3030,25 @@ bool LLParser::ParseMDField(LocTy Loc, S
}
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)
return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result));
@@ -3408,7 +3430,8 @@ bool LLParser::ParseMDCompileUnit(MDNode
/// ::= !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
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, ); \
Modified: llvm/trunk/lib/AsmParser/LLToken.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=229015&r1=229014&r2=229015&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLToken.h (original)
+++ llvm/trunk/lib/AsmParser/LLToken.h Thu Feb 12 19:28:16 2015
@@ -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).
Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=229015&r1=229014&r2=229015&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Thu Feb 12 19:28:16 2015
@@ -1588,8 +1588,13 @@ static void writeMDSubprogram(raw_ostrea
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())
Modified: llvm/trunk/test/Assembler/mdsubprogram.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/mdsubprogram.ll?rev=229015&r1=229014&r2=229015&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/mdsubprogram.ll (original)
+++ llvm/trunk/test/Assembler/mdsubprogram.ll Thu Feb 12 19:28:16 2015
@@ -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)
Modified: llvm/trunk/utils/vim/llvm.vim
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/vim/llvm.vim?rev=229015&r1=229014&r2=229015&view=diff
==============================================================================
--- llvm/trunk/utils/vim/llvm.vim (original)
+++ llvm/trunk/utils/vim/llvm.vim Thu Feb 12 19:28:16 2015
@@ -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:.*$/
More information about the llvm-commits
mailing list