Skip to content

Commit afb163f

Browse files
committed
SemaExceptionSpec - 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. llvm-svn: 375440
1 parent 0cfd9e5 commit afb163f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

clang/lib/Sema/SemaExceptionSpec.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,7 @@ static bool hasImplicitExceptionSpec(FunctionDecl *Decl) {
263263
if (!Decl->getTypeSourceInfo())
264264
return isa<CXXDestructorDecl>(Decl);
265265

266-
const FunctionProtoType *Ty =
267-
Decl->getTypeSourceInfo()->getType()->getAs<FunctionProtoType>();
266+
auto *Ty = Decl->getTypeSourceInfo()->getType()->castAs<FunctionProtoType>();
268267
return !Ty->hasExceptionSpec();
269268
}
270269

@@ -965,9 +964,9 @@ bool Sema::CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
965964
PDiag(diag::err_deep_exception_specs_differ),
966965
PDiag(diag::note_overridden_virtual_function),
967966
PDiag(diag::ext_override_exception_spec),
968-
Old->getType()->getAs<FunctionProtoType>(),
967+
Old->getType()->castAs<FunctionProtoType>(),
969968
Old->getLocation(),
970-
New->getType()->getAs<FunctionProtoType>(),
969+
New->getType()->castAs<FunctionProtoType>(),
971970
New->getLocation());
972971
}
973972

0 commit comments

Comments
 (0)