summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp16
-rw-r--r--lib/IR/ValueSymbolTable.cpp8
-rw-r--r--lib/MC/MCDisassembler/Disassembler.cpp29
-rw-r--r--lib/MC/MCParser/AsmLexer.cpp15
-rw-r--r--lib/MC/MCParser/AsmParser.cpp65
-rw-r--r--lib/Support/FileUtilities.cpp8
-rw-r--r--lib/Support/LockFileManager.cpp15
-rw-r--r--lib/Support/SmallPtrSet.cpp3
-rw-r--r--lib/Support/StringMap.cpp10
-rw-r--r--lib/Support/raw_ostream.cpp13
-rw-r--r--lib/TableGen/Record.cpp23
-rw-r--r--lib/TableGen/TGLexer.cpp11
-rw-r--r--lib/TableGen/TGParser.cpp33
13 files changed, 156 insertions, 93 deletions
diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
index 441f0eb8572..ee75bee9c53 100644
--- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
+++ b/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 <cassert>
#include <cmath>
#include <csignal>
+#include <cstdint>
#include <cstdio>
#include <cstring>
#include <map>
+#include <string>
+#include <utility>
+#include <vector>
#ifdef HAVE_FFI_CALL
#ifdef HAVE_FFI_H
@@ -290,7 +301,6 @@ GenericValue Interpreter::callExternalFunction(Function *F,
return GenericValue();
}
-
//===----------------------------------------------------------------------===//
// Functions "exported" to the running application...
//
@@ -331,7 +341,7 @@ static GenericValue lle_X_sprintf(FunctionType *FT,
// 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
diff --git a/lib/IR/ValueSymbolTable.cpp b/lib/IR/ValueSymbolTable.cpp
index f6f1dd984e9..8a6a320fc2d 100644
--- a/lib/IR/ValueSymbolTable.cpp
+++ b/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 <cassert>
+#include <utility>
+
using namespace llvm;
#define DEBUG_TYPE "valuesymtab"
@@ -35,7 +40,7 @@ ValueSymbolTable::~ValueSymbolTable() {
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 @@ ValueName *ValueSymbolTable::createValueName(StringRef Name, Value *V) {
return makeUniqueName(V, UniqueName);
}
-
// dump - print out the symbol table
//
LLVM_DUMP_METHOD void ValueSymbolTable::dump() const {
diff --git a/lib/MC/MCDisassembler/Disassembler.cpp b/lib/MC/MCDisassembler/Disassembler.cpp
index 21e8748b797..094ad7cc5eb 100644
--- a/lib/MC/MCDisassembler/Disassembler.cpp
+++ b/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 <cassert>
+#include <cstddef>
+#include <cstring>
using namespace llvm;
@@ -116,7 +126,7 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TT, void *DisInfo,
// LLVMDisasmDispose() disposes of the disassembler specified by the context.
//
void LLVMDisasmDispose(LLVMDisasmContextRef DCR){
- LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR;
+ LLVMDisasmContext *DC = static_cast<LLVMDisasmContext *>(DCR);
delete DC;
}
@@ -211,7 +221,6 @@ static int getLatency(LLVMDisasmContext *DC, const MCInst &Inst) {
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 @@ static void emitLatency(LLVMDisasmContext *DC, const MCInst &Inst) {
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<LLVMDisasmContext *>(DCR);
// Wrap the pointer to the Bytes, BytesSize and PC in a MemoryObject.
ArrayRef<uint8_t> Data(Bytes, BytesSize);
@@ -288,21 +297,21 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes,
//
int LLVMSetDisasmOptions(LLVMDisasmContextRef DCR, uint64_t Options){
if (Options & LLVMDisassembler_Option_UseMarkup){
- LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR;
+ LLVMDisasmContext *DC = static_cast<LLVMDisasmContext *>(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<LLVMDisasmContext *>(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<LLVMDisasmContext *>(DCR);
// Try to set up the new instruction printer.
const MCAsmInfo *MAI = DC->getAsmInfo();
const MCInstrInfo *MII = DC->getInstrInfo();
@@ -318,14 +327,14 @@ int LLVMSetDisasmOptions(LLVMDisasmContextRef DCR, uint64_t Options){
}
}
if (Options & LLVMDisassembler_Option_SetInstrComments) {
- LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR;
+ LLVMDisasmContext *DC = static_cast<LLVMDisasmContext *>(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<LLVMDisasmContext *>(DCR);
DC->addOptions(LLVMDisassembler_Option_PrintLatency);
Options &= ~LLVMDisassembler_Option_PrintLatency;
}
diff --git a/lib/MC/MCParser/AsmLexer.cpp b/lib/MC/MCParser/AsmLexer.cpp
index 832c39a2c75..71e35448919 100644
--- a/lib/MC/MCParser/AsmLexer.cpp
+++ b/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 <cassert>
#include <cctype>
-#include <cerrno>
#include <cstdio>
-#include <cstdlib>
+#include <cstring>
#include <tuple>
+#include <string>
+#include <utility>
using namespace llvm;
@@ -136,6 +141,7 @@ static bool IsIdentifierChar(char c, bool AllowAt) {
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 void SkipIgnoredIntegerSuffix(const char *&CurPtr) {
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 @@ AsmToken AsmLexer::LexSingleQuote() {
return AsmToken(AsmToken::Integer, Res, Value);
}
-
/// LexQuote: String: "..."
AsmToken AsmLexer::LexQuote() {
int CurChar = getNextChar();
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp
index 7a6d5dbd2d3..46696609961 100644
--- a/lib/MC/MCParser/AsmParser.cpp
+++ b/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 <algorithm>
+#include <cassert>
#include <cctype>
+#include <cstddef>
+#include <cstdint>
#include <deque>
+#include <memory>
#include <sstream>
#include <string>
+#include <tuple>
+#include <utility>
#include <vector>
+
using namespace llvm;
MCAsmParserSemaCallback::~MCAsmParserSemaCallback() {}
@@ -54,6 +73,7 @@ static cl::opt<unsigned> AsmMacroMaxNestingDepth(
cl::desc("The maximum nesting depth allowed for assembly macros."));
namespace {
+
/// \brief Helper types for tracking macro definitions.
typedef std::vector<AsmToken> MCAsmMacroArgument;
typedef std::vector<MCAsmMacroArgument> MCAsmMacroArguments;
@@ -119,6 +139,7 @@ struct ParseStatementInfo {
class AsmParser : public MCAsmParser {
AsmParser(const AsmParser &) = delete;
void operator=(const AsmParser &) = delete;
+
private:
AsmLexer Lexer;
MCContext &Ctx;
@@ -212,6 +233,7 @@ public:
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 @@ public:
/// }
private:
-
bool parseStatement(ParseStatementInfo &Info,
MCAsmParserSemaCallback *SI);
bool parseCurlyBlockScope(SmallVectorImpl<AsmRewrite>& AsmStrRewrites);
@@ -562,7 +583,8 @@ private:
void initializeDirectiveKindMap();
};
-}
+
+} // end anonymous namespace
namespace llvm {
@@ -570,7 +592,7 @@ extern MCAsmParserExtension *createDarwinAsmParser();
extern MCAsmParserExtension *createELFAsmParser();
extern MCAsmParserExtension *createCOFFAsmParser();
-}
+} // end namespace llvm
enum { DEFAULT_ADDRSPACE = 0 };
@@ -708,7 +730,6 @@ const AsmToken &AsmParser::Lex() {
}
}
-
return *tok;
}
@@ -1415,7 +1436,7 @@ unsigned AsmParser::getBinOpPrecedence(AsmToken::TokenKind K,
/// 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 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
getTargetParser().onLabelParsed(Sym);
-
-
return false;
}
@@ -2239,6 +2258,7 @@ static bool isOperator(AsmToken::TokenKind kind) {
}
namespace {
+
class AsmLexerSkipSpaceRAII {
public:
AsmLexerSkipSpaceRAII(AsmLexer &Lexer, bool SkipSpace) : Lexer(Lexer) {
@@ -2252,7 +2272,8 @@ public:
private:
AsmLexer &Lexer;
};
-}
+
+} // end anonymous namespace
bool AsmParser::parseMacroArgument(MCAsmMacroArgument &MA, bool Vararg) {
@@ -2271,7 +2292,7 @@ bool AsmParser::parseMacroArgument(MCAsmMacroArgument &MA, bool Vararg) {
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 @@ bool AsmParser::parseDirectiveAscii(StringRef IDVal, bool ZeroTerminated) {
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 @@ bool AsmParser::parseDirectiveValue(unsigned Size) {
if (getLexer().isNot(AsmToken::EndOfStatement)) {
checkForValidSection();
- for (;;) {
+ while (true) {
const MCExpr *Value;
SMLoc ExprLoc = getLexer().getLoc();
if (parseExpression(Value))
@@ -2748,7 +2769,7 @@ bool AsmParser::parseDirectiveOctaValue() {
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 @@ bool AsmParser::parseDirectiveRealValue(const fltSemantics &Semantics) {
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 @@ bool AsmParser::parseDirectiveLoc() {
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 @@ bool AsmParser::parseDirectiveMacro(SMLoc DirectiveLoc) {
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 @@ bool AsmParser::parseDirectiveLEB128(bool Signed) {
checkForValidSection();
const MCExpr *Value;
- for (;;) {
+ while (true) {
if (parseExpression(Value))
return true;
@@ -4149,7 +4170,7 @@ bool AsmParser::parseDirectiveLEB128(bool Signed) {
/// ::= { ".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 @@ MCAsmMacro *AsmParser::parseMacroLikeBody(SMLoc DirectiveLoc) {
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 @@ bool parseAssignmentExpression(StringRef Name, bool allow_redef,
return false;
}
-} // namespace MCParserUtils
-} // namespace llvm
+} // end namespace MCParserUtils
+} // end namespace llvm
/// \brief Create an MCAsmParser instance.
MCAsmParser *llvm::createMCAsmParser(SourceMgr &SM, MCContext &C,
diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp
index c6a58cc9d03..39dbefff5b7 100644
--- a/lib/Support/FileUtilities.cpp
+++ b/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 <cctype>
+#include <cmath>
+#include <cstdint>
#include <cstdlib>
#include <cstring>
+#include <memory>
#include <system_error>
+
using namespace llvm;
static bool isSignedChar(char C) {
@@ -215,7 +219,7 @@ int llvm::DiffFilesWithTolerance(StringRef NameA,
}
bool CompareFailed = false;
- while (1) {
+ while (true) {
// Scan for the end of file or next difference.
while (F1P < File1End && F2P < File2End && *F1P == *F2P) {
++F1P;
diff --git a/lib/Support/LockFileManager.cpp b/lib/Support/LockFileManager.cpp
index 611f94a9709..357d0e37856 100644
--- a/lib/Support/LockFileManager.cpp
+++ b/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 <cerrno>
+#include <ctime>
+#include <memory>
+#include <tuple>
#include <sys/stat.h>
#include <sys/types.h>
#if LLVM_ON_WIN32
@@ -31,6 +39,7 @@
#if USE_OSX_GETHOSTUUID
#include <uuid/uuid.h>
#endif
+
using namespace llvm;
/// \brief Attempt to read the lock file with the given name, if it exists.
@@ -112,6 +121,7 @@ bool LockFileManager::processStillExecuting(StringRef HostID, int PID) {
}
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 @@ public:
: 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 @@ public:
sys::fs::remove(Filename);
sys::DontRemoveFileOnSignal(Filename);
}
+
void lockAcquired() { RemoveImmediately = false; }
};
+
} // end anonymous namespace
LockFileManager::LockFileManager(StringRef FileName)
@@ -202,7 +215,7 @@ LockFileManager::LockFileManager(StringRef FileName)
// 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);
diff --git a/lib/Support/SmallPtrSet.cpp b/lib/Support/SmallPtrSet.cpp
index 539b4eb34da..8fb12ba917b 100644
--- a/lib/Support/SmallPtrSet.cpp
+++ b/lib/Support/SmallPtrSet.cpp
@@ -16,6 +16,7 @@
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
+#include <cassert>
#include <cstdlib>
using namespace llvm;
@@ -91,7 +92,7 @@ const void * const *SmallPtrSetImplBase::FindBucketFor(const void *Ptr) const {
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.
diff --git a/lib/Support/StringMap.cpp b/lib/Support/StringMap.cpp
index 7da9ccbd40c..d2315966e32 100644
--- a/lib/Support/StringMap.cpp
+++ b/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 <cassert>
+
using namespace llvm;
/// Returns the number of buckets to allocate to ensure that the DenseMap can
@@ -63,7 +65,6 @@ void StringMapImpl::init(unsigned InitSize) {
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 StringMapImpl::LookupBucketFor(StringRef Name) {
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 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) {
}
}
-
/// 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 @@ int StringMapImpl::FindKey(StringRef Key) const {
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 @@ StringMapEntryBase *StringMapImpl::RemoveKey(StringRef Key) {
return Result;
}
-
-
/// RehashTable - Grow the table, redistributing values into the buckets with
/// the appropriate mod-of-hashtable-size.
unsigned StringMapImpl::RehashTable(unsigned BucketNo) {
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index c4a7b145588..df4c8dc376b 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/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 <algorithm>
#include <cctype>
#include <cerrno>
-#include <sys/stat.h>
+#include <cstdio>
+#include <iterator>
#include <system_error>
+#include <sys/stat.h>
// <fcntl.h> may provide O_BINARY.
#if defined(HAVE_FCNTL_H)
@@ -266,8 +269,6 @@ raw_ostream &raw_ostream::operator<<(double N) {
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 @@ raw_ostream &raw_ostream::operator<<(const format_object_base &Fmt) {
// space. Iterate until we win.
SmallVector<char, 128> V;
- while (1) {
+ while (true) {
V.resize(NextBufferSize);
// Try formatting into the SmallVector.
@@ -455,7 +456,6 @@ raw_ostream &raw_ostream::operator<<(const FormattedNumber &FN) {
}
}
-
/// indent - Insert 'NumSpaces' spaces.
raw_ostream &raw_ostream::indent(unsigned NumSpaces) {
static const char Spaces[] = " "
@@ -475,7 +475,6 @@ raw_ostream &raw_ostream::indent(unsigned NumSpaces) {
return *this;
}
-
//===----------------------------------------------------------------------===//
// Formatted Output
//===----------------------------------------------------------------------===//
@@ -563,7 +562,6 @@ raw_fd_ostream::~raw_fd_ostream() {
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 @@ raw_ostream &llvm::nulls() {
return S;
}
-
//===----------------------------------------------------------------------===//
// raw_string_ostream
//===----------------------------------------------------------------------===//
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");
}
-