Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clang] NFC Silence compiler warning spam #86532

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

NagyDonat
Copy link
Contributor

@NagyDonat NagyDonat commented Mar 25, 2024

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 is included into very many source files (through various chains of 6-7 header files).

This non-functional change eliminates the compiler warning
/repo/llvm-project/clang/include/clang/Basic/SyncScope.h: In member function ‘virtual bool clang::AtomicS
copeGenericModel::isValid(unsigned int) const’:
/repo/llvm-project/clang/include/clang/Basic/SyncScope.h:255:14: warning: comparison of unsigned expressi
on >= 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).
@NagyDonat NagyDonat requested a review from jhuber6 March 25, 2024 16:59
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Mar 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 25, 2024

@llvm/pr-subscribers-clang

Author: None (NagyDonat)

Changes

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 &gt;= 0 is always true [-Wtype-limits]
     return S &gt;= static_cast&lt;unsigned&gt;(System) &amp;&amp;
            ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

@NagyDonat
Copy link
Contributor Author

NagyDonat commented Mar 25, 2024

(By the way, I'm also fine with any other resolution that would silence this warning.)

Copy link

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link

✅ With the latest revision this PR passed the Python code formatter.

@NagyDonat NagyDonat requested a review from yxsamliu March 25, 2024 17:18
@NagyDonat NagyDonat merged commit 4fa736b into llvm:main Mar 26, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants