xgupta created this revision. xgupta added reviewers: aaron.ballman, usaxena95. Herald added a project: All. xgupta requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Found by PVS-Studio - https://pvs-studio.com/en/blog/posts/cpp/1003/, N37. The code you is using the bit mask NullabilityKindMask which is 0x3 (00000011 in binary) to clear the bits in the NullabilityPayload variable. Since NullabilityPayload is a 64-bit variable and NullabilityKindMask is only a 8-bit variable(0x3), it will only affect the last 8 bits of the variable. The higher 56 bits will remain unchanged. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D142334 Files: clang/include/clang/APINotes/Types.h Index: clang/include/clang/APINotes/Types.h =================================================================== --- clang/include/clang/APINotes/Types.h +++ clang/include/clang/APINotes/Types.h @@ -532,7 +532,7 @@ // Mask the bits. NullabilityPayload &= - ~(NullabilityKindMask << (index * NullabilityKindSize)); + ~(static_cast<uint64_t>NullabilityKindMask << (index * NullabilityKindSize)); // Set the value. unsigned kindValue = (static_cast<unsigned>(kind))
Index: clang/include/clang/APINotes/Types.h =================================================================== --- clang/include/clang/APINotes/Types.h +++ clang/include/clang/APINotes/Types.h @@ -532,7 +532,7 @@ // Mask the bits. NullabilityPayload &= - ~(NullabilityKindMask << (index * NullabilityKindSize)); + ~(static_cast<uint64_t>NullabilityKindMask << (index * NullabilityKindSize)); // Set the value. unsigned kindValue = (static_cast<unsigned>(kind))
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits