Author: Simon Pilgrim
Date: 2020-01-09T12:05:47Z
New Revision: e3e72a2619ccec9654ef9ad45e1e926841fbaa58

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

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

Assert that the pointers are non-null before dereferencing them.

Added: 
    

Modified: 
    clang/lib/CodeGen/CGObjCGNU.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 479cd8ec77ce..a27b6d4ed637 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -1236,6 +1236,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
         // The first Interface we find may be a @class,
         // which should only be treated as the source of
         // truth in the absence of a true declaration.
+        assert(OID && "Failed to find ObjCInterfaceDecl");
         const ObjCInterfaceDecl *OIDDef = OID->getDefinition();
         if (OIDDef != nullptr)
           OID = OIDDef;
@@ -3036,6 +3037,7 @@ llvm::Value 
*CGObjCGNU::GenerateProtocolRef(CodeGenFunction &CGF,
   llvm::Constant *&protocol = ExistingProtocols[PD->getNameAsString()];
   if (!protocol)
     GenerateProtocol(PD);
+  assert(protocol && "Unknown protocol");
   llvm::Type *T =
     CGM.getTypes().ConvertType(CGM.getContext().getObjCProtoType());
   return CGF.Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T));


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to