[llvm-branch-commits] [clang] eb7ea5a - CGCall.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly. NFCI.

Simon Pilgrim via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Nov 25 03:43:25 PST 2020


Author: Simon Pilgrim
Date: 2020-11-25T11:38:29Z
New Revision: eb7ea5aa1ac6030b7bc94c5f2fb42de675cd392f

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

LOG: CGCall.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly. NFCI.

castAs<> will assert the correct cast type instead of just returning null, which we then try to dereference immediately in the setUsedBits call.

Added: 
    

Modified: 
    clang/lib/CodeGen/CGCall.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 2558dd42fac1..78740018d416 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3153,7 +3153,7 @@ llvm::Value *CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src,
   const llvm::DataLayout &DataLayout = CGM.getDataLayout();
   int Size = DataLayout.getTypeStoreSize(ITy);
   SmallVector<uint64_t, 4> Bits(Size);
-  setUsedBits(CGM, QTy->getAs<RecordType>(), 0, Bits);
+  setUsedBits(CGM, QTy->castAs<RecordType>(), 0, Bits);
 
   int CharWidth = CGM.getContext().getCharWidth();
   uint64_t Mask =
@@ -3170,7 +3170,7 @@ llvm::Value *CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src,
   const llvm::DataLayout &DataLayout = CGM.getDataLayout();
   int Size = DataLayout.getTypeStoreSize(ATy);
   SmallVector<uint64_t, 16> Bits(Size);
-  setUsedBits(CGM, QTy->getAs<RecordType>(), 0, Bits);
+  setUsedBits(CGM, QTy->castAs<RecordType>(), 0, Bits);
 
   // Clear each element of the LLVM array.
   int CharWidth = CGM.getContext().getCharWidth();


        


More information about the llvm-branch-commits mailing list