Author: Simon Pilgrim Date: 2022-01-31T17:25:16Z New Revision: 1307f66d17e3b63edc27a03c3a64e46d3a7bfa61
URL: https://github.com/llvm/llvm-project/commit/1307f66d17e3b63edc27a03c3a64e46d3a7bfa61 DIFF: https://github.com/llvm/llvm-project/commit/1307f66d17e3b63edc27a03c3a64e46d3a7bfa61.diff LOG: [clang-tidy] getLambdaProperties - use cast<> instead of dyn_cast<> to avoid dereference of nullptr The pointers are dereferenced immediately, so assert the cast is correct instead of returning nullptr Added: Modified: clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp index 960eb7b3d6707..8b7373b3d932a 100644 --- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp @@ -548,11 +548,10 @@ getLambdaProperties(const MatchFinder::MatchResult &Result) { LambdaProperties LP; const auto *Bind = Result.Nodes.getNodeAs<CallExpr>("bind"); - const auto *Decl = dyn_cast<FunctionDecl>(Bind->getCalleeDecl()); - const auto *NS = - dyn_cast<NamespaceDecl>(Decl->getEnclosingNamespaceContext()); + const auto *Decl = cast<FunctionDecl>(Bind->getCalleeDecl()); + const auto *NS = cast<NamespaceDecl>(Decl->getEnclosingNamespaceContext()); while (NS->isInlineNamespace()) - NS = dyn_cast<NamespaceDecl>(NS->getDeclContext()); + NS = cast<NamespaceDecl>(NS->getDeclContext()); LP.BindNamespace = NS->getName(); LP.Callable.Type = getCallableType(Result); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits