[clang] ca55f05 - [clang][SourceManager] Fix -Wparentheses warning (NFC)

Yang Fan via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 8 19:23:36 PDT 2021


Author: Yang Fan
Date: 2021-04-09T10:22:56+08:00
New Revision: ca55f0511698e5b64538e02eff9f6b2280282b15

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

LOG: [clang][SourceManager] Fix -Wparentheses warning (NFC)

GCC warning:
```
/llvm-project/clang/lib/Basic/SourceManager.cpp: In instantiation of ‘constexpr T likelyhasbetween(T, unsigned char, unsigned char) [with T = long unsigned int]’:
/llvm-project/clang/lib/Basic/SourceManager.cpp:1292:52:   required from here
/llvm-project/clang/lib/Basic/SourceManager.cpp:1264:48: warning: suggest parentheses around ‘+’ in operand of ‘&’ [-Wparentheses]
 1264 |           (x & ~static_cast<T>(0) / 255 * 127) +
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
 1265 |               (~static_cast<T>(0) / 255 * (127 - (m - 1)))) &
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Added: 
    

Modified: 
    clang/lib/Basic/SourceManager.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 438525b1ee13..2c8036aaf36a 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -1261,8 +1261,8 @@ template <class T>
 static constexpr inline T likelyhasbetween(T x, unsigned char m,
                                            unsigned char n) {
   return ((x - ~static_cast<T>(0) / 255 * (n + 1)) & ~x &
-          (x & ~static_cast<T>(0) / 255 * 127) +
-              (~static_cast<T>(0) / 255 * (127 - (m - 1)))) &
+          ((x & ~static_cast<T>(0) / 255 * 127) +
+           (~static_cast<T>(0) / 255 * (127 - (m - 1))))) &
          ~static_cast<T>(0) / 255 * 128;
 }
 


        


More information about the cfe-commits mailing list