[llvm] 814c65d - ExecutionDomainFix - fix static analyzer out of range shift warnings.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 12 11:53:28 PDT 2020
Author: Simon Pilgrim
Date: 2020-03-12T18:52:56Z
New Revision: 814c65dedce949b8216ef819698c06c6f8f40de0
URL: https://github.com/llvm/llvm-project/commit/814c65dedce949b8216ef819698c06c6f8f40de0
DIFF: https://github.com/llvm/llvm-project/commit/814c65dedce949b8216ef819698c06c6f8f40de0.diff
LOG: ExecutionDomainFix - fix static analyzer out of range shift warnings.
Repeat the assertion that we already have in hasDomain for addDomain and setSingleDomain.
Added:
Modified:
llvm/include/llvm/CodeGen/ExecutionDomainFix.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/ExecutionDomainFix.h b/llvm/include/llvm/CodeGen/ExecutionDomainFix.h
index 6836678e2101..f1602c223b4d 100644
--- a/llvm/include/llvm/CodeGen/ExecutionDomainFix.h
+++ b/llvm/include/llvm/CodeGen/ExecutionDomainFix.h
@@ -81,10 +81,20 @@ struct DomainValue {
}
/// Mark domain as available.
- void addDomain(unsigned domain) { AvailableDomains |= 1u << domain; }
+ void addDomain(unsigned domain) {
+ assert(domain <
+ static_cast<unsigned>(std::numeric_limits<unsigned>::digits) &&
+ "undefined behavior");
+ AvailableDomains |= 1u << domain;
+ }
// Restrict to a single domain available.
- void setSingleDomain(unsigned domain) { AvailableDomains = 1u << domain; }
+ void setSingleDomain(unsigned domain) {
+ assert(domain <
+ static_cast<unsigned>(std::numeric_limits<unsigned>::digits) &&
+ "undefined behavior");
+ AvailableDomains = 1u << domain;
+ }
/// Return bitmask of domains that are available and in mask.
unsigned getCommonDomains(unsigned mask) const {
More information about the llvm-commits
mailing list