summaryrefslogtreecommitdiff
path: root/lib/AsmParser
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2016-03-31 23:56:58 +0000
committerAdrian Prantl <aprantl@apple.com>2016-03-31 23:56:58 +0000
commit39bb84a09793331da8e56e913026e0829f5c1620 (patch)
treeeefaa90b96539da5c8f202e6e0187d86d5353f60 /lib/AsmParser
parentff85de827737247cad3a9387e0be9f29458f5218 (diff)
Move the DebugEmissionKind enum from DIBuilder into DICompileUnit.
This mostly cosmetic patch moves the DebugEmissionKind enum from DIBuilder into DICompileUnit. DIBuilder is not the right place for this enum to live in — a metadata consumer should not have to include DIBuilder.h. I also added a Verifier check that checks that the emission kind of a DICompileUnit is actually legal. http://reviews.llvm.org/D18612 <rdar://problem/25427165> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265077 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser')
-rw-r--r--lib/AsmParser/LLLexer.cpp6
-rw-r--r--lib/AsmParser/LLParser.cpp26
-rw-r--r--lib/AsmParser/LLToken.h1
3 files changed, 30 insertions, 3 deletions
diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp
index 46ffc642ec6..5ad5ddd52a0 100644
--- a/lib/AsmParser/LLLexer.cpp
+++ b/lib/AsmParser/LLLexer.cpp
@@ -787,11 +787,15 @@ lltok::Kind LLLexer::LexIdentifier() {
DWKEYWORD(OP, DwarfOp);
DWKEYWORD(MACINFO, DwarfMacinfo);
#undef DWKEYWORD
-
if (Keyword.startswith("DIFlag")) {
StrVal.assign(Keyword.begin(), Keyword.end());
return lltok::DIFlag;
}
+ if (Keyword == "NoDebug" || Keyword == "FullDebug" ||
+ Keyword == "LineTablesOnly") {
+ StrVal.assign(Keyword.begin(), Keyword.end());
+ return lltok::EmissionKind;
+ }
// Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by
// the CFE to avoid forcing it to deal with 64-bit numbers.
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 39c613599e6..e72686d045c 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -3260,6 +3260,9 @@ struct DwarfVirtualityField : public MDUnsignedField {
struct DwarfLangField : public MDUnsignedField {
DwarfLangField() : MDUnsignedField(0, dwarf::DW_LANG_hi_user) {}
};
+struct EmissionKindField : public MDUnsignedField {
+ EmissionKindField() : MDUnsignedField(0, DICompileUnit::LastEmissionKind) {}
+};
struct DIFlagField : public MDUnsignedField {
DIFlagField() : MDUnsignedField(0, UINT32_MAX) {}
@@ -3400,6 +3403,24 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfLangField &Result) {
}
template <>
+bool LLParser::ParseMDField(LocTy Loc, StringRef Name, EmissionKindField &Result) {
+ if (Lex.getKind() == lltok::APSInt)
+ return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result));
+
+ if (Lex.getKind() != lltok::EmissionKind)
+ return TokError("expected emission kind");
+
+ auto Kind = DICompileUnit::getEmissionKind(Lex.getStrVal());
+ if (!Kind)
+ return TokError("invalid emission kind" + Twine(" '") + Lex.getStrVal() +
+ "'");
+ assert(*Kind <= Result.Max && "Expected valid emission kind");
+ Result.assign(*Kind);
+ Lex.Lex();
+ return false;
+}
+
+template <>
bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
DwarfAttEncodingField &Result) {
if (Lex.getKind() == lltok::APSInt)
@@ -3772,7 +3793,8 @@ bool LLParser::ParseDIFile(MDNode *&Result, bool IsDistinct) {
/// ParseDICompileUnit:
/// ::= !DICompileUnit(language: DW_LANG_C99, file: !0, producer: "clang",
/// isOptimized: true, flags: "-O2", runtimeVersion: 1,
-/// splitDebugFilename: "abc.debug", emissionKind: 1,
+/// splitDebugFilename: "abc.debug",
+/// emissionKind: FullDebug,
/// enums: !1, retainedTypes: !2, subprograms: !3,
/// globals: !4, imports: !5, macros: !6, dwoId: 0x0abcd)
bool LLParser::ParseDICompileUnit(MDNode *&Result, bool IsDistinct) {
@@ -3787,7 +3809,7 @@ bool LLParser::ParseDICompileUnit(MDNode *&Result, bool IsDistinct) {
OPTIONAL(flags, MDStringField, ); \
OPTIONAL(runtimeVersion, MDUnsignedField, (0, UINT32_MAX)); \
OPTIONAL(splitDebugFilename, MDStringField, ); \
- OPTIONAL(emissionKind, MDUnsignedField, (0, UINT32_MAX)); \
+ OPTIONAL(emissionKind, EmissionKindField, ); \
OPTIONAL(enums, MDField, ); \
OPTIONAL(retainedTypes, MDField, ); \
OPTIONAL(subprograms, MDField, ); \
diff --git a/lib/AsmParser/LLToken.h b/lib/AsmParser/LLToken.h
index c5a74901985..4df922b1c78 100644
--- a/lib/AsmParser/LLToken.h
+++ b/lib/AsmParser/LLToken.h
@@ -221,6 +221,7 @@ namespace lltok {
DwarfAttEncoding, // DW_ATE_foo
DwarfVirtuality, // DW_VIRTUALITY_foo
DwarfLang, // DW_LANG_foo
+ EmissionKind, // lineTablesOnly
DwarfOp, // DW_OP_foo
DIFlag, // DIFlagFoo
DwarfMacinfo, // DW_MACINFO_foo