[NFC][CLANG] Fix Static Code Analyzer Concerns with dereference null return value...
authorManna, Soumi <soumi.manna@intel.com>
Fri, 2 Jun 2023 20:34:32 +0000 (13:34 -0700)
committerManna, Soumi <soumi.manna@intel.com>
Fri, 2 Jun 2023 20:40:45 +0000 (13:40 -0700)
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

clang/lib/Sema/SemaType.cpp

index 1e4eece..f844048 100644 (file)
@@ -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()) {