summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2022-02-12 11:28:50 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2022-02-12 11:28:50 +0000
commit2188e61691ad89e27583fd3a4197322be830df59 (patch)
tree885c3963cb1fb06e374a0e90841449d33546d547
parentfbe0ca576d2b96c523182200529b5afbf709506f (diff)
[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
-rw-r--r--clang-tools-extra/clang-doc/Serialize.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp
index 29762b6b54b1..c567cda9b6e2 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -357,7 +357,7 @@ template <typename T>
static void
populateParentNamespaces(llvm::SmallVector<Reference, 4> &Namespaces,
const T *D, bool &IsInAnonymousNamespace) {
- const auto *DC = dyn_cast<DeclContext>(D);
+ const auto *DC = cast<DeclContext>(D);
while ((DC = DC->getParent())) {
if (const auto *N = dyn_cast<NamespaceDecl>(DC)) {
std::string Namespace;