~LocalInstantiationScope() {
Exit();
}
+
+ const Sema &getSema() const { return SemaRef; }
/// \brief Exit this local instantiation scope early.
void Exit() {
Exited = true;
}
- Decl *getInstantiationOf(const Decl *D);
-
/// \brief Find the instantiation of the declaration D within the current
/// instantiation scope.
///
return Instantiator.TransformTemplateArguments(Args, NumArgs, Result);
}
-Decl *LocalInstantiationScope::getInstantiationOf(const Decl *D) {
- llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found= findInstantiationOf(D);
- assert(Found);
-
- if (Found->is<Decl *>())
- return Found->get<Decl *>();
-
- return (*Found->get<DeclArgumentPack *>())[
- SemaRef.ArgumentPackSubstitutionIndex];
-}
-
llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *> *
LocalInstantiationScope::findInstantiationOf(const Decl *D) {
for (LocalInstantiationScope *Current = this; Current;
(ParentDC->isFunctionOrMethod() && ParentDC->isDependentContext())) {
// D is a local of some kind. Look into the map of local
// declarations to their instantiations.
- return cast<NamedDecl>(CurrentInstantiationScope->getInstantiationOf(D));
+ typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
+ llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found
+ = CurrentInstantiationScope->findInstantiationOf(D);
+ assert(Found);
+
+ if (Decl *FD = Found->dyn_cast<Decl *>())
+ return cast<NamedDecl>(FD);
+
+ unsigned PackIdx = ArgumentPackSubstitutionIndex;
+ return cast<NamedDecl>((*Found->get<DeclArgumentPack *>())[PackIdx]);
}
if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(D)) {