Skip to content

Commit

Permalink
[clang] Fix remove{CVR|Fast}Qualifiers with 64-bit `Qualifiers::Mas…
Browse files Browse the repository at this point in the history
…k` (llvm#90329)

After llvm#84384, `Qualifiers::Mask` becomes 64-bit. So, operations like
`Mask &= ~U32` where `U32` is `unsigned` produce undesirable results
since higher 32 bits of `Mask` become zeroed while they should be
preserved. Fix that by explicitly casting `unsigned` values to
`uint64_t` in such operations. Signatures of fixed functions are
intentionally left intact instead of changing the argument itself to
`uint64_t` to keep things consistent with other functions working with
the same qualifiers and to emphasize that 64-bit masks should not be
used for these types of qualifiers.
  • Loading branch information
kovdan01 authored Apr 29, 2024
1 parent b811ad6 commit 91f251c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ class Qualifiers {
}
void removeCVRQualifiers(unsigned mask) {
assert(!(mask & ~CVRMask) && "bitmask contains non-CVR bits");
Mask &= ~mask;
Mask &= ~static_cast<uint64_t>(mask);
}
void removeCVRQualifiers() {
removeCVRQualifiers(CVRMask);
Expand Down Expand Up @@ -609,7 +609,7 @@ class Qualifiers {
}
void removeFastQualifiers(unsigned mask) {
assert(!(mask & ~FastMask) && "bitmask contains non-fast qualifier bits");
Mask &= ~mask;
Mask &= ~static_cast<uint64_t>(mask);
}
void removeFastQualifiers() {
removeFastQualifiers(FastMask);
Expand Down

0 comments on commit 91f251c

Please sign in to comment.