diff --git a/clang/lib/Sema/ParsedAttr.cpp b/clang/lib/Sema/ParsedAttr.cpp --- a/clang/lib/Sema/ParsedAttr.cpp +++ b/clang/lib/Sema/ParsedAttr.cpp @@ -111,7 +111,7 @@ const ParsedAttrInfo &ParsedAttrInfo::get(const AttributeCommonInfo &A) { // If we have a ParsedAttrInfo for this ParsedAttr then return that. - if (A.getParsedKind() < llvm::array_lengthof(AttrInfoMap)) + if ((size_t)A.getParsedKind() < llvm::array_lengthof(AttrInfoMap)) return *AttrInfoMap[A.getParsedKind()]; // If this is an ignored attribute then return an appropriate ParsedAttrInfo. diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp --- a/llvm/lib/ProfileData/InstrProfReader.cpp +++ b/llvm/lib/ProfileData/InstrProfReader.cpp @@ -423,11 +423,11 @@ // Check bounds. Note that the counter pointer embedded in the data record // may itself be corrupt. - if (NumCounters > MaxNumCounters) + if (MaxNumCounters < 0 || NumCounters > (uint32_t)MaxNumCounters) return error(instrprof_error::malformed); ptrdiff_t CounterOffset = getCounterOffset(CounterPtr); if (CounterOffset < 0 || CounterOffset > MaxNumCounters || - (CounterOffset + NumCounters) > MaxNumCounters) + ((uint32_t)CounterOffset + NumCounters) > (uint32_t)MaxNumCounters) return error(instrprof_error::malformed); auto RawCounts = makeArrayRef(getCounter(CounterOffset), NumCounters);