summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2024-04-03 10:27:09 -0700
committerGitHub <noreply@github.com>2024-04-03 10:27:09 -0700
commit5822ca5a013256bbca33fbbae56f49caa2e37fe3 (patch)
tree70264248326cd40964719bb9b76236e71df0ec4f /clang/lib/CodeGen/CGExpr.cpp
parent315c88c5fbdb2b27cebf23c87fb502f7a567d84b (diff)
Revert "[clang][UBSan] Add implicit conversion check for bitfields" (#87518)
Reverts llvm/llvm-project#75481 Breaks multiple bots, see #75481
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp37
1 files changed, 2 insertions, 35 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 0c7f48fe0060..54432353e742 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -5580,44 +5580,11 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
break;
}
- // TODO: Can we de-duplicate this code with the corresponding code in
- // CGExprScalar, similar to the way EmitCompoundAssignmentLValue works?
- RValue RV;
- llvm::Value *Previous = nullptr;
- 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()) {
- llvm::Value *RHS =
- EmitWithOriginalRHSBitfieldAssignment(E, Previous, &SrcType);
- RV = RValue::get(RHS);
- } else
- RV = EmitAnyExpr(E->getRHS());
-
+ RValue RV = EmitAnyExpr(E->getRHS());
LValue LV = EmitCheckedLValue(E->getLHS(), TCK_Store);
-
if (RV.isScalar())
EmitNullabilityCheck(LV, RV.getScalarVal(), E->getExprLoc());
-
- if (LV.isBitField()) {
- llvm::Value *Result = nullptr;
- // If bitfield sanitizers are enabled we want to use the result
- // to check whether a truncation or sign change has occurred.
- if (SanOpts.has(SanitizerKind::ImplicitBitfieldConversion))
- EmitStoreThroughBitfieldLValue(RV, LV, &Result);
- else
- EmitStoreThroughBitfieldLValue(RV, LV);
-
- // If the expression contained an implicit conversion, make sure
- // to use the value before the scalar conversion.
- llvm::Value *Src = Previous ? Previous : RV.getScalarVal();
- QualType DstType = E->getLHS()->getType();
- EmitBitfieldConversionCheck(Src, SrcType, Result, DstType,
- LV.getBitFieldInfo(), E->getExprLoc());
- } else
- EmitStoreThroughLValue(RV, LV);
-
+ EmitStoreThroughLValue(RV, LV);
if (getLangOpts().OpenMP)
CGM.getOpenMPRuntime().checkAndEmitLastprivateConditional(*this,
E->getLHS());