[clang] [Clang] Fix 'counted_by' for nested struct pointers (PR #110497)

Jan Hendrik Farr via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 2 18:16:30 PDT 2024


================
@@ -1164,15 +1163,15 @@ llvm::Value *CodeGenFunction::EmitLoadOfCountedByField(
     return nullptr;
 
   llvm::Value *Res = nullptr;
-  if (StructBase->isLValue()) {
-    LValue LV = EmitLValue(StructBase);
-    Address Addr = LV.getAddress();
-    Res = Addr.emitRawPointer(*this);
-  } else {
+  if (StructBase->getType()->isPointerType()) {
     LValueBaseInfo BaseInfo;
     TBAAAccessInfo TBAAInfo;
     Address Addr = EmitPointerWithAlignment(StructBase, &BaseInfo, &TBAAInfo);
     Res = Addr.emitRawPointer(*this);
+  } else {
----------------
Cydox wrote:

should I add a check for `StructBase->isLValue()` and add an `else` statement that returns `nullptr`?

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


More information about the cfe-commits mailing list