Index: lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp =================================================================== --- lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -20,20 +20,31 @@ //===----------------------------------------------------------------------===// #include "Interpreter.h" +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/Config/config.h" // Detect libffi +#include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.h" -#include "llvm/IR/Module.h" +#include "llvm/IR/Function.h" +#include "llvm/IR/Type.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Mutex.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Support/UniqueLock.h" +#include #include #include +#include #include #include #include +#include +#include +#include #ifdef HAVE_FFI_CALL #ifdef HAVE_FFI_H @@ -290,7 +301,6 @@ return GenericValue(); } - //===----------------------------------------------------------------------===// // Functions "exported" to the running application... // @@ -331,7 +341,7 @@ // close enough for now. GenericValue GV; GV.IntVal = APInt(32, strlen(FmtStr)); - while (1) { + while (true) { switch (*FmtStr) { case 0: return GV; // Null terminator... default: // Normal nonspecial character Index: lib/IR/ValueSymbolTable.cpp =================================================================== --- lib/IR/ValueSymbolTable.cpp +++ lib/IR/ValueSymbolTable.cpp @@ -15,8 +15,13 @@ #include "llvm/ADT/SmallString.h" #include "llvm/IR/GlobalValue.h" #include "llvm/IR/Type.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" +#include +#include + using namespace llvm; #define DEBUG_TYPE "valuesymtab" @@ -35,7 +40,7 @@ ValueName *ValueSymbolTable::makeUniqueName(Value *V, SmallString<256> &UniqueName) { unsigned BaseSize = UniqueName.size(); - while (1) { + while (true) { // Trim any suffix off and append the next number. UniqueName.resize(BaseSize); raw_svector_ostream S(UniqueName); @@ -94,7 +99,6 @@ return makeUniqueName(V, UniqueName); } - // dump - print out the symbol table // LLVM_DUMP_METHOD void ValueSymbolTable::dump() const { Index: lib/MC/MCDisassembler/Disassembler.cpp =================================================================== --- lib/MC/MCDisassembler/Disassembler.cpp +++ lib/MC/MCDisassembler/Disassembler.cpp @@ -9,6 +9,9 @@ #include "Disassembler.h" #include "llvm-c/Disassembler.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/Triple.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCDisassembler/MCDisassembler.h" @@ -16,12 +19,19 @@ #include "llvm/MC/MCDisassembler/MCSymbolizer.h" #include "llvm/MC/MCInst.h" #include "llvm/MC/MCInstPrinter.h" +#include "llvm/MC/MCInstrDesc.h" #include "llvm/MC/MCInstrInfo.h" +#include "llvm/MC/MCInstrItineraries.h" #include "llvm/MC/MCRegisterInfo.h" +#include "llvm/MC/MCSchedule.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Support/TargetRegistry.h" +#include +#include +#include using namespace llvm; @@ -116,7 +126,7 @@ // LLVMDisasmDispose() disposes of the disassembler specified by the context. // void LLVMDisasmDispose(LLVMDisasmContextRef DCR){ - LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR; + LLVMDisasmContext *DC = static_cast(DCR); delete DC; } @@ -211,7 +221,6 @@ return Latency; } - /// \brief Emits latency information in DC->CommentStream for \p Inst, based /// on the information available in \p DC. static void emitLatency(LLVMDisasmContext *DC, const MCInst &Inst) { @@ -239,7 +248,7 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes, uint64_t BytesSize, uint64_t PC, char *OutString, size_t OutStringSize){ - LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR; + LLVMDisasmContext *DC = static_cast(DCR); // Wrap the pointer to the Bytes, BytesSize and PC in a MemoryObject. ArrayRef Data(Bytes, BytesSize); @@ -288,21 +297,21 @@ // int LLVMSetDisasmOptions(LLVMDisasmContextRef DCR, uint64_t Options){ if (Options & LLVMDisassembler_Option_UseMarkup){ - LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR; + LLVMDisasmContext *DC = static_cast(DCR); MCInstPrinter *IP = DC->getIP(); - IP->setUseMarkup(1); + IP->setUseMarkup(true); DC->addOptions(LLVMDisassembler_Option_UseMarkup); Options &= ~LLVMDisassembler_Option_UseMarkup; } if (Options & LLVMDisassembler_Option_PrintImmHex){ - LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR; + LLVMDisasmContext *DC = static_cast(DCR); MCInstPrinter *IP = DC->getIP(); - IP->setPrintImmHex(1); + IP->setPrintImmHex(true); DC->addOptions(LLVMDisassembler_Option_PrintImmHex); Options &= ~LLVMDisassembler_Option_PrintImmHex; } if (Options & LLVMDisassembler_Option_AsmPrinterVariant){ - LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR; + LLVMDisasmContext *DC = static_cast(DCR); // Try to set up the new instruction printer. const MCAsmInfo *MAI = DC->getAsmInfo(); const MCInstrInfo *MII = DC->getInstrInfo(); @@ -318,14 +327,14 @@ } } if (Options & LLVMDisassembler_Option_SetInstrComments) { - LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR; + LLVMDisasmContext *DC = static_cast(DCR); MCInstPrinter *IP = DC->getIP(); IP->setCommentStream(DC->CommentStream); DC->addOptions(LLVMDisassembler_Option_SetInstrComments); Options &= ~LLVMDisassembler_Option_SetInstrComments; } if (Options & LLVMDisassembler_Option_PrintLatency) { - LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR; + LLVMDisasmContext *DC = static_cast(DCR); DC->addOptions(LLVMDisassembler_Option_PrintLatency); Options &= ~LLVMDisassembler_Option_PrintLatency; } Index: lib/MC/MCParser/AsmLexer.cpp =================================================================== --- lib/MC/MCParser/AsmLexer.cpp +++ lib/MC/MCParser/AsmLexer.cpp @@ -11,16 +11,21 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/ADT/StringRef.h" #include "llvm/MC/MCParser/AsmLexer.h" +#include "llvm/MC/MCParser/MCAsmLexer.h" #include "llvm/MC/MCAsmInfo.h" -#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/SMLoc.h" +#include #include -#include #include -#include +#include #include +#include +#include using namespace llvm; @@ -136,6 +141,7 @@ return isalnum(c) || c == '_' || c == '$' || c == '.' || (c == '@' && AllowAt) || c == '?'; } + AsmToken AsmLexer::LexIdentifier() { // Check for floating point literals. if (CurPtr[-1] == '.' && isdigit(*CurPtr)) { @@ -225,7 +231,7 @@ static unsigned doLookAhead(const char *&CurPtr, unsigned DefaultRadix) { const char *FirstHex = nullptr; const char *LookAhead = CurPtr; - while (1) { + while (true) { if (isdigit(*LookAhead)) { ++LookAhead; } else if (isxdigit(*LookAhead)) { @@ -400,7 +406,6 @@ return AsmToken(AsmToken::Integer, Res, Value); } - /// LexQuote: String: "..." AsmToken AsmLexer::LexQuote() { int CurChar = getNextChar(); Index: lib/MC/MCParser/AsmParser.cpp =================================================================== --- lib/MC/MCParser/AsmParser.cpp +++ lib/MC/MCParser/AsmParser.cpp @@ -12,39 +12,58 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/APFloat.h" -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/None.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCDirectives.h" #include "llvm/MC/MCDwarf.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInstPrinter.h" +#include "llvm/MC/MCInstrDesc.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCObjectFileInfo.h" #include "llvm/MC/MCParser/AsmCond.h" #include "llvm/MC/MCParser/AsmLexer.h" +#include "llvm/MC/MCParser/MCAsmLexer.h" #include "llvm/MC/MCParser/MCAsmParser.h" #include "llvm/MC/MCParser/MCAsmParserUtils.h" #include "llvm/MC/MCParser/MCParsedAsmOperand.h" #include "llvm/MC/MCParser/MCTargetAsmParser.h" #include "llvm/MC/MCRegisterInfo.h" -#include "llvm/MC/MCSectionMachO.h" +#include "llvm/MC/MCSection.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCValue.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Dwarf.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/SMLoc.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/raw_ostream.h" +#include +#include #include +#include +#include #include +#include #include #include +#include +#include #include + using namespace llvm; MCAsmParserSemaCallback::~MCAsmParserSemaCallback() {} @@ -54,6 +73,7 @@ cl::desc("The maximum nesting depth allowed for assembly macros.")); namespace { + /// \brief Helper types for tracking macro definitions. typedef std::vector MCAsmMacroArgument; typedef std::vector MCAsmMacroArguments; @@ -119,6 +139,7 @@ class AsmParser : public MCAsmParser { AsmParser(const AsmParser &) = delete; void operator=(const AsmParser &) = delete; + private: AsmLexer Lexer; MCContext &Ctx; @@ -212,6 +233,7 @@ MCAsmLexer &getLexer() override { return Lexer; } MCContext &getContext() override { return Ctx; } MCStreamer &getStreamer() override { return Out; } + unsigned getAssemblerDialect() override { if (AssemblerDialect == ~0U) return MAI.getAssemblerDialect(); @@ -296,7 +318,6 @@ /// } private: - bool parseStatement(ParseStatementInfo &Info, MCAsmParserSemaCallback *SI); bool parseCurlyBlockScope(SmallVectorImpl& AsmStrRewrites); @@ -562,7 +583,8 @@ void initializeDirectiveKindMap(); }; -} + +} // end anonymous namespace namespace llvm { @@ -570,7 +592,7 @@ extern MCAsmParserExtension *createELFAsmParser(); extern MCAsmParserExtension *createCOFFAsmParser(); -} +} // end namespace llvm enum { DEFAULT_ADDRSPACE = 0 }; @@ -708,7 +730,6 @@ } } - return *tok; } @@ -1415,7 +1436,7 @@ /// Res contains the LHS of the expression on input. bool AsmParser::parseBinOpRHS(unsigned Precedence, const MCExpr *&Res, SMLoc &EndLoc) { - while (1) { + while (true) { MCBinaryExpr::Opcode Kind = MCBinaryExpr::Add; unsigned TokPrec = getBinOpPrecedence(Lexer.getKind(), Kind); @@ -1631,8 +1652,6 @@ getTargetParser().onLabelParsed(Sym); - - return false; } @@ -2239,6 +2258,7 @@ } namespace { + class AsmLexerSkipSpaceRAII { public: AsmLexerSkipSpaceRAII(AsmLexer &Lexer, bool SkipSpace) : Lexer(Lexer) { @@ -2252,7 +2272,8 @@ private: AsmLexer &Lexer; }; -} + +} // end anonymous namespace bool AsmParser::parseMacroArgument(MCAsmMacroArgument &MA, bool Vararg) { @@ -2271,7 +2292,7 @@ bool SpaceEaten; - for (;;) { + while (true) { SpaceEaten = false; if (Lexer.is(AsmToken::Eof) || Lexer.is(AsmToken::Equal)) return TokError("unexpected token in macro instantiation"); @@ -2639,7 +2660,7 @@ if (getLexer().isNot(AsmToken::EndOfStatement)) { checkForValidSection(); - for (;;) { + while (true) { std::string Data; if (check(getTok().isNot(AsmToken::String), "expected string in '" + Twine(IDVal) + "' directive") || @@ -2713,7 +2734,7 @@ if (getLexer().isNot(AsmToken::EndOfStatement)) { checkForValidSection(); - for (;;) { + while (true) { const MCExpr *Value; SMLoc ExprLoc = getLexer().getLoc(); if (parseExpression(Value)) @@ -2748,7 +2769,7 @@ if (getLexer().isNot(AsmToken::EndOfStatement)) { checkForValidSection(); - for (;;) { + while (true) { if (getTok().is(AsmToken::Error)) return true; if (getTok().isNot(AsmToken::Integer) && getTok().isNot(AsmToken::BigNum)) @@ -2796,7 +2817,7 @@ if (getLexer().isNot(AsmToken::EndOfStatement)) { checkForValidSection(); - for (;;) { + while (true) { // We don't truly support arithmetic on floating point expressions, so we // have to manually parse unary prefixes. bool IsNeg = false; @@ -3147,7 +3168,7 @@ unsigned Isa = 0; int64_t Discriminator = 0; if (getLexer().isNot(AsmToken::EndOfStatement)) { - for (;;) { + while (true) { if (getLexer().is(AsmToken::EndOfStatement)) break; @@ -3819,7 +3840,7 @@ AsmToken EndToken, StartToken = getTok(); unsigned MacroDepth = 0; // Lex the macro definition. - for (;;) { + while (true) { // Ignore Lexing errors in macros. while (Lexer.is(AsmToken::Error)) { Lexer.Lex(); @@ -4125,7 +4146,7 @@ checkForValidSection(); const MCExpr *Value; - for (;;) { + while (true) { if (parseExpression(Value)) return true; @@ -4149,7 +4170,7 @@ /// ::= { ".globl", ".weak", ... } [ identifier ( , identifier )* ] bool AsmParser::parseDirectiveSymbolAttribute(MCSymbolAttr Attr) { if (getLexer().isNot(AsmToken::EndOfStatement)) { - for (;;) { + while (true) { StringRef Name; SMLoc Loc = getTok().getLoc(); @@ -4748,7 +4769,7 @@ AsmToken EndToken, StartToken = getTok(); unsigned NestLevel = 0; - for (;;) { + while (true) { // Check whether we have reached the end of the file. if (getLexer().is(AsmToken::Eof)) { Error(DirectiveLoc, "no matching '.endr' in definition"); @@ -5300,8 +5321,8 @@ return false; } -} // namespace MCParserUtils -} // namespace llvm +} // end namespace MCParserUtils +} // end namespace llvm /// \brief Create an MCAsmParser instance. MCAsmParser *llvm::createMCAsmParser(SourceMgr &SM, MCContext &C, Index: lib/Support/FileUtilities.cpp =================================================================== --- lib/Support/FileUtilities.cpp +++ lib/Support/FileUtilities.cpp @@ -14,13 +14,17 @@ #include "llvm/Support/FileUtilities.h" #include "llvm/ADT/SmallString.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include +#include +#include #include #include +#include #include + using namespace llvm; static bool isSignedChar(char C) { @@ -215,7 +219,7 @@ } bool CompareFailed = false; - while (1) { + while (true) { // Scan for the end of file or next difference. while (F1P < File1End && F2P < File2End && *F1P == *F2P) { ++F1P; Index: lib/Support/LockFileManager.cpp =================================================================== --- lib/Support/LockFileManager.cpp +++ lib/Support/LockFileManager.cpp @@ -6,13 +6,21 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// + #include "llvm/Support/LockFileManager.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Errc.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Signals.h" +#include +#include +#include +#include #include #include #if LLVM_ON_WIN32 @@ -31,6 +39,7 @@ #if USE_OSX_GETHOSTUUID #include #endif + using namespace llvm; /// \brief Attempt to read the lock file with the given name, if it exists. @@ -112,6 +121,7 @@ } namespace { + /// An RAII helper object ensure that the unique lock file is removed. /// /// Ensures that if there is an error or a signal before we finish acquiring the @@ -127,6 +137,7 @@ : Filename(Name), RemoveImmediately(true) { sys::RemoveFileOnSignal(Filename, nullptr); } + ~RemoveUniqueLockFileOnSignal() { if (!RemoveImmediately) { // Leave the signal handler enabled. It will be removed when the lock is @@ -136,8 +147,10 @@ sys::fs::remove(Filename); sys::DontRemoveFileOnSignal(Filename); } + void lockAcquired() { RemoveImmediately = false; } }; + } // end anonymous namespace LockFileManager::LockFileManager(StringRef FileName) @@ -202,7 +215,7 @@ // held since the .lock symlink will point to a nonexistent file. RemoveUniqueLockFileOnSignal RemoveUniqueFile(UniqueLockFileName); - while (1) { + while (true) { // Create a link from the lock file name. If this succeeds, we're done. std::error_code EC = sys::fs::create_link(UniqueLockFileName, LockFileName); Index: lib/Support/SmallPtrSet.cpp =================================================================== --- lib/Support/SmallPtrSet.cpp +++ lib/Support/SmallPtrSet.cpp @@ -16,6 +16,7 @@ #include "llvm/ADT/DenseMapInfo.h" #include "llvm/Support/MathExtras.h" #include +#include #include using namespace llvm; @@ -91,7 +92,7 @@ unsigned ProbeAmt = 1; const void *const *Array = CurArray; const void *const *Tombstone = nullptr; - while (1) { + while (true) { // If we found an empty bucket, the pointer doesn't exist in the set. // Return a tombstone if we've seen one so far, or the empty bucket if // not. Index: lib/Support/StringMap.cpp =================================================================== --- lib/Support/StringMap.cpp +++ lib/Support/StringMap.cpp @@ -14,7 +14,9 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/MathExtras.h" #include + using namespace llvm; /// Returns the number of buckets to allocate to ensure that the DenseMap can @@ -63,7 +65,6 @@ TheTable[NumBuckets] = (StringMapEntryBase*)2; } - /// LookupBucketFor - Look up the bucket that the specified string should end /// up in. If it already exists as a key in the map, the Item pointer for the /// specified bucket will be non-null. Otherwise, it will be null. In either @@ -81,7 +82,7 @@ unsigned ProbeAmt = 1; int FirstTombstone = -1; - while (1) { + while (true) { StringMapEntryBase *BucketItem = TheTable[BucketNo]; // If we found an empty bucket, this key isn't in the table yet, return it. if (LLVM_LIKELY(!BucketItem)) { @@ -123,7 +124,6 @@ } } - /// FindKey - Look up the bucket that contains the specified key. If it exists /// in the map, return the bucket number of the key. Otherwise return -1. /// This does not modify the map. @@ -135,7 +135,7 @@ unsigned *HashTable = (unsigned *)(TheTable + NumBuckets + 1); unsigned ProbeAmt = 1; - while (1) { + while (true) { StringMapEntryBase *BucketItem = TheTable[BucketNo]; // If we found an empty bucket, this key isn't in the table yet, return. if (LLVM_LIKELY(!BucketItem)) @@ -191,8 +191,6 @@ return Result; } - - /// RehashTable - Grow the table, redistributing values into the buckets with /// the appropriate mod-of-hashtable-size. unsigned StringMapImpl::RehashTable(unsigned BucketNo) { Index: lib/Support/raw_ostream.cpp =================================================================== --- lib/Support/raw_ostream.cpp +++ lib/Support/raw_ostream.cpp @@ -23,10 +23,13 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Support/Process.h" #include "llvm/Support/Program.h" +#include #include #include -#include +#include +#include #include +#include // may provide O_BINARY. #if defined(HAVE_FCNTL_H) @@ -266,8 +269,6 @@ return this->operator<<(format("%e", N)); } - - void raw_ostream::flush_nonempty() { assert(OutBufCur > OutBufStart && "Invalid call to flush_nonempty."); size_t Length = OutBufCur - OutBufStart; @@ -382,7 +383,7 @@ // space. Iterate until we win. SmallVector V; - while (1) { + while (true) { V.resize(NextBufferSize); // Try formatting into the SmallVector. @@ -455,7 +456,6 @@ } } - /// indent - Insert 'NumSpaces' spaces. raw_ostream &raw_ostream::indent(unsigned NumSpaces) { static const char Spaces[] = " " @@ -475,7 +475,6 @@ return *this; } - //===----------------------------------------------------------------------===// // Formatted Output //===----------------------------------------------------------------------===// @@ -563,7 +562,6 @@ report_fatal_error("IO failure on output stream.", /*GenCrashDiag=*/false); } - void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) { assert(FD >= 0 && "File already closed."); pos += Size; @@ -740,7 +738,6 @@ return S; } - //===----------------------------------------------------------------------===// // raw_string_ostream //===----------------------------------------------------------------------===// Index: lib/TableGen/Record.cpp =================================================================== --- lib/TableGen/Record.cpp +++ 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 +#include +#include using namespace llvm; @@ -51,6 +52,7 @@ using llvm::hash_value; return hash_value(Value.str()); } + private: std::string data; }; @@ -61,21 +63,24 @@ TableGenStringKey Empty("<<>>"); return Empty; } + static inline TableGenStringKey getTombstoneKey() { TableGenStringKey Tombstone("<<>>"); 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 @@ return nullptr; } - //===----------------------------------------------------------------------===// // Initializer implementations //===----------------------------------------------------------------------===// @@ -1320,7 +1324,6 @@ return nullptr; } - RecTy *VarInit::getFieldType(const std::string &FieldName) const { if (RecordRecTy *RTy = dyn_cast(getType())) if (const RecordVal *RV = RTy->getRecord()->getValue(FieldName)) @@ -1447,7 +1450,6 @@ return Def->getValue(FieldName)->getValue(); } - std::string DefInit::getAsString() const { return Def->getName(); } @@ -1572,7 +1574,6 @@ return const_cast(this); } - std::string DagInit::getAsString() const { std::string Result = "(" + Val->getAsString(); if (!ValName.empty()) @@ -1588,7 +1589,6 @@ return Result + ")"; } - //===----------------------------------------------------------------------===// // Other implementations //===----------------------------------------------------------------------===// @@ -1628,7 +1628,7 @@ // 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 @@ return R->getValue(); } - std::string Record::getValueAsString(StringRef FieldName) const { const RecordVal *R = getValue(FieldName); if (!R || !R->getValue()) @@ -1884,7 +1883,6 @@ FieldName + "' does not have a dag initializer!"); } - LLVM_DUMP_METHOD void MultiClass::dump() const { errs() << "Record:\n"; Rec.dump(); @@ -1894,7 +1892,6 @@ Proto->dump(); } - LLVM_DUMP_METHOD void RecordKeeper::dump() const { errs() << *this; } raw_ostream &llvm::operator<<(raw_ostream &OS, const RecordKeeper &RK) { Index: lib/TableGen/TGLexer.cpp =================================================================== --- lib/TableGen/TGLexer.cpp +++ 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 #include +#include #include #include #include @@ -246,7 +248,6 @@ return tgtok::VarName; } - tgtok::TokKind TGLexer::LexIdentifier() { // The first letter is [a-zA-Z_#]. const char *IdentStart = TokStart; @@ -301,7 +302,6 @@ std::string Filename = CurStrVal; std::string IncludedFile; - CurBuffer = SrcMgr.AddIncludeFile(Filename, SMLoc::getFromPointer(CurPtr), IncludedFile); if (!CurBuffer) { @@ -326,7 +326,7 @@ void TGLexer::SkipBCPLComment() { ++CurPtr; // skip the second slash. - while (1) { + while (true) { switch (*CurPtr) { case '\n': case '\r': @@ -348,7 +348,7 @@ ++CurPtr; // skip the star. unsigned CommentDepth = 1; - while (1) { + while (true) { int CurChar = getNextChar(); switch (CurChar) { case EOF: @@ -436,7 +436,7 @@ return tgtok::l_square; ++CurPtr; const char *CodeStart = CurPtr; - while (1) { + while (true) { int Char = getNextChar(); if (Char == EOF) break; @@ -485,4 +485,3 @@ return Kind != tgtok::Error ? Kind : ReturnError(Start-1, "Unknown operator"); } - Index: lib/TableGen/TGParser.cpp =================================================================== --- lib/TableGen/TGParser.cpp +++ 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 +#include +#include + using namespace llvm; //===----------------------------------------------------------------------===// @@ -24,10 +32,12 @@ //===----------------------------------------------------------------------===// namespace llvm { + struct SubClassReference { SMRange RefRange; Record *Rec; std::vector TemplateArgs; + SubClassReference() : Rec(nullptr) {} bool isInvalid() const { return Rec == nullptr; } @@ -37,6 +47,7 @@ SMRange RefRange; MultiClass *MC; std::vector TemplateArgs; + SubMultiClassReference() : MC(nullptr) {} bool isInvalid() const { return MC == nullptr; } @@ -130,7 +141,7 @@ } if (RV->setValue(V)) { - std::string InitType = ""; + std::string InitType; if (BitsInit *BI = dyn_cast(V)) InitType = (Twine("' of type bit initializer with length ") + Twine(BI->getNumBits())).str(); @@ -644,7 +655,6 @@ return false; } - /// ParseType - Parse and return a tblgen type. This returns null on error. /// /// Type ::= STRING // string type @@ -1110,7 +1120,6 @@ return Type; } - /// ParseSimpleValue - Parse a tblgen value. This returns null on error. /// /// SimpleValue ::= IDValue @@ -1465,7 +1474,7 @@ 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 @@ TGParser::ParseDagArgList(Record *CurRec) { std::vector > Result; - while (1) { + while (true) { // DagArg ::= VARNAME if (Lex.getCode() == tgtok::VarName) { // A missing value is treated like '?'. @@ -1623,7 +1632,6 @@ 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 @@ 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 @@ return false; } - /// ParseBodyItem - Parse a single item at within the body of a def or class. /// /// BodyItem ::= Declaration ';' @@ -1951,7 +1957,7 @@ // 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 @@ std::vector TGParser::ParseLetList() { std::vector Result; - while (1) { + while (true) { if (Lex.getCode() != tgtok::Id) { TokError("expected identifier in let definition"); return std::vector(); @@ -2264,7 +2270,7 @@ // 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 @@ 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 @@ // 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 @@ return TokError("Unexpected input at top level"); } -