diff options
author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2016-08-23 17:14:32 +0000 |
---|---|---|
committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2016-08-23 17:14:32 +0000 |
commit | 9feaa97adaf0530405dcc7201cf05e3f83ef91be (patch) | |
tree | 59a13ecadcbefd86639b42fea5cf7cc192c30792 /lib/TableGen | |
parent | f98248330cb1eb499c4d4c1f1ea46530a42089e7 (diff) |
Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D23789
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279535 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/TableGen')
-rw-r--r-- | lib/TableGen/Record.cpp | 23 | ||||
-rw-r--r-- | lib/TableGen/TGLexer.cpp | 11 | ||||
-rw-r--r-- | lib/TableGen/TGParser.cpp | 33 |
3 files changed, 34 insertions, 33 deletions
diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index 66fbc9a8c96..7f02c3189f3 100644 --- a/lib/TableGen/Record.cpp +++ b/lib/TableGen/Record.cpp @@ -15,14 +15,15 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/Hashing.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringMap.h" -#include "llvm/Support/DataTypes.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/Format.h" #include "llvm/TableGen/Error.h" +#include <cassert> +#include <cstdint> +#include <new> using namespace llvm; @@ -51,6 +52,7 @@ public: using llvm::hash_value; return hash_value(Value.str()); } + private: std::string data; }; @@ -61,21 +63,24 @@ template<> struct DenseMapInfo<TableGenStringKey> { TableGenStringKey Empty("<<<EMPTY KEY>>>"); return Empty; } + static inline TableGenStringKey getTombstoneKey() { TableGenStringKey Tombstone("<<<TOMBSTONE KEY>>>"); return Tombstone; } + static unsigned getHashValue(const TableGenStringKey& Val) { using llvm::hash_value; return hash_value(Val); } + static bool isEqual(const TableGenStringKey& LHS, const TableGenStringKey& RHS) { return LHS.str() == RHS.str(); } }; -} // namespace llvm +} // end namespace llvm //===----------------------------------------------------------------------===// // Type implementations @@ -203,7 +208,6 @@ RecTy *llvm::resolveTypes(RecTy *T1, RecTy *T2) { return nullptr; } - //===----------------------------------------------------------------------===// // Initializer implementations //===----------------------------------------------------------------------===// @@ -1320,7 +1324,6 @@ Init *VarInit::resolveListElementReference(Record &R, return nullptr; } - RecTy *VarInit::getFieldType(const std::string &FieldName) const { if (RecordRecTy *RTy = dyn_cast<RecordRecTy>(getType())) if (const RecordVal *RV = RTy->getRecord()->getValue(FieldName)) @@ -1447,7 +1450,6 @@ Init *DefInit::getFieldInit(Record &R, const RecordVal *RV, return Def->getValue(FieldName)->getValue(); } - std::string DefInit::getAsString() const { return Def->getName(); } @@ -1572,7 +1574,6 @@ Init *DagInit::resolveReferences(Record &R, const RecordVal *RV) const { return const_cast<DagInit *>(this); } - std::string DagInit::getAsString() const { std::string Result = "(" + Val->getAsString(); if (!ValName.empty()) @@ -1588,7 +1589,6 @@ std::string DagInit::getAsString() const { return Result + ")"; } - //===----------------------------------------------------------------------===// // Other implementations //===----------------------------------------------------------------------===// @@ -1628,7 +1628,7 @@ void Record::init() { // Every record potentially has a def at the top. This value is // replaced with the top-level def name at instantiation time. - RecordVal DN("NAME", StringRecTy::get(), 0); + RecordVal DN("NAME", StringRecTy::get(), false); addValue(DN); } @@ -1737,7 +1737,6 @@ Init *Record::getValueInit(StringRef FieldName) const { return R->getValue(); } - std::string Record::getValueAsString(StringRef FieldName) const { const RecordVal *R = getValue(FieldName); if (!R || !R->getValue()) @@ -1884,7 +1883,6 @@ DagInit *Record::getValueAsDag(StringRef FieldName) const { FieldName + "' does not have a dag initializer!"); } - LLVM_DUMP_METHOD void MultiClass::dump() const { errs() << "Record:\n"; Rec.dump(); @@ -1894,7 +1892,6 @@ LLVM_DUMP_METHOD void MultiClass::dump() const { Proto->dump(); } - LLVM_DUMP_METHOD void RecordKeeper::dump() const { errs() << *this; } raw_ostream &llvm::operator<<(raw_ostream &OS, const RecordKeeper &RK) { diff --git a/lib/TableGen/TGLexer.cpp b/lib/TableGen/TGLexer.cpp index acf1fb20afa..c526fc05d08 100644 --- a/lib/TableGen/TGLexer.cpp +++ b/lib/TableGen/TGLexer.cpp @@ -15,11 +15,13 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Twine.h" #include "llvm/Config/config.h" // for strtoull()/strtoll() define +#include "llvm/Support/Compiler.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/SourceMgr.h" #include "llvm/TableGen/Error.h" #include <cctype> #include <cerrno> +#include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> @@ -246,7 +248,6 @@ tgtok::TokKind TGLexer::LexVarName() { return tgtok::VarName; } - tgtok::TokKind TGLexer::LexIdentifier() { // The first letter is [a-zA-Z_#]. const char *IdentStart = TokStart; @@ -301,7 +302,6 @@ bool TGLexer::LexInclude() { std::string Filename = CurStrVal; std::string IncludedFile; - CurBuffer = SrcMgr.AddIncludeFile(Filename, SMLoc::getFromPointer(CurPtr), IncludedFile); if (!CurBuffer) { @@ -326,7 +326,7 @@ bool TGLexer::LexInclude() { void TGLexer::SkipBCPLComment() { ++CurPtr; // skip the second slash. - while (1) { + while (true) { switch (*CurPtr) { case '\n': case '\r': @@ -348,7 +348,7 @@ bool TGLexer::SkipCComment() { ++CurPtr; // skip the star. unsigned CommentDepth = 1; - while (1) { + while (true) { int CurChar = getNextChar(); switch (CurChar) { case EOF: @@ -436,7 +436,7 @@ tgtok::TokKind TGLexer::LexBracket() { return tgtok::l_square; ++CurPtr; const char *CodeStart = CurPtr; - while (1) { + while (true) { int Char = getNextChar(); if (Char == EOF) break; @@ -485,4 +485,3 @@ tgtok::TokKind TGLexer::LexExclaim() { return Kind != tgtok::Error ? Kind : ReturnError(Start-1, "Unknown operator"); } - diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index 34e90925e92..0a6752bb26d 100644 --- a/lib/TableGen/TGParser.cpp +++ b/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"); } - |