[llvm] r228226 - AsmParser: Split out LineField, NFC

Duncan P. N. Exon Smith dexonsmith at apple.com
Wed Feb 4 14:59:18 PST 2015


Author: dexonsmith
Date: Wed Feb  4 16:59:18 2015
New Revision: 228226

URL: http://llvm.org/viewvc/llvm-project?rev=228226&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/AsmParser/LLParser.cpp

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=228226&r1=228225&r2=228226&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Feb  4 16:59:18 2015
@@ -2945,6 +2945,12 @@ struct MDUnsignedField : public MDFieldI
   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, S
 }
 
 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(MD
 ///   ::= !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();





More information about the llvm-commits mailing list