[clang] eef7054 - [Basic] Fix a warning

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 30 08:57:14 PST 2022


Author: Kazu Hirata
Date: 2022-11-30T08:57:05-08:00
New Revision: eef7054f331b18c695a278704a6dd0b31dcd2be0

URL: https://github.com/llvm/llvm-project/commit/eef7054f331b18c695a278704a6dd0b31dcd2be0
DIFF: https://github.com/llvm/llvm-project/commit/eef7054f331b18c695a278704a6dd0b31dcd2be0.diff

LOG: [Basic] Fix a warning

This patch fixes:

  clang/lib/Basic/SourceManager.cpp:1292:19: error: comparison of
  integers of different signs: 'long' and 'unsigned long'
  [-Werror,-Wsign-compare]

Added: 
    

Modified: 
    clang/lib/Basic/SourceManager.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index f61dc0f0f3f7..a5f673fadf6f 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -1289,7 +1289,7 @@ LineOffsetMapping LineOffsetMapping::get(llvm::MemoryBufferRef Buffer,
 
   // scan sizeof(Word) bytes at a time for new lines.
   // This is much faster than scanning each byte independently.
-  if (End - Start > sizeof(Word)) {
+  if ((unsigned long)(End - Start) > sizeof(Word)) {
     do {
       Word = llvm::support::endian::read64(Buf, llvm::support::little);
       // no new line => jump over sizeof(Word) bytes.


        


More information about the cfe-commits mailing list