[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 8 14:28:04 PST 2024


================
@@ -4564,15 +4737,41 @@ Value *ScalarExprEmitter::VisitBinAssign(const BinaryOperator *E) {
   case Qualifiers::OCL_None:
     // __block variables need to have the rhs evaluated first, plus
     // this should improve codegen just a little.
-    RHS = Visit(E->getRHS());
+    Value *Previous = nullptr;
+    QualType SrcType = E->getRHS()->getType();
+    // Check if LHS is a bitfield and sanitizer checks are enabled
+    if (E->getLHS()->refersToBitField() &&
+        CGF.SanOpts.hasOneOf(SanitizerKind::ImplicitConversion |
+                             SanitizerKind::ImplicitBitfieldConversion)) {
----------------
zygoloid wrote:

```suggestion
        CGF.SanOpts.hasOneOf(SanitizerKind::ImplicitBitfieldConversion)) {
```

https://github.com/llvm/llvm-project/pull/75481


More information about the cfe-commits mailing list