aganea created this revision.
aganea added reviewers: bkramer, john.brawn, vsk.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.
When using Visual Studio 2019 16.5.4, and targetting 32-bit, before this patch
we were seeing:
[1378/3007] Building CXX object
lib\ProfileData\CMakeFiles\LLVMProfileData.dir\InstrProfReader.cpp.obj
F:\llvm-project\llvm\lib\ProfileData\InstrProfReader.cpp(426): warning C4018:
'>': signed/unsigned mismatch
F:\llvm-project\llvm\lib\ProfileData\InstrProfReader.cpp(415): note: while
compiling class template member function 'llvm::Error
llvm::RawInstrProfReader::readRawCounts(llvm::InstrProfRecord &)'
F:\llvm-project\llvm\lib\ProfileData\InstrProfReader.cpp(491): note: see
reference to function template instantiation 'llvm::Error
llvm::RawInstrProfReader::readRawCounts(llvm::InstrProfRecord &)'
being compiled
F:\llvm-project\llvm\lib\ProfileData\InstrProfReader.cpp(78): note: see
reference to class template instantiation 'llvm::RawInstrProfReader'
being compiled
F:\llvm-project\llvm\lib\ProfileData\InstrProfReader.cpp(430): warning C4018:
'>': signed/unsigned mismatch
And:
[2060/3007] Building CXX object
tools\clang\lib\Sema\CMakeFiles\obj.clangSema.dir\ParsedAttr.cpp.obj
F:\llvm-project\clang\lib\Sema\ParsedAttr.cpp(114): warning C4018: '<':
signed/unsigned mismatch
I can commit the two files independently if you prefer.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79337
Files:
clang/lib/Sema/ParsedAttr.cpp
llvm/lib/ProfileData/InstrProfReader.cpp
Index: llvm/lib/ProfileData/InstrProfReader.cpp
===
--- llvm/lib/ProfileData/InstrProfReader.cpp
+++ 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);
Index: clang/lib/Sema/ParsedAttr.cpp
===
--- clang/lib/Sema/ParsedAttr.cpp
+++ 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.
Index: llvm/lib/ProfileData/InstrProfReader.cpp
===
--- llvm/lib/ProfileData/InstrProfReader.cpp
+++ 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);
Index: clang/lib/Sema/ParsedAttr.cpp
===
--- clang/lib/Sema/ParsedAttr.cpp
+++ 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.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits