From 2188e61691ad89e27583fd3a4197322be830df59 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sat, 12 Feb 2022 11:28:50 +0000 Subject: [PATCH] [clang-doc] populateParentNamespaces - 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 It's only later iterations of the loop where the getParent() call might return nullptr --- clang-tools-extra/clang-doc/Serialize.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp index 29762b6..c567cda 100644 --- a/clang-tools-extra/clang-doc/Serialize.cpp +++ b/clang-tools-extra/clang-doc/Serialize.cpp @@ -357,7 +357,7 @@ template static void populateParentNamespaces(llvm::SmallVector &Namespaces, const T *D, bool &IsInAnonymousNamespace) { - const auto *DC = dyn_cast(D); + const auto *DC = cast(D); while ((DC = DC->getParent())) { if (const auto *N = dyn_cast(DC)) { std::string Namespace; -- 2.7.4