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

Axel Lundberg via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 12 04:32:39 PDT 2024


================
@@ -5571,11 +5571,52 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
       break;
     }
 
-    RValue RV = EmitAnyExpr(E->getRHS());
+    llvm::Value *Previous = nullptr;
+    RValue RV;
+    QualType SrcType = E->getRHS()->getType();
+    // Check if LHS is a bitfield, if RHS contains an implicit cast expression
+    // we want to extract that value and potentially (if the bitfield sanitizer
+    // is enabled) use it to check for an implicit conversion.
+    if (E->getLHS()->refersToBitField()) {
+      // Get the RHS before scalar conversion.
+      if (auto *ICE = GetOriginalRHSForBitfieldSanitizer(E)) {
----------------
Zonotora wrote:

Will do!

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


More information about the cfe-commits mailing list