Fix potential nullptr dereference.
Bug: 21597073
We must use dyn_cast_or_null<> instead of dyn_cast<>, because we aren't
guaranteed to always be passed a NamedDecl.
Change-Id: I7b00eacc639a688f8e2fdbeea80b87a01372e232
diff --git a/slang_rs_export_type.cpp b/slang_rs_export_type.cpp
index d73f866..d0b6094 100644
--- a/slang_rs_export_type.cpp
+++ b/slang_rs_export_type.cpp
@@ -678,7 +678,7 @@
// If this is an externally visible variable declaration, we check if the
// type is able to be exported first.
- if (auto VD = llvm::dyn_cast<clang::VarDecl>(ND)) {
+ if (auto VD = llvm::dyn_cast_or_null<clang::VarDecl>(ND)) {
if (VD->getFormalLinkage() == clang::ExternalLinkage) {
if (!TypeExportable(T, Context, VD)) {
return false;