mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
Fix many -Wsign-compare and -Wtautological-constant-compare warnings.
Most of the -Wsign-compare warnings are due to the fact that enums are signed by default in the MS ABI, while the tautological comparison warnings trigger on x86 builds where sizeof(size_t) is 4 bytes, so N > numeric_limits<unsigned>::max() is always false. Differential Revision: https://reviews.llvm.org/D41256 llvm-svn: 320750
This commit is contained in:
parent
b03cfaf7ce
commit
7655f081e8
@ -91,7 +91,7 @@ struct BigObjHeader {
|
||||
uint32_t NumberOfSymbols;
|
||||
};
|
||||
|
||||
enum MachineTypes {
|
||||
enum MachineTypes : unsigned {
|
||||
MT_Invalid = 0xffff,
|
||||
|
||||
IMAGE_FILE_MACHINE_UNKNOWN = 0x0,
|
||||
@ -118,7 +118,7 @@ enum MachineTypes {
|
||||
IMAGE_FILE_MACHINE_WCEMIPSV2 = 0x169
|
||||
};
|
||||
|
||||
enum Characteristics {
|
||||
enum Characteristics : unsigned {
|
||||
C_Invalid = 0,
|
||||
|
||||
/// The file does not contain base relocations and must be loaded at its
|
||||
@ -158,7 +158,7 @@ enum Characteristics {
|
||||
IMAGE_FILE_BYTES_REVERSED_HI = 0x8000
|
||||
};
|
||||
|
||||
enum ResourceTypeID {
|
||||
enum ResourceTypeID : unsigned {
|
||||
RID_Cursor = 1,
|
||||
RID_Bitmap = 2,
|
||||
RID_Icon = 3,
|
||||
@ -234,7 +234,7 @@ enum SymbolStorageClass {
|
||||
IMAGE_SYM_CLASS_CLR_TOKEN = 107
|
||||
};
|
||||
|
||||
enum SymbolBaseType {
|
||||
enum SymbolBaseType : unsigned {
|
||||
IMAGE_SYM_TYPE_NULL = 0, ///< No type information or unknown base type.
|
||||
IMAGE_SYM_TYPE_VOID = 1, ///< Used with void pointers and functions.
|
||||
IMAGE_SYM_TYPE_CHAR = 2, ///< A character (signed byte).
|
||||
@ -253,7 +253,7 @@ enum SymbolBaseType {
|
||||
IMAGE_SYM_TYPE_DWORD = 15 ///< An unsigned 4-byte integer.
|
||||
};
|
||||
|
||||
enum SymbolComplexType {
|
||||
enum SymbolComplexType : unsigned {
|
||||
IMAGE_SYM_DTYPE_NULL = 0, ///< No complex type; simple scalar variable.
|
||||
IMAGE_SYM_DTYPE_POINTER = 1, ///< A pointer to base type.
|
||||
IMAGE_SYM_DTYPE_FUNCTION = 2, ///< A function that returns a base type.
|
||||
@ -325,7 +325,7 @@ struct relocation {
|
||||
uint16_t Type;
|
||||
};
|
||||
|
||||
enum RelocationTypeI386 {
|
||||
enum RelocationTypeI386 : unsigned {
|
||||
IMAGE_REL_I386_ABSOLUTE = 0x0000,
|
||||
IMAGE_REL_I386_DIR16 = 0x0001,
|
||||
IMAGE_REL_I386_REL16 = 0x0002,
|
||||
@ -339,7 +339,7 @@ enum RelocationTypeI386 {
|
||||
IMAGE_REL_I386_REL32 = 0x0014
|
||||
};
|
||||
|
||||
enum RelocationTypeAMD64 {
|
||||
enum RelocationTypeAMD64 : unsigned {
|
||||
IMAGE_REL_AMD64_ABSOLUTE = 0x0000,
|
||||
IMAGE_REL_AMD64_ADDR64 = 0x0001,
|
||||
IMAGE_REL_AMD64_ADDR32 = 0x0002,
|
||||
@ -359,7 +359,7 @@ enum RelocationTypeAMD64 {
|
||||
IMAGE_REL_AMD64_SSPAN32 = 0x0010
|
||||
};
|
||||
|
||||
enum RelocationTypesARM {
|
||||
enum RelocationTypesARM : unsigned {
|
||||
IMAGE_REL_ARM_ABSOLUTE = 0x0000,
|
||||
IMAGE_REL_ARM_ADDR32 = 0x0001,
|
||||
IMAGE_REL_ARM_ADDR32NB = 0x0002,
|
||||
@ -377,7 +377,7 @@ enum RelocationTypesARM {
|
||||
IMAGE_REL_ARM_BLX23T = 0x0015
|
||||
};
|
||||
|
||||
enum RelocationTypesARM64 {
|
||||
enum RelocationTypesARM64 : unsigned {
|
||||
IMAGE_REL_ARM64_ABSOLUTE = 0x0000,
|
||||
IMAGE_REL_ARM64_ADDR32 = 0x0001,
|
||||
IMAGE_REL_ARM64_ADDR32NB = 0x0002,
|
||||
@ -397,7 +397,7 @@ enum RelocationTypesARM64 {
|
||||
IMAGE_REL_ARM64_BRANCH14 = 0x0010,
|
||||
};
|
||||
|
||||
enum COMDATType {
|
||||
enum COMDATType : unsigned {
|
||||
IMAGE_COMDAT_SELECT_NODUPLICATES = 1,
|
||||
IMAGE_COMDAT_SELECT_ANY,
|
||||
IMAGE_COMDAT_SELECT_SAME_SIZE,
|
||||
@ -430,7 +430,7 @@ struct AuxiliaryWeakExternal {
|
||||
uint8_t unused[10];
|
||||
};
|
||||
|
||||
enum WeakExternalCharacteristics {
|
||||
enum WeakExternalCharacteristics : unsigned {
|
||||
IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY = 1,
|
||||
IMAGE_WEAK_EXTERN_SEARCH_LIBRARY = 2,
|
||||
IMAGE_WEAK_EXTERN_SEARCH_ALIAS = 3
|
||||
@ -572,7 +572,7 @@ struct DataDirectory {
|
||||
uint32_t Size;
|
||||
};
|
||||
|
||||
enum DataDirectoryIndex {
|
||||
enum DataDirectoryIndex : unsigned {
|
||||
EXPORT_TABLE = 0,
|
||||
IMPORT_TABLE,
|
||||
RESOURCE_TABLE,
|
||||
@ -592,7 +592,7 @@ enum DataDirectoryIndex {
|
||||
NUM_DATA_DIRECTORIES
|
||||
};
|
||||
|
||||
enum WindowsSubsystem {
|
||||
enum WindowsSubsystem : unsigned {
|
||||
IMAGE_SUBSYSTEM_UNKNOWN = 0, ///< An unknown subsystem.
|
||||
IMAGE_SUBSYSTEM_NATIVE = 1, ///< Device drivers and native Windows processes
|
||||
IMAGE_SUBSYSTEM_WINDOWS_GUI = 2, ///< The Windows GUI subsystem.
|
||||
@ -611,7 +611,7 @@ enum WindowsSubsystem {
|
||||
IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16 ///< A BCD application.
|
||||
};
|
||||
|
||||
enum DLLCharacteristics {
|
||||
enum DLLCharacteristics : unsigned {
|
||||
/// ASLR with 64 bit address space.
|
||||
IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA = 0x0020,
|
||||
/// DLL can be relocated at load time.
|
||||
@ -637,7 +637,7 @@ enum DLLCharacteristics {
|
||||
IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000
|
||||
};
|
||||
|
||||
enum DebugType {
|
||||
enum DebugType : unsigned {
|
||||
IMAGE_DEBUG_TYPE_UNKNOWN = 0,
|
||||
IMAGE_DEBUG_TYPE_COFF = 1,
|
||||
IMAGE_DEBUG_TYPE_CODEVIEW = 2,
|
||||
@ -657,7 +657,7 @@ enum DebugType {
|
||||
IMAGE_DEBUG_TYPE_REPRO = 16,
|
||||
};
|
||||
|
||||
enum BaseRelocationType {
|
||||
enum BaseRelocationType : unsigned {
|
||||
IMAGE_REL_BASED_ABSOLUTE = 0,
|
||||
IMAGE_REL_BASED_HIGH = 1,
|
||||
IMAGE_REL_BASED_LOW = 2,
|
||||
@ -670,9 +670,13 @@ enum BaseRelocationType {
|
||||
IMAGE_REL_BASED_DIR64 = 10
|
||||
};
|
||||
|
||||
enum ImportType { IMPORT_CODE = 0, IMPORT_DATA = 1, IMPORT_CONST = 2 };
|
||||
enum ImportType : unsigned {
|
||||
IMPORT_CODE = 0,
|
||||
IMPORT_DATA = 1,
|
||||
IMPORT_CONST = 2
|
||||
};
|
||||
|
||||
enum ImportNameType {
|
||||
enum ImportNameType : unsigned {
|
||||
/// Import is by ordinal. This indicates that the value in the Ordinal/Hint
|
||||
/// field of the import header is the import's ordinal. If this constant is
|
||||
/// not specified, then the Ordinal/Hint field should always be interpreted
|
||||
|
@ -926,7 +926,7 @@ public:
|
||||
|
||||
uint8_t getBytesInAddress() const override;
|
||||
StringRef getFileFormatName() const override;
|
||||
unsigned getArch() const override;
|
||||
Triple::ArchType getArch() const override;
|
||||
SubtargetFeatures getFeatures() const override { return SubtargetFeatures(); }
|
||||
|
||||
import_directory_iterator import_directory_begin() const;
|
||||
|
@ -362,7 +362,7 @@ public:
|
||||
|
||||
uint8_t getBytesInAddress() const override;
|
||||
StringRef getFileFormatName() const override;
|
||||
unsigned getArch() const override;
|
||||
Triple::ArchType getArch() const override;
|
||||
|
||||
std::error_code getPlatformFlags(unsigned &Result) const override {
|
||||
Result = EF.getHeader()->e_flags;
|
||||
@ -1026,8 +1026,7 @@ StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
|
||||
}
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
unsigned ELFObjectFile<ELFT>::getArch() const {
|
||||
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
|
||||
bool IsLittleEndian = ELFT::TargetEndianness == support::little;
|
||||
switch (EF.getHeader()->e_machine) {
|
||||
case ELF::EM_386:
|
||||
|
@ -360,7 +360,7 @@ public:
|
||||
uint8_t getBytesInAddress() const override;
|
||||
|
||||
StringRef getFileFormatName() const override;
|
||||
unsigned getArch() const override;
|
||||
Triple::ArchType getArch() const override;
|
||||
SubtargetFeatures getFeatures() const override { return SubtargetFeatures(); }
|
||||
Triple getArchTriple(const char **McpuDefault = nullptr) const;
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#define LLVM_OBJECT_OBJECTFILE_H
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/BinaryFormat/Magic.h"
|
||||
#include "llvm/MC/SubtargetFeature.h"
|
||||
@ -279,7 +280,7 @@ public:
|
||||
virtual uint8_t getBytesInAddress() const = 0;
|
||||
|
||||
virtual StringRef getFileFormatName() const = 0;
|
||||
virtual /* Triple::ArchType */ unsigned getArch() const = 0;
|
||||
virtual Triple::ArchType getArch() const = 0;
|
||||
virtual SubtargetFeatures getFeatures() const = 0;
|
||||
virtual void setARMSubArch(Triple &TheTriple) const { }
|
||||
|
||||
|
@ -302,6 +302,8 @@ private:
|
||||
return Value;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
HasError = true;
|
||||
return 0;
|
||||
|
@ -201,7 +201,7 @@ public:
|
||||
section_iterator section_end() const override;
|
||||
uint8_t getBytesInAddress() const override;
|
||||
StringRef getFileFormatName() const override;
|
||||
unsigned getArch() const override;
|
||||
Triple::ArchType getArch() const override;
|
||||
SubtargetFeatures getFeatures() const override;
|
||||
bool isRelocatableObject() const override;
|
||||
|
||||
|
@ -327,7 +327,7 @@ static Value *ThreadBinOpOverSelect(Instruction::BinaryOps Opcode, Value *LHS,
|
||||
// Check that the simplified value has the form "X op Y" where "op" is the
|
||||
// same as the original operation.
|
||||
Instruction *Simplified = dyn_cast<Instruction>(FV ? FV : TV);
|
||||
if (Simplified && Simplified->getOpcode() == Opcode) {
|
||||
if (Simplified && Simplified->getOpcode() == unsigned(Opcode)) {
|
||||
// The value that didn't simplify is "UnsimplifiedLHS op UnsimplifiedRHS".
|
||||
// We already know that "op" is the same as for the simplified value. See
|
||||
// if the operands match too. If so, return the simplified value.
|
||||
|
@ -1769,7 +1769,7 @@ void SelectionDAGBuilder::FindMergedConditions(const Value *Cond,
|
||||
|
||||
// If this node is not part of the or/and tree, emit it as a branch.
|
||||
if (!BOp || !(isa<BinaryOperator>(BOp) || isa<CmpInst>(BOp)) ||
|
||||
BOpc != Opc || !BOp->hasOneUse() ||
|
||||
BOpc != unsigned(Opc) || !BOp->hasOneUse() ||
|
||||
BOp->getParent() != CurBB->getBasicBlock() ||
|
||||
!InBlock(BOp->getOperand(0), CurBB->getBasicBlock()) ||
|
||||
!InBlock(BOp->getOperand(1), CurBB->getBasicBlock())) {
|
||||
|
@ -895,7 +895,7 @@ StringRef COFFObjectFile::getFileFormatName() const {
|
||||
}
|
||||
}
|
||||
|
||||
unsigned COFFObjectFile::getArch() const {
|
||||
Triple::ArchType COFFObjectFile::getArch() const {
|
||||
switch (getMachine()) {
|
||||
case COFF::IMAGE_FILE_MACHINE_I386:
|
||||
return Triple::x86;
|
||||
|
@ -2573,7 +2573,7 @@ bool MachOObjectFile::isValidArch(StringRef ArchFlag) {
|
||||
.Default(false);
|
||||
}
|
||||
|
||||
unsigned MachOObjectFile::getArch() const {
|
||||
Triple::ArchType MachOObjectFile::getArch() const {
|
||||
return getArch(getCPUType(*this));
|
||||
}
|
||||
|
||||
|
@ -1038,7 +1038,7 @@ uint8_t WasmObjectFile::getBytesInAddress() const { return 4; }
|
||||
|
||||
StringRef WasmObjectFile::getFileFormatName() const { return "WASM"; }
|
||||
|
||||
unsigned WasmObjectFile::getArch() const { return Triple::wasm32; }
|
||||
Triple::ArchType WasmObjectFile::getArch() const { return Triple::wasm32; }
|
||||
|
||||
SubtargetFeatures WasmObjectFile::getFeatures() const {
|
||||
return SubtargetFeatures();
|
||||
|
@ -61,7 +61,7 @@ InstrProfReader::create(const Twine &Path) {
|
||||
Expected<std::unique_ptr<InstrProfReader>>
|
||||
InstrProfReader::create(std::unique_ptr<MemoryBuffer> Buffer) {
|
||||
// Sanity check the buffer.
|
||||
if (Buffer->getBufferSize() > std::numeric_limits<unsigned>::max())
|
||||
if (uint64_t(Buffer->getBufferSize()) > std::numeric_limits<unsigned>::max())
|
||||
return make_error<InstrProfError>(instrprof_error::too_large);
|
||||
|
||||
if (Buffer->getBufferSize() == 0)
|
||||
@ -99,7 +99,7 @@ IndexedInstrProfReader::create(const Twine &Path) {
|
||||
Expected<std::unique_ptr<IndexedInstrProfReader>>
|
||||
IndexedInstrProfReader::create(std::unique_ptr<MemoryBuffer> Buffer) {
|
||||
// Sanity check the buffer.
|
||||
if (Buffer->getBufferSize() > std::numeric_limits<unsigned>::max())
|
||||
if (uint64_t(Buffer->getBufferSize()) > std::numeric_limits<unsigned>::max())
|
||||
return make_error<InstrProfError>(instrprof_error::too_large);
|
||||
|
||||
// Create the reader.
|
||||
|
@ -749,7 +749,7 @@ setupMemoryBuffer(const Twine &Filename) {
|
||||
auto Buffer = std::move(BufferOrErr.get());
|
||||
|
||||
// Sanity check the file.
|
||||
if (Buffer->getBufferSize() > std::numeric_limits<uint32_t>::max())
|
||||
if (uint64_t(Buffer->getBufferSize()) > std::numeric_limits<uint32_t>::max())
|
||||
return sampleprof_error::too_large;
|
||||
|
||||
return std::move(Buffer);
|
||||
|
@ -592,7 +592,7 @@ void ARMAttributeParser::ParseAttributeList(const uint8_t *Data,
|
||||
bool Handled = false;
|
||||
for (unsigned AHI = 0, AHE = array_lengthof(DisplayRoutines);
|
||||
AHI != AHE && !Handled; ++AHI) {
|
||||
if (DisplayRoutines[AHI].Attribute == Tag) {
|
||||
if (uint64_t(DisplayRoutines[AHI].Attribute) == Tag) {
|
||||
(this->*DisplayRoutines[AHI].Routine)(ARMBuildAttrs::AttrType(Tag),
|
||||
Data, Offset);
|
||||
Handled = true;
|
||||
|
@ -30276,7 +30276,7 @@ static SDValue matchBinOpReduction(SDNode *Extract, unsigned &BinOp,
|
||||
|
||||
// Match against one of the candidate binary ops.
|
||||
if (llvm::none_of(CandidateBinOps, [Op](ISD::NodeType BinOp) {
|
||||
return Op.getOpcode() == BinOp;
|
||||
return Op.getOpcode() == unsigned(BinOp);
|
||||
}))
|
||||
return SDValue();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user