Author: Simon Pilgrim
Date: 2022-02-12T10:51:48Z
New Revision: 99acc0dc6434373dc391ac4c89f6ae6b72ec7208

URL: 
https://github.com/llvm/llvm-project/commit/99acc0dc6434373dc391ac4c89f6ae6b72ec7208
DIFF: 
https://github.com/llvm/llvm-project/commit/99acc0dc6434373dc391ac4c89f6ae6b72ec7208.diff

LOG: [clang-tidy] UseNoexceptCheck::check - use cast<> instead of dyn_cast<> to 
avoid dereference of nullptr

The pointer is referenced immediately, so assert the cast is correct instead of 
returning nullptr

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
index c4e7f12e74acb..0043eb0dab9a4 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
@@ -65,7 +65,7 @@ void UseNoexceptCheck::check(const MatchFinder::MatchResult 
&Result) {
   } else if (const auto *ParmDecl =
                  Result.Nodes.getNodeAs<ParmVarDecl>("parmVarDecl")) {
     FnTy = ParmDecl->getType()
-               ->getAs<Type>()
+               ->castAs<Type>()
                ->getPointeeType()
                ->getAs<FunctionProtoType>();
 


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to