[clang] 27b297b - [clang] Fix -Wunused-variable in CGCall.cpp (NFC)

Jie Fu via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 28 04:59:04 PST 2024


Author: Jie Fu
Date: 2024-02-28T20:58:20+08:00
New Revision: 27b297bf21b6637047c1ac403f983351b9a3fc64

URL: https://github.com/llvm/llvm-project/commit/27b297bf21b6637047c1ac403f983351b9a3fc64
DIFF: https://github.com/llvm/llvm-project/commit/27b297bf21b6637047c1ac403f983351b9a3fc64.diff

LOG: [clang] Fix -Wunused-variable in CGCall.cpp (NFC)

llvm-project/clang/lib/CodeGen/CGCall.cpp:3226:24:
error: unused variable 'StructSize' [-Werror,-Wunused-variable]
        llvm::TypeSize StructSize = CGM.getDataLayout().getTypeAllocSize(STy);
                       ^
llvm-project/clang/lib/CodeGen/CGCall.cpp:3227:24:
error: unused variable 'PtrElementSize' [-Werror,-Wunused-variable]
        llvm::TypeSize PtrElementSize =
                       ^
llvm-project/clang/lib/CodeGen/CGCall.cpp:5313:24:
error: unused variable 'SrcTypeSize' [-Werror,-Wunused-variable]
        llvm::TypeSize SrcTypeSize =
                       ^
llvm-project/clang/lib/CodeGen/CGCall.cpp:5315:24:
error: unused variable 'DstTypeSize' [-Werror,-Wunused-variable]
        llvm::TypeSize DstTypeSize = CGM.getDataLayout().getTypeAllocSize(STy);
                       ^
4 errors generated.

Added: 
    

Modified: 
    clang/lib/CodeGen/CGCall.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 0d86fcf544d0fd..13f68237b464d6 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3223,8 +3223,9 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
           dyn_cast<llvm::StructType>(ArgI.getCoerceToType());
       if (ArgI.isDirect() && !ArgI.getCanBeFlattened() && STy &&
           STy->getNumElements() > 1) {
-        llvm::TypeSize StructSize = CGM.getDataLayout().getTypeAllocSize(STy);
-        llvm::TypeSize PtrElementSize =
+        [[maybe_unused]] llvm::TypeSize StructSize =
+            CGM.getDataLayout().getTypeAllocSize(STy);
+        [[maybe_unused]] llvm::TypeSize PtrElementSize =
             CGM.getDataLayout().getTypeAllocSize(ConvertTypeForMem(Ty));
         if (STy->containsHomogeneousScalableVectorTypes()) {
           assert(StructSize == PtrElementSize &&
@@ -5310,9 +5311,10 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
           dyn_cast<llvm::StructType>(ArgInfo.getCoerceToType());
       if (STy && ArgInfo.isDirect() && !ArgInfo.getCanBeFlattened()) {
         llvm::Type *SrcTy = ConvertTypeForMem(I->Ty);
-        llvm::TypeSize SrcTypeSize =
+        [[maybe_unused]] llvm::TypeSize SrcTypeSize =
             CGM.getDataLayout().getTypeAllocSize(SrcTy);
-        llvm::TypeSize DstTypeSize = CGM.getDataLayout().getTypeAllocSize(STy);
+        [[maybe_unused]] llvm::TypeSize DstTypeSize =
+            CGM.getDataLayout().getTypeAllocSize(STy);
         if (STy->containsHomogeneousScalableVectorTypes()) {
           assert(SrcTypeSize == DstTypeSize &&
                  "Only allow non-fractional movement of structure with "


        


More information about the cfe-commits mailing list