[PATCH] D79337: Silence warnings when compiling x86 with latest MSVC

2020-05-06 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3483cdc8344d: [Sema] Silence warnings when targeting x86 
with VS2019 16.5.4 (authored by aganea).

Changed prior to commit:
  https://reviews.llvm.org/D79337?vs=261848&id=262356#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79337/new/

https://reviews.llvm.org/D79337

Files:
  clang/lib/Sema/ParsedAttr.cpp


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: 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


[PATCH] D79337: Silence warnings when compiling x86 with latest MSVC

2020-05-04 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Will do, thank you for your time!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79337/new/

https://reviews.llvm.org/D79337



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79337: Silence warnings when compiling x86 with latest MSVC

2020-05-04 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Thanks, this lgtm. If you could split this up into two commits before landing 
it, I'd appreciate it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79337/new/

https://reviews.llvm.org/D79337



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79337: Silence warnings when compiling x86 with latest MSVC

2020-05-04 Thread Alexandre Ganea via Phabricator via cfe-commits
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