[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
This commit is contained in:
Simon Pilgrim 2022-01-31 17:23:03 +00:00
parent c965d5448e
commit 1307f66d17
1 changed files with 3 additions and 4 deletions

View File

@ -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);