[clang] 5fe64d2 - [clang] Sema::CheckEquivalentExceptionSpec - remove useless nullptr test

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 17 08:59:57 PST 2022


Author: Simon Pilgrim
Date: 2022-02-17T16:59:50Z
New Revision: 5fe64d238b8b5ed1861de63a2072ddf3e81af806

URL: https://github.com/llvm/llvm-project/commit/5fe64d238b8b5ed1861de63a2072ddf3e81af806
DIFF: https://github.com/llvm/llvm-project/commit/5fe64d238b8b5ed1861de63a2072ddf3e81af806.diff

LOG: [clang] Sema::CheckEquivalentExceptionSpec - remove useless nullptr test

We use castAs<> for NewProto/OldProto, which would assert if the cast failed.

Added: 
    

Modified: 
    clang/lib/Sema/SemaExceptionSpec.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp
index 29cb4be7b1ba..151fbb48651d 100644
--- a/clang/lib/Sema/SemaExceptionSpec.cpp
+++ b/clang/lib/Sema/SemaExceptionSpec.cpp
@@ -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
@@ -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()) &&
@@ -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) {


        


More information about the cfe-commits mailing list