Skip to content

Commit

Permalink
[clang] Sema::CheckEquivalentExceptionSpec - remove useless nullptr test
Browse files Browse the repository at this point in the history
We use castAs<> for NewProto/OldProto, which would assert if the cast failed.
  • Loading branch information
RKSimon committed Feb 17, 2022
1 parent 32b73bc commit 5fe64d2
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions clang/lib/Sema/SemaExceptionSpec.cpp
Expand Up @@ -342,8 +342,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
if (!MissingExceptionSpecification)
return ReturnValueOnError;

const FunctionProtoType *NewProto =
New->getType()->castAs<FunctionProtoType>();
const auto *NewProto = New->getType()->castAs<FunctionProtoType>();

// The new function declaration is only missing an empty exception
// specification "throw()". If the throw() specification came from a
Expand All @@ -353,7 +352,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
// specifications.
//
// Likewise if the old function is a builtin.
if (MissingEmptyExceptionSpecification && NewProto &&
if (MissingEmptyExceptionSpecification &&
(Old->getLocation().isInvalid() ||
Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
Old->getBuiltinID()) &&
Expand All @@ -364,8 +363,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
return false;
}

const FunctionProtoType *OldProto =
Old->getType()->castAs<FunctionProtoType>();
const auto *OldProto = Old->getType()->castAs<FunctionProtoType>();

FunctionProtoType::ExceptionSpecInfo ESI = OldProto->getExceptionSpecType();
if (ESI.Type == EST_Dynamic) {
Expand Down

0 comments on commit 5fe64d2

Please sign in to comment.