diff options
Diffstat (limited to 'llvm/lib/TableGen/TGParser.cpp')
-rw-r--r-- | llvm/lib/TableGen/TGParser.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index 34e90925e92..0a6752bb26d 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -12,11 +12,19 @@ //===----------------------------------------------------------------------===// #include "TGParser.h" +#include "llvm/ADT/None.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/TableGen/Record.h" #include <algorithm> +#include <cassert> +#include <cstdint> + using namespace llvm; //===----------------------------------------------------------------------===// @@ -24,10 +32,12 @@ using namespace llvm; //===----------------------------------------------------------------------===// namespace llvm { + struct SubClassReference { SMRange RefRange; Record *Rec; std::vector<Init*> TemplateArgs; + SubClassReference() : Rec(nullptr) {} bool isInvalid() const { return Rec == nullptr; } @@ -37,6 +47,7 @@ struct SubMultiClassReference { SMRange RefRange; MultiClass *MC; std::vector<Init*> TemplateArgs; + SubMultiClassReference() : MC(nullptr) {} bool isInvalid() const { return MC == nullptr; } @@ -130,7 +141,7 @@ bool TGParser::SetValue(Record *CurRec, SMLoc Loc, Init *ValName, } if (RV->setValue(V)) { - std::string InitType = ""; + std::string InitType; if (BitsInit *BI = dyn_cast<BitsInit>(V)) InitType = (Twine("' of type bit initializer with length ") + Twine(BI->getNumBits())).str(); @@ -644,7 +655,6 @@ bool TGParser::ParseOptionalBitList(std::vector<unsigned> &Ranges) { return false; } - /// ParseType - Parse and return a tblgen type. This returns null on error. /// /// Type ::= STRING // string type @@ -1110,7 +1120,6 @@ RecTy *TGParser::ParseOperatorType() { return Type; } - /// ParseSimpleValue - Parse a tblgen value. This returns null on error. /// /// SimpleValue ::= IDValue @@ -1465,7 +1474,7 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType, IDParseMode Mode) { if (!Result) return nullptr; // Parse the suffixes now if present. - while (1) { + while (true) { switch (Lex.getCode()) { default: return Result; case tgtok::l_brace: { @@ -1591,7 +1600,7 @@ std::vector<std::pair<llvm::Init*, std::string> > TGParser::ParseDagArgList(Record *CurRec) { std::vector<std::pair<llvm::Init*, std::string> > Result; - while (1) { + while (true) { // DagArg ::= VARNAME if (Lex.getCode() == tgtok::VarName) { // A missing value is treated like '?'. @@ -1623,7 +1632,6 @@ TGParser::ParseDagArgList(Record *CurRec) { return Result; } - /// ParseValueList - Parse a comma separated list of values, returning them as a /// vector. Note that this always expects to be able to parse at least one /// value. It returns an empty list if this is not possible. @@ -1674,7 +1682,6 @@ std::vector<Init*> TGParser::ParseValueList(Record *CurRec, Record *ArgsRec, return Result; } - /// ParseDeclaration - Read a declaration, returning the name of field ID, or an /// empty string on error. This can happen in a number of different context's, /// including within a def or in the template args for a def (which which case @@ -1848,7 +1855,6 @@ bool TGParser::ParseTemplateArgList(Record *CurRec) { return false; } - /// ParseBodyItem - Parse a single item at within the body of a def or class. /// /// BodyItem ::= Declaration ';' @@ -1951,7 +1957,7 @@ bool TGParser::ParseObjectBody(Record *CurRec) { // Read all of the subclasses. SubClassReference SubClass = ParseSubClassReference(CurRec, false); - while (1) { + while (true) { // Check for error. if (!SubClass.Rec) return true; @@ -2142,7 +2148,7 @@ bool TGParser::ParseClass() { std::vector<LetRecord> TGParser::ParseLetList() { std::vector<LetRecord> Result; - while (1) { + while (true) { if (Lex.getCode() != tgtok::Id) { TokError("expected identifier in let definition"); return std::vector<LetRecord>(); @@ -2264,7 +2270,7 @@ bool TGParser::ParseMultiClass() { // Read all of the submulticlasses. SubMultiClassReference SubMultiClass = ParseSubMultiClassReference(CurMultiClass); - while (1) { + while (true) { // Check for error. if (!SubMultiClass.MC) return true; @@ -2519,7 +2525,7 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) { SMLoc SubClassLoc = Lex.getLoc(); SubClassReference Ref = ParseSubClassReference(nullptr, true); - while (1) { + while (true) { if (!Ref.Rec) return true; // To instantiate a multiclass, we need to first get the multiclass, then @@ -2589,7 +2595,7 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) { // Process all the classes to inherit as if they were part of a // regular 'def' and inherit all record values. SubClassReference SubClass = ParseSubClassReference(nullptr, false); - while (1) { + while (true) { // Check for error. if (!SubClass.Rec) return true; @@ -2664,4 +2670,3 @@ bool TGParser::ParseFile() { return TokError("Unexpected input at top level"); } - |