diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index e4ca425f8a1f88..e682f79907f9aa 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -3980,9 +3980,13 @@ AST_POLYMORPHIC_MATCHER(isMissingDllImportOrExport, PermittedToExport = VD->hasGlobalStorage() && VD->getStorageClass() != SC_Static; } - bool HasImportOrExportAttr = - Node.hasAttr() || Node.hasAttr(); - return PermittedToExport && !HasImportOrExportAttr; + if (const Decl *D = dyn_cast(&Node)) { + bool HasImportOrExportAttr = + D->hasAttr() || D->hasAttr(); + return PermittedToExport && !HasImportOrExportAttr; + } else { + return false; + } } // @unreal: END