1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[LLVM] Fix some Clang-tidy modernize-use-using and Include What You Use warnings

Differential revision: https://reviews.llvm.org/D23675

llvm-svn: 279102
This commit is contained in:
Eugene Zelenko 2016-08-18 17:56:27 +00:00
parent d1314859b2
commit 14cb183214
7 changed files with 86 additions and 59 deletions

View File

@ -15,12 +15,21 @@
#ifndef LLVM_BITCODE_BITSTREAMREADER_H
#define LLVM_BITCODE_BITSTREAMREADER_H
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Bitcode/BitCodes.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/StreamingMemoryObject.h"
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <string>
#include <utility>
#include <vector>
namespace llvm {
@ -37,9 +46,9 @@ public:
unsigned BlockID;
std::vector<IntrusiveRefCntPtr<BitCodeAbbrev>> Abbrevs;
std::string Name;
std::vector<std::pair<unsigned, std::string> > RecordNames;
};
private:
std::unique_ptr<MemoryObject> BitcodeBytes;
@ -51,6 +60,7 @@ private:
BitstreamReader(const BitstreamReader&) = delete;
void operator=(const BitstreamReader&) = delete;
public:
BitstreamReader() : IgnoreBlockInfoNames(true) {
}
@ -139,12 +149,12 @@ class SimpleBitstreamCursor {
// The size of the bicode. 0 if we don't know it yet.
size_t Size = 0;
public:
/// This is the current data we have pulled from the stream but have not
/// returned to the client. This is specifically and intentionally defined to
/// follow the word size of the host machine for efficiency. We use word_t in
/// places that are aware of this to make it perfectly explicit what is going
/// on.
public:
typedef size_t word_t;
private:
@ -306,7 +316,7 @@ public:
uint32_t Result = 0;
unsigned NextBit = 0;
while (1) {
while (true) {
Result |= (Piece & ((1U << (NumBits-1))-1)) << NextBit;
if ((Piece & (1U << (NumBits-1))) == 0)
@ -326,7 +336,7 @@ public:
uint64_t Result = 0;
unsigned NextBit = 0;
while (1) {
while (true) {
Result |= uint64_t(Piece & ((1U << (NumBits-1))-1)) << NextBit;
if ((Piece & (1U << (NumBits-1))) == 0)
@ -394,12 +404,15 @@ struct BitstreamEntry {
static BitstreamEntry getError() {
BitstreamEntry E; E.Kind = Error; return E;
}
static BitstreamEntry getEndBlock() {
BitstreamEntry E; E.Kind = EndBlock; return E;
}
static BitstreamEntry getSubBlock(unsigned ID) {
BitstreamEntry E; E.Kind = SubBlock; E.ID = ID; return E;
}
static BitstreamEntry getRecord(unsigned AbbrevID) {
BitstreamEntry E; E.Kind = Record; E.ID = AbbrevID; return E;
}
@ -421,13 +434,13 @@ class BitstreamCursor : SimpleBitstreamCursor {
struct Block {
unsigned PrevCodeSize;
std::vector<IntrusiveRefCntPtr<BitCodeAbbrev>> PrevAbbrevs;
explicit Block(unsigned PCS) : PrevCodeSize(PCS) {}
};
/// This tracks the codesize of parent blocks.
SmallVector<Block, 8> BlockScope;
public:
static const size_t MaxChunkSize = sizeof(word_t) * 8;
@ -471,7 +484,7 @@ public:
/// Advance the current bitstream, returning the next entry in the stream.
BitstreamEntry advance(unsigned Flags = 0) {
while (1) {
while (true) {
unsigned Code = ReadCode();
if (Code == bitc::END_BLOCK) {
// Pop the end of the block unless Flags tells us not to.
@ -498,7 +511,7 @@ public:
/// This is a convenience function for clients that don't expect any
/// subblocks. This just skips over them automatically.
BitstreamEntry advanceSkippingSubblocks(unsigned Flags = 0) {
while (1) {
while (true) {
// If we found a normal entry, return it.
BitstreamEntry Entry = advance(Flags);
if (Entry.Kind != BitstreamEntry::SubBlock)
@ -514,7 +527,6 @@ public:
return Read(CurCodeSize);
}
// Block header:
// [ENTER_SUBBLOCK, blockid, newcodelen, <align4bytes>, blocklen]
@ -558,7 +570,6 @@ public:
}
private:
void popBlockScope() {
CurCodeSize = BlockScope.back().PrevCodeSize;
@ -593,6 +604,6 @@ public:
bool ReadBlockInfoBlock();
};
} // End llvm namespace
} // end llvm namespace
#endif
#endif // LLVM_BITCODE_BITSTREAMREADER_H

View File

@ -10,10 +10,11 @@
#ifndef LLVM_MC_MCINSTPRINTER_H
#define LLVM_MC_MCINSTPRINTER_H
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/Format.h"
#include <cstdint>
namespace llvm {
template <typename T> class ArrayRef;
class MCInst;
class raw_ostream;
@ -27,11 +28,13 @@ class StringRef;
void dumpBytes(ArrayRef<uint8_t> Bytes, raw_ostream &OS);
namespace HexStyle {
enum Style {
C, ///< 0xff
Asm ///< 0ffh
};
}
} // end namespace HexStyle
/// \brief This is an instance of a target assembly language printer that
/// converts an MCInst to valid target assembly syntax.
@ -60,8 +63,8 @@ protected:
public:
MCInstPrinter(const MCAsmInfo &mai, const MCInstrInfo &mii,
const MCRegisterInfo &mri)
: CommentStream(nullptr), MAI(mai), MII(mii), MRI(mri), UseMarkup(0),
PrintImmHex(0), PrintHexStyle(HexStyle::C) {}
: CommentStream(nullptr), MAI(mai), MII(mii), MRI(mri), UseMarkup(false),
PrintImmHex(false), PrintHexStyle(HexStyle::C) {}
virtual ~MCInstPrinter();
@ -103,6 +106,6 @@ public:
format_object<uint64_t> formatHex(uint64_t Value) const;
};
} // namespace llvm
} // end namespace llvm
#endif
#endif // LLVM_MC_MCINSTPRINTER_H

View File

@ -17,8 +17,11 @@
// FIXME: Move to this file: BasicBlock::removePredecessor, BB::splitBasicBlock
#include "llvm/ADT/ArrayRef.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/InstrTypes.h"
#include <cassert>
namespace llvm {
@ -29,7 +32,6 @@ class Instruction;
class MDNode;
class ReturnInst;
class TargetLibraryInfo;
class TerminatorInst;
/// Delete the specified block, which must have no predecessors.
void DeleteDeadBlock(BasicBlock *BB);
@ -154,7 +156,7 @@ SplitCriticalEdge(BasicBlock *Src, BasicBlock *Dst,
CriticalEdgeSplittingOptions()) {
TerminatorInst *TI = Src->getTerminator();
unsigned i = 0;
while (1) {
while (true) {
assert(i != TI->getNumSuccessors() && "Edge doesn't exist!");
if (TI->getSuccessor(i) == Dst)
return SplitCriticalEdge(TI, i, Options);
@ -282,6 +284,7 @@ void SplitBlockAndInsertIfThenElse(Value *Cond, Instruction *SplitBefore,
/// instructions in them.
Value *GetIfCondition(BasicBlock *BB, BasicBlock *&IfTrue,
BasicBlock *&IfFalse);
} // End llvm namespace
#endif
} // end namespace llvm
#endif // LLVM_TRANSFORMS_UTILS_BASICBLOCKUTILS_H

View File

@ -12,21 +12,18 @@
//===----------------------------------------------------------------------===//
#include "LLLexer.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Twine.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace llvm;
bool LLLexer::Error(LocTy ErrorLoc, const Twine &Msg) const {
@ -147,18 +144,15 @@ static bool isLabelChar(char C) {
C == '.' || C == '_';
}
/// isLabelTail - Return true if this pointer points to a valid end of a label.
static const char *isLabelTail(const char *CurPtr) {
while (1) {
while (true) {
if (CurPtr[0] == ':') return CurPtr+1;
if (!isLabelChar(CurPtr[0])) return nullptr;
++CurPtr;
}
}
//===----------------------------------------------------------------------===//
// Lexer definition.
//===----------------------------------------------------------------------===//
@ -185,7 +179,6 @@ int LLLexer::getNextChar() {
}
}
lltok::Kind LLLexer::LexToken() {
TokStart = CurPtr;
@ -246,7 +239,7 @@ lltok::Kind LLLexer::LexToken() {
}
void LLLexer::SkipLineComment() {
while (1) {
while (true) {
if (CurPtr[0] == '\n' || CurPtr[0] == '\r' || getNextChar() == EOF)
return;
}
@ -271,7 +264,7 @@ lltok::Kind LLLexer::LexDollar() {
if (CurPtr[0] == '"') {
++CurPtr;
while (1) {
while (true) {
int CurChar = getNextChar();
if (CurChar == EOF) {
@ -300,7 +293,7 @@ lltok::Kind LLLexer::LexDollar() {
/// ReadString - Read a string until the closing quote.
lltok::Kind LLLexer::ReadString(lltok::Kind kind) {
const char *Start = CurPtr;
while (1) {
while (true) {
int CurChar = getNextChar();
if (CurChar == EOF) {
@ -338,7 +331,7 @@ lltok::Kind LLLexer::LexVar(lltok::Kind Var, lltok::Kind VarID) {
if (CurPtr[0] == '"') {
++CurPtr;
while (1) {
while (true) {
int CurChar = getNextChar();
if (CurChar == EOF) {
@ -488,11 +481,12 @@ lltok::Kind LLLexer::LexIdentifier() {
CurPtr = KeywordEnd;
--StartChar;
StringRef Keyword(StartChar, CurPtr - StartChar);
#define KEYWORD(STR) \
do { \
if (Keyword == #STR) \
return lltok::kw_##STR; \
} while (0)
} while (false)
KEYWORD(true); KEYWORD(false);
KEYWORD(declare); KEYWORD(define);
@ -697,6 +691,7 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD(cleanup);
KEYWORD(catch);
KEYWORD(filter);
#undef KEYWORD
// Keywords for types.
@ -707,6 +702,7 @@ lltok::Kind LLLexer::LexIdentifier() {
return lltok::Type; \
} \
} while (false)
TYPEKEYWORD("void", Type::getVoidTy(Context));
TYPEKEYWORD("half", Type::getHalfTy(Context));
TYPEKEYWORD("float", Type::getFloatTy(Context));
@ -718,6 +714,7 @@ lltok::Kind LLLexer::LexIdentifier() {
TYPEKEYWORD("metadata", Type::getMetadataTy(Context));
TYPEKEYWORD("x86_mmx", Type::getX86_MMXTy(Context));
TYPEKEYWORD("token", Type::getTokenTy(Context));
#undef TYPEKEYWORD
// Keywords for instructions.
@ -782,6 +779,7 @@ lltok::Kind LLLexer::LexIdentifier() {
INSTKEYWORD(catchswitch, CatchSwitch);
INSTKEYWORD(catchpad, CatchPad);
INSTKEYWORD(cleanuppad, CleanupPad);
#undef INSTKEYWORD
#define DWKEYWORD(TYPE, TOKEN) \
@ -791,6 +789,7 @@ lltok::Kind LLLexer::LexIdentifier() {
return lltok::TOKEN; \
} \
} while (false)
DWKEYWORD(TAG, DwarfTag);
DWKEYWORD(ATE, DwarfAttEncoding);
DWKEYWORD(VIRTUALITY, DwarfVirtuality);
@ -798,7 +797,9 @@ lltok::Kind LLLexer::LexIdentifier() {
DWKEYWORD(CC, DwarfCC);
DWKEYWORD(OP, DwarfOp);
DWKEYWORD(MACINFO, DwarfMacinfo);
#undef DWKEYWORD
if (Keyword.startswith("DIFlag")) {
StrVal.assign(Keyword.begin(), Keyword.end());
return lltok::DIFlag;

View File

@ -8,6 +8,9 @@
//===----------------------------------------------------------------------===//
#include "llvm/Bitcode/BitstreamReader.h"
#include "llvm/ADT/StringRef.h"
#include <cassert>
#include <string>
using namespace llvm;
@ -95,8 +98,6 @@ static void skipAbbreviatedField(BitstreamCursor &Cursor,
}
}
/// skipRecord - Read the current record and discard it.
void BitstreamCursor::skipRecord(unsigned AbbrevID) {
// Skip unabbreviated records by reading past their entries.
@ -279,7 +280,6 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID,
return Code;
}
void BitstreamCursor::ReadAbbrevRecord() {
BitCodeAbbrev *Abbv = new BitCodeAbbrev();
unsigned NumOpInfo = ReadVBR(5);
@ -329,7 +329,7 @@ bool BitstreamCursor::ReadBlockInfoBlock() {
BitstreamReader::BlockInfo *CurBlockInfo = nullptr;
// Read all the records for this module.
while (1) {
while (true) {
BitstreamEntry Entry = advanceSkippingSubblocks(AF_DontAutoprocessAbbrevs);
switch (Entry.Kind) {
@ -388,4 +388,3 @@ bool BitstreamCursor::ReadBlockInfoBlock() {
}
}
}

View File

@ -12,21 +12,26 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <cstdint>
#include <string>
#include <utility>
#include <vector>
using namespace llvm;
using namespace dwarf;
/// \brief Abstract frame entry defining the common interface concrete
/// entries implement.
class llvm::FrameEntry {
@ -95,7 +100,6 @@ protected:
}
};
// See DWARF standard v3, section 7.23
const uint8_t DWARF_CFI_PRIMARY_OPCODE_MASK = 0xc0;
const uint8_t DWARF_CFI_PRIMARY_OPERAND_MASK = 0x3f;
@ -194,6 +198,7 @@ void FrameEntry::parseInstructions(DataExtractor Data, uint32_t *Offset,
}
namespace {
/// \brief DWARF Common Information Entry (CIE)
class CIE : public FrameEntry {
public:
@ -220,9 +225,11 @@ public:
StringRef getAugmentationString() const { return Augmentation; }
uint64_t getCodeAlignmentFactor() const { return CodeAlignmentFactor; }
int64_t getDataAlignmentFactor() const { return DataAlignmentFactor; }
uint32_t getFDEPointerEncoding() const {
return FDEPointerEncoding;
}
uint32_t getLSDAPointerEncoding() const {
return LSDAPointerEncoding;
}
@ -274,7 +281,6 @@ private:
uint32_t LSDAPointerEncoding;
};
/// \brief DWARF Frame Description Entry (FDE)
class FDE : public FrameEntry {
public:
@ -336,7 +342,7 @@ static ArrayRef<OperandType[2]> getOperandTypes() {
do { \
OpTypes[OP][0] = OPTYPE0; \
OpTypes[OP][1] = OPTYPE1; \
} while (0)
} while (false)
#define DECLARE_OP1(OP, OPTYPE0) DECLARE_OP2(OP, OPTYPE0, OT_None)
#define DECLARE_OP0(OP) DECLARE_OP1(OP, OT_None)
@ -373,6 +379,7 @@ static ArrayRef<OperandType[2]> getOperandTypes() {
#undef DECLARE_OP0
#undef DECLARE_OP1
#undef DECLARE_OP2
return ArrayRef<OperandType[2]>(&OpTypes[0], DW_CFA_restore+1);
}
@ -668,7 +675,6 @@ void DWARFDebugFrame::parse(DataExtractor Data) {
}
}
void DWARFDebugFrame::dump(raw_ostream &OS) const {
OS << "\n";
for (const auto &Entry : Entries) {
@ -677,4 +683,3 @@ void DWARFDebugFrame::dump(raw_ostream &OS) const {
OS << "\n";
}
}

View File

@ -24,9 +24,15 @@
#ifndef LLVM_LIB_TARGET_X86_X86INSTRBUILDER_H
#define LLVM_LIB_TARGET_X86_X86INSTRBUILDER_H
#include "llvm/ADT/SmallVector.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/MC/MCInstrDesc.h"
#include <cassert>
namespace llvm {
@ -57,12 +63,11 @@ struct X86AddressMode {
Base.Reg = 0;
}
void getFullAddress(SmallVectorImpl<MachineOperand> &MO) {
assert(Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8);
if (BaseType == X86AddressMode::RegBase)
MO.push_back(MachineOperand::CreateReg(Base.Reg, false, false,
MO.push_back(MachineOperand::CreateReg(Base.Reg, false, false, false,
false, false, false, 0, false));
else {
assert(BaseType == X86AddressMode::FrameIndexBase);
@ -70,16 +75,16 @@ struct X86AddressMode {
}
MO.push_back(MachineOperand::CreateImm(Scale));
MO.push_back(MachineOperand::CreateReg(IndexReg, false, false,
false, false, false, 0, false));
MO.push_back(MachineOperand::CreateReg(IndexReg, false, false, false, false,
false, false, 0, false));
if (GV)
MO.push_back(MachineOperand::CreateGA(GV, Disp, GVOpFlags));
else
MO.push_back(MachineOperand::CreateImm(Disp));
MO.push_back(MachineOperand::CreateReg(0, false, false,
false, false, false, 0, false));
MO.push_back(MachineOperand::CreateReg(0, false, false, false, false, false,
false, 0, false));
}
};
@ -206,6 +211,6 @@ addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI,
.addConstantPoolIndex(CPI, 0, OpFlags).addReg(0);
}
} // End llvm namespace
} // end namespace llvm
#endif
#endif // LLVM_LIB_TARGET_X86_X86INSTRBUILDER_H