Skip to content

Commit 91f251c

Browse files
authored
[clang] Fix remove{CVR|Fast}Qualifiers with 64-bit Qualifiers::Mask (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.
1 parent b811ad6 commit 91f251c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang/include/clang/AST/Type.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ class Qualifiers {
480480
}
481481
void removeCVRQualifiers(unsigned mask) {
482482
assert(!(mask & ~CVRMask) && "bitmask contains non-CVR bits");
483-
Mask &= ~mask;
483+
Mask &= ~static_cast<uint64_t>(mask);
484484
}
485485
void removeCVRQualifiers() {
486486
removeCVRQualifiers(CVRMask);
@@ -609,7 +609,7 @@ class Qualifiers {
609609
}
610610
void removeFastQualifiers(unsigned mask) {
611611
assert(!(mask & ~FastMask) && "bitmask contains non-fast qualifier bits");
612-
Mask &= ~mask;
612+
Mask &= ~static_cast<uint64_t>(mask);
613613
}
614614
void removeFastQualifiers() {
615615
removeFastQualifiers(FastMask);

0 commit comments

Comments
 (0)