r375097 - SemaDeclObjC - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 17 03:35:29 PDT 2019
Author: rksimon
Date: Thu Oct 17 03:35:29 2019
New Revision: 375097
URL: http://llvm.org/viewvc/llvm-project?rev=375097&view=rev
Log:
SemaDeclObjC - silence static analyzer getAs<> null dereference warnings. NFCI.
The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=375097&r1=375096&r2=375097&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Oct 17 03:35:29 2019
@@ -586,7 +586,7 @@ ActOnSuperClassOfClassInterface(Scope *S
dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
QualType T = TDecl->getUnderlyingType();
if (T->isObjCObjectType()) {
- if (NamedDecl *IDecl = T->getAs<ObjCObjectType>()->getInterface()) {
+ if (NamedDecl *IDecl = T->castAs<ObjCObjectType>()->getInterface()) {
SuperClassDecl = dyn_cast<ObjCInterfaceDecl>(IDecl);
SuperClassType = Context.getTypeDeclType(TDecl);
@@ -1151,7 +1151,7 @@ Decl *Sema::ActOnCompatibilityAlias(Sour
dyn_cast_or_null<TypedefNameDecl>(CDeclU)) {
QualType T = TDecl->getUnderlyingType();
if (T->isObjCObjectType()) {
- if (NamedDecl *IDecl = T->getAs<ObjCObjectType>()->getInterface()) {
+ if (NamedDecl *IDecl = T->castAs<ObjCObjectType>()->getInterface()) {
ClassName = IDecl->getIdentifier();
CDeclU = LookupSingleName(TUScope, ClassName, ClassLocation,
LookupOrdinaryName,
@@ -4876,7 +4876,7 @@ VarDecl *Sema::BuildObjCExceptionDecl(Ty
} else if (!T->isObjCObjectPointerType()) {
Invalid = true;
Diag(IdLoc, diag::err_catch_param_not_objc_type);
- } else if (!T->getAs<ObjCObjectPointerType>()->getInterfaceType()) {
+ } else if (!T->castAs<ObjCObjectPointerType>()->getInterfaceType()) {
Invalid = true;
Diag(IdLoc, diag::err_catch_param_not_objc_type);
}
More information about the cfe-commits
mailing list