[clang] [Clang][UBSan] Use EmitCheckedLValue for C++ trivial operator= operands (PR #203737)

Hubert Tong via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 18 08:39:27 PDT 2026


================
@@ -307,17 +312,22 @@ RValue CodeGenFunction::EmitCXXMemberOrOperatorMemberCallExpr(
   }
 
   if (TrivialForCodegen) {
-    if (isa<CXXDestructorDecl>(MD))
+    if (isa<CXXDestructorDecl>(MD)) {
+      (void)getLValueForThis(); // Emit LHS for side effects.
----------------
hubert-reinterpretcast wrote:

> I agree. Wouldn’t this leave us with IR that evaluates the LHS but doesn’t emit any UBSan checks?

Sure, but the value isn't actually being used by this operation in the user program, so it is questionable whether a UBSan check is appropriate. Further, if it is indeed an issue that UBSan checks are omitted here, it is a separate issue (not within the scope of addressing UBSan checks for assignment operands).

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


More information about the cfe-commits mailing list