[clang] 5f9fcfb - Replace getAs with castAs to fix null dereference static analyzer warnings.

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 12 07:59:38 PDT 2020


Author: Simon Pilgrim
Date: 2020-03-12T14:56:50Z
New Revision: 5f9fcfb29e4e30932909ce648ad556a3890e6dce

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

LOG: Replace getAs with castAs to fix null dereference static analyzer warnings.

Use castAs as we know the cast should succeed (and castAs will assert if it doesn't) and we're dereferencing it directly in the canAssignObjCInterfaces call.

Added: 
    

Modified: 
    clang/lib/AST/ASTContext.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index e50d1d608397..436880968b1f 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -8698,8 +8698,8 @@ bool ASTContext::areComparableObjCPointerTypes(QualType LHS, QualType RHS) {
 
 bool ASTContext::canBindObjCObjectType(QualType To, QualType From) {
   return canAssignObjCInterfaces(
-                getObjCObjectPointerType(To)->getAs<ObjCObjectPointerType>(),
-                getObjCObjectPointerType(From)->getAs<ObjCObjectPointerType>());
+      getObjCObjectPointerType(To)->castAs<ObjCObjectPointerType>(),
+      getObjCObjectPointerType(From)->castAs<ObjCObjectPointerType>());
 }
 
 /// typesAreCompatible - C99 6.7.3p9: For two qualified types to be compatible,


        


More information about the cfe-commits mailing list