From: Adam Czachorowski Date: Mon, 18 Jan 2021 22:16:05 +0000 (+0100) Subject: [clang] Check for nullptr when instantiating late attrs X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=a6f9077b16da90204b296acd4f840769e83460ac;p=android-x86%2Fexternal-llvm-project.git [clang] Check for nullptr when instantiating late attrs This was already done in SemaTemplateInstantiateDecl.cpp, but not in SemaTemplateInstantiate.cpp. Anecdotally I've seen some clangd crashes where coredumps point to this being a problem, but I cannot reproduce this so far. Differential Revision: https://reviews.llvm.org/D94933 --- diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index cb74f08830c..7679063ead7 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -2796,7 +2796,8 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation, Attr *NewAttr = instantiateTemplateAttribute(I->TmplAttr, Context, *this, TemplateArgs); - I->NewDecl->addAttr(NewAttr); + if (NewAttr) + I->NewDecl->addAttr(NewAttr); LocalInstantiationScope::deleteScopes(I->Scope, Instantiator.getStartingScope()); }