Author: Manna, Soumi
Date: 2023-06-02T13:40:45-07:00
New Revision: 82659941ccb88605ae4288f7506ef11e5fe3fc17

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

LOG: [NFC][CLANG] Fix Static Code Analyzer Concerns with dereference null 
return value in applyObjCTypeArgs()

This patch uses castAs instead of getAs to resolve dereference issue with 
nullptr boundObjC when calling
canAssignObjCInterfaces() or isObjCIdType() in applyObjCTypeArgs() since getAs 
returns nullptr.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D151964

Added: 
    

Modified: 
    clang/lib/Sema/SemaType.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 1e4eecee21e5..f844048889b5 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -950,7 +950,7 @@ static QualType applyObjCTypeArgs(Sema &S, SourceLocation 
loc, QualType type,
 
       // Retrieve the bound.
       QualType bound = typeParam->getUnderlyingType();
-      const auto *boundObjC = bound->getAs<ObjCObjectPointerType>();
+      const auto *boundObjC = bound->castAs<ObjCObjectPointerType>();
 
       // Determine whether the type argument is substitutable for the bound.
       if (typeArgObjC->isObjCIdType()) {


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

Reply via email to