[clang] 1aeb4c6 - [ItaniumCXXABI] Avoid pointer element type accesses

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 14 06:17:24 PST 2022


Author: Nikita Popov
Date: 2022-02-14T15:17:14+01:00
New Revision: 1aeb4c6b5081944fd1e53a8f6ee0488ca33644c1

URL: https://github.com/llvm/llvm-project/commit/1aeb4c6b5081944fd1e53a8f6ee0488ca33644c1
DIFF: https://github.com/llvm/llvm-project/commit/1aeb4c6b5081944fd1e53a8f6ee0488ca33644c1.diff

LOG: [ItaniumCXXABI] Avoid pointer element type accesses

Added: 
    

Modified: 
    clang/lib/CodeGen/ItaniumCXXABI.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 2979d92c8417..5ec9d3289ee8 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -4472,7 +4472,7 @@ static void InitCatchParam(CodeGenFunction &CGF,
       // pad.  The best solution is to fix the personality function.
       } else {
         // Pull the pointer for the reference type off.
-        llvm::Type *PtrTy = LLVMCatchTy->getPointerElementType();
+        llvm::Type *PtrTy = CGF.ConvertTypeForMem(CaughtType);
 
         // Create the temporary and write the adjusted pointer into it.
         Address ExnPtrTmp =
@@ -4555,7 +4555,7 @@ static void InitCatchParam(CodeGenFunction &CGF,
   if (!copyExpr) {
     llvm::Value *rawAdjustedExn = CallBeginCatch(CGF, Exn, true);
     Address adjustedExn(CGF.Builder.CreateBitCast(rawAdjustedExn, PtrTy),
-                        caughtExnAlignment);
+                        LLVMCatchTy, caughtExnAlignment);
     LValue Dest = CGF.MakeAddrLValue(ParamAddr, CatchType);
     LValue Src = CGF.MakeAddrLValue(adjustedExn, CatchType);
     CGF.EmitAggregateCopy(Dest, Src, CatchType, AggValueSlot::DoesNotOverlap);
@@ -4569,7 +4569,7 @@ static void InitCatchParam(CodeGenFunction &CGF,
 
   // Cast that to the appropriate type.
   Address adjustedExn(CGF.Builder.CreateBitCast(rawAdjustedExn, PtrTy),
-                      caughtExnAlignment);
+                      LLVMCatchTy, caughtExnAlignment);
 
   // The copy expression is defined in terms of an OpaqueValueExpr.
   // Find it and map it to the adjusted expression.


        


More information about the cfe-commits mailing list