summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-04 22:59:18 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-04 22:59:18 +0000
commit9c93dc6453457100fe0697f063a04bf63ed62da1 (patch)
tree5712c789461b8e6af52150bd17f56c671979f048
parent68292c96da4ac6fd036c5bc2425d5b022642463c (diff)
downloadbcm5719-llvm-9c93dc6453457100fe0697f063a04bf63ed62da1.tar.gz
bcm5719-llvm-9c93dc6453457100fe0697f063a04bf63ed62da1.zip
AsmParser: Split out LineField, NFC
Split out `LineField`, which restricts the legal line numbers. This will make it easier to be consistent between different node parsers. llvm-svn: 228226
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 9e02e9edb6a..d652f59acb1 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -2945,6 +2945,12 @@ struct MDUnsignedField : public MDFieldImpl<uint64_t> {
MDUnsignedField(uint64_t Default = 0, uint64_t Max = UINT64_MAX)
: ImplTy(Default), Max(Max) {}
};
+struct LineField : public MDUnsignedField {
+ LineField() : MDUnsignedField(0, UINT32_MAX >> 8) {}
+};
+struct ColumnField : public MDUnsignedField {
+ ColumnField() : MDUnsignedField(0, UINT16_MAX) {}
+};
struct DwarfTagField : public MDUnsignedField {
DwarfTagField() : MDUnsignedField(0, ~0u >> 16) {}
};
@@ -2979,6 +2985,15 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
}
template <>
+bool LLParser::ParseMDField(LocTy Loc, StringRef Name, LineField &Result) {
+ return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result));
+}
+template <>
+bool LLParser::ParseMDField(LocTy Loc, StringRef Name, ColumnField &Result) {
+ return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result));
+}
+
+template <>
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result) {
if (Lex.getKind() == lltok::APSInt)
return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result));
@@ -3105,8 +3120,8 @@ bool LLParser::ParseSpecializedMDNode(MDNode *&N, bool IsDistinct) {
/// ::= !MDLocation(line: 43, column: 8, scope: !5, inlinedAt: !6)
bool LLParser::ParseMDLocation(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
- OPTIONAL(line, MDUnsignedField, (0, ~0u >> 8)); \
- OPTIONAL(column, MDUnsignedField, (0, ~0u >> 16)); \
+ OPTIONAL(line, LineField, ); \
+ OPTIONAL(column, ColumnField, ); \
REQUIRED(scope, MDField, ); \
OPTIONAL(inlinedAt, MDField, );
PARSE_MD_FIELDS();
OpenPOWER on IntegriCloud