[clang] 54b2914 - Fix "pointer is null" static analyzer warnings. NFCI.

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 12 14:09:19 PST 2020


Author: Simon Pilgrim
Date: 2020-01-12T22:08:56Z
New Revision: 54b2914accb4f5c9b58305fd6da405d20a47c452

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

LOG: Fix "pointer is null" static analyzer warnings. NFCI.

Use castAs<> instead of getAs<> since the pointers are dereferenced immediately and castAs will perform the null assertion for us.

Added: 
    

Modified: 
    clang/lib/AST/VTableBuilder.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index 5688042dadd9..2b5b74be5961 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -270,8 +270,8 @@ static BaseOffset
 ComputeReturnAdjustmentBaseOffset(ASTContext &Context,
                                   const CXXMethodDecl *DerivedMD,
                                   const CXXMethodDecl *BaseMD) {
-  const FunctionType *BaseFT = BaseMD->getType()->getAs<FunctionType>();
-  const FunctionType *DerivedFT = DerivedMD->getType()->getAs<FunctionType>();
+  const auto *BaseFT = BaseMD->getType()->castAs<FunctionType>();
+  const auto *DerivedFT = DerivedMD->getType()->castAs<FunctionType>();
 
   // Canonicalize the return types.
   CanQualType CanDerivedReturnType =


        


More information about the cfe-commits mailing list