forked from OSchip/llvm-project
Fix member function call on null pointer in Sema::FindInstantiatedDecl.
This bug was reported by UBSan. llvm-svn: 217059
This commit is contained in:
parent
029634e99e
commit
2c0aac2591
|
@ -4400,17 +4400,17 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
|
|||
(isa<CXXRecordDecl>(D) && cast<CXXRecordDecl>(D)->isLambda())) {
|
||||
// D is a local of some kind. Look into the map of local
|
||||
// declarations to their instantiations.
|
||||
typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
|
||||
llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found
|
||||
= CurrentInstantiationScope->findInstantiationOf(D);
|
||||
if (CurrentInstantiationScope) {
|
||||
if (auto Found = CurrentInstantiationScope->findInstantiationOf(D)) {
|
||||
if (Decl *FD = Found->dyn_cast<Decl *>())
|
||||
return cast<NamedDecl>(FD);
|
||||
|
||||
if (Found) {
|
||||
if (Decl *FD = Found->dyn_cast<Decl *>())
|
||||
return cast<NamedDecl>(FD);
|
||||
|
||||
int PackIdx = ArgumentPackSubstitutionIndex;
|
||||
assert(PackIdx != -1 && "found declaration pack but not pack expanding");
|
||||
return cast<NamedDecl>((*Found->get<DeclArgumentPack *>())[PackIdx]);
|
||||
int PackIdx = ArgumentPackSubstitutionIndex;
|
||||
assert(PackIdx != -1 &&
|
||||
"found declaration pack but not pack expanding");
|
||||
typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
|
||||
return cast<NamedDecl>((*Found->get<DeclArgumentPack *>())[PackIdx]);
|
||||
}
|
||||
}
|
||||
|
||||
// If we're performing a partial substitution during template argument
|
||||
|
|
Loading…
Reference in New Issue