aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2024-04-03 15:19:03 -0700
committerGitHub <noreply@github.com>2024-04-03 15:19:03 -0700
commit029e1d751503268e3d8b01db769e710835c3010d (patch)
tree4e8ecaf2da18b33165c7569114a96164f40ab7d1 /clang/lib/CodeGen/CGExpr.cpp
parent4078763e2e73b4ef3f9e728f66cdf9e429d3f7a4 (diff)
downloadllvm-029e1d751503268e3d8b01db769e710835c3010d.zip
llvm-029e1d751503268e3d8b01db769e710835c3010d.tar.gz
llvm-029e1d751503268e3d8b01db769e710835c3010d.tar.bz2
Revert "Revert "Revert "[clang][UBSan] Add implicit conversion check for bitfields""" (#87562)
Reverts llvm/llvm-project#87529 Reverts #87518 https://lab.llvm.org/buildbot/#/builders/37/builds/33262 is still broken
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 0c7f48f..5443235 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());