From eb86173f7bfe9f794c59c8a996f41f19a839963a Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 19 Apr 2017 02:19:21 +0000 Subject: Fix member function call with null 'this' pointer. llvm-svn: 300653 --- clang/lib/AST/Decl.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'clang/lib/AST/Decl.cpp') diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 9b5ba813dbd..5fe07065212 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2253,6 +2253,7 @@ bool VarDecl::checkInitIsICE() const { template static DeclT *getDefinitionOrSelf(DeclT *D) { + assert(D); if (auto *Def = D->getDefinition()) return Def; return D; @@ -3202,9 +3203,12 @@ bool FunctionDecl::isTemplateInstantiation() const { FunctionDecl *FunctionDecl::getTemplateInstantiationPattern() const { // Handle class scope explicit specialization special case. - if (getTemplateSpecializationKind() == TSK_ExplicitSpecialization) - return getDefinitionOrSelf(getClassScopeSpecializationPattern()); - + if (getTemplateSpecializationKind() == TSK_ExplicitSpecialization) { + if (auto *Spec = getClassScopeSpecializationPattern()) + return getDefinitionOrSelf(Spec); + return nullptr; + } + // If this is a generic lambda call operator specialization, its // instantiation pattern is always its primary template's pattern // even if its primary template was instantiated from another -- cgit v1.2.3