[clang] [Clang] NFC Silence compiler warning spam (PR #86532)

via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 25 10:00:31 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: None (NagyDonat)

<details>
<summary>Changes</summary>

This non-functional change eliminates the compiler warning
```
/repo/llvm-project/clang/include/clang/Basic/SyncScope.h: In member function ‘virtual bool clang::AtomicScopeGenericModel::isValid(unsigned int) const’:
/repo/llvm-project/clang/include/clang/Basic/SyncScope.h:255:14: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
     return S >= static_cast<unsigned>(System) &&
            ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
which was appearing repeatedly, as this header was included into very many source files (through chains of 6-7 header files).

---
Full diff: https://github.com/llvm/llvm-project/pull/86532.diff


1 Files Affected:

- (modified) clang/include/clang/Basic/SyncScope.h (+1-2) 


``````````diff
diff --git a/clang/include/clang/Basic/SyncScope.h b/clang/include/clang/Basic/SyncScope.h
index bc7ec7b5cf777e..45beff41afa11d 100644
--- a/clang/include/clang/Basic/SyncScope.h
+++ b/clang/include/clang/Basic/SyncScope.h
@@ -252,8 +252,7 @@ class AtomicScopeGenericModel : public AtomicScopeModel {
   }
 
   bool isValid(unsigned S) const override {
-    return S >= static_cast<unsigned>(System) &&
-           S <= static_cast<unsigned>(Last);
+    return S <= static_cast<unsigned>(Last);
   }
 
   ArrayRef<unsigned> getRuntimeValues() const override {

``````````

</details>


https://github.com/llvm/llvm-project/pull/86532


More information about the cfe-commits mailing list