Index: cfe/trunk/lib/CodeGen/CGExpr.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGExpr.cpp +++ cfe/trunk/lib/CodeGen/CGExpr.cpp @@ -2825,7 +2825,7 @@ assert(IsSanitizerScope); assert(Checked.size() > 0); assert(CheckHandler >= 0 && - CheckHandler < sizeof(SanitizerHandlers) / sizeof(*SanitizerHandlers)); + size_t(CheckHandler) < llvm::array_lengthof(SanitizerHandlers)); const StringRef CheckName = SanitizerHandlers[CheckHandler].Name; llvm::Value *FatalCond = nullptr; Index: llvm/trunk/include/llvm/BinaryFormat/COFF.h =================================================================== --- llvm/trunk/include/llvm/BinaryFormat/COFF.h +++ llvm/trunk/include/llvm/BinaryFormat/COFF.h @@ -91,7 +91,7 @@ uint32_t NumberOfSymbols; }; -enum MachineTypes { +enum MachineTypes : unsigned { MT_Invalid = 0xffff, IMAGE_FILE_MACHINE_UNKNOWN = 0x0, @@ -118,7 +118,7 @@ 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 @@ IMAGE_FILE_BYTES_REVERSED_HI = 0x8000 }; -enum ResourceTypeID { +enum ResourceTypeID : unsigned { RID_Cursor = 1, RID_Bitmap = 2, RID_Icon = 3, @@ -234,7 +234,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ uint32_t Size; }; -enum DataDirectoryIndex { +enum DataDirectoryIndex : unsigned { EXPORT_TABLE = 0, IMPORT_TABLE, RESOURCE_TABLE, @@ -592,7 +592,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 Index: llvm/trunk/include/llvm/Object/COFF.h =================================================================== --- llvm/trunk/include/llvm/Object/COFF.h +++ llvm/trunk/include/llvm/Object/COFF.h @@ -926,7 +926,7 @@ 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; Index: llvm/trunk/include/llvm/Object/ELFObjectFile.h =================================================================== --- llvm/trunk/include/llvm/Object/ELFObjectFile.h +++ llvm/trunk/include/llvm/Object/ELFObjectFile.h @@ -362,7 +362,7 @@ 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 @@ } } -template -unsigned ELFObjectFile::getArch() const { +template Triple::ArchType ELFObjectFile::getArch() const { bool IsLittleEndian = ELFT::TargetEndianness == support::little; switch (EF.getHeader()->e_machine) { case ELF::EM_386: Index: llvm/trunk/include/llvm/Object/MachO.h =================================================================== --- llvm/trunk/include/llvm/Object/MachO.h +++ llvm/trunk/include/llvm/Object/MachO.h @@ -360,7 +360,7 @@ 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; Index: llvm/trunk/include/llvm/Object/ObjectFile.h =================================================================== --- llvm/trunk/include/llvm/Object/ObjectFile.h +++ llvm/trunk/include/llvm/Object/ObjectFile.h @@ -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 @@ 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 { } Index: llvm/trunk/include/llvm/Object/RelocVisitor.h =================================================================== --- llvm/trunk/include/llvm/Object/RelocVisitor.h +++ llvm/trunk/include/llvm/Object/RelocVisitor.h @@ -302,6 +302,8 @@ return Value; } break; + default: + break; } HasError = true; return 0; Index: llvm/trunk/include/llvm/Object/Wasm.h =================================================================== --- llvm/trunk/include/llvm/Object/Wasm.h +++ llvm/trunk/include/llvm/Object/Wasm.h @@ -201,7 +201,7 @@ 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; Index: llvm/trunk/lib/Analysis/InstructionSimplify.cpp =================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp @@ -327,7 +327,7 @@ // Check that the simplified value has the form "X op Y" where "op" is the // same as the original operation. Instruction *Simplified = dyn_cast(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. Index: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1769,7 +1769,7 @@ // If this node is not part of the or/and tree, emit it as a branch. if (!BOp || !(isa(BOp) || isa(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())) { Index: llvm/trunk/lib/Object/COFFObjectFile.cpp =================================================================== --- llvm/trunk/lib/Object/COFFObjectFile.cpp +++ llvm/trunk/lib/Object/COFFObjectFile.cpp @@ -895,7 +895,7 @@ } } -unsigned COFFObjectFile::getArch() const { +Triple::ArchType COFFObjectFile::getArch() const { switch (getMachine()) { case COFF::IMAGE_FILE_MACHINE_I386: return Triple::x86; Index: llvm/trunk/lib/Object/MachOObjectFile.cpp =================================================================== --- llvm/trunk/lib/Object/MachOObjectFile.cpp +++ llvm/trunk/lib/Object/MachOObjectFile.cpp @@ -2573,7 +2573,7 @@ .Default(false); } -unsigned MachOObjectFile::getArch() const { +Triple::ArchType MachOObjectFile::getArch() const { return getArch(getCPUType(*this)); } Index: llvm/trunk/lib/Object/WasmObjectFile.cpp =================================================================== --- llvm/trunk/lib/Object/WasmObjectFile.cpp +++ llvm/trunk/lib/Object/WasmObjectFile.cpp @@ -1038,7 +1038,7 @@ 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(); Index: llvm/trunk/lib/ProfileData/InstrProfReader.cpp =================================================================== --- llvm/trunk/lib/ProfileData/InstrProfReader.cpp +++ llvm/trunk/lib/ProfileData/InstrProfReader.cpp @@ -61,7 +61,7 @@ Expected> InstrProfReader::create(std::unique_ptr Buffer) { // Sanity check the buffer. - if (Buffer->getBufferSize() > std::numeric_limits::max()) + if (uint64_t(Buffer->getBufferSize()) > std::numeric_limits::max()) return make_error(instrprof_error::too_large); if (Buffer->getBufferSize() == 0) @@ -99,7 +99,7 @@ Expected> IndexedInstrProfReader::create(std::unique_ptr Buffer) { // Sanity check the buffer. - if (Buffer->getBufferSize() > std::numeric_limits::max()) + if (uint64_t(Buffer->getBufferSize()) > std::numeric_limits::max()) return make_error(instrprof_error::too_large); // Create the reader. Index: llvm/trunk/lib/ProfileData/SampleProfReader.cpp =================================================================== --- llvm/trunk/lib/ProfileData/SampleProfReader.cpp +++ llvm/trunk/lib/ProfileData/SampleProfReader.cpp @@ -749,7 +749,7 @@ auto Buffer = std::move(BufferOrErr.get()); // Sanity check the file. - if (Buffer->getBufferSize() > std::numeric_limits::max()) + if (uint64_t(Buffer->getBufferSize()) > std::numeric_limits::max()) return sampleprof_error::too_large; return std::move(Buffer); Index: llvm/trunk/lib/Support/ARMAttributeParser.cpp =================================================================== --- llvm/trunk/lib/Support/ARMAttributeParser.cpp +++ llvm/trunk/lib/Support/ARMAttributeParser.cpp @@ -592,7 +592,7 @@ 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; Index: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp =================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp @@ -30276,7 +30276,7 @@ // 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();