forked from OSchip/llvm-project
Switch Decl instantiation to DeclNodes.inc.
This replaces a long list of declarations for visitor functions with a list generated from DeclNodes.inc. Nothing really interesting came out of it; we had comprehensive coverage anyway (excluding FriendTemplateDecls). llvm-svn: 185118
This commit is contained in:
parent
8d7f11da50
commit
cb9cd6c714
|
@ -386,62 +386,38 @@ namespace clang {
|
|||
Owner(Owner), TemplateArgs(TemplateArgs), LateAttrs(0), StartingScope(0)
|
||||
{ }
|
||||
|
||||
// FIXME: Once we get closer to completion, replace these manually-written
|
||||
// declarations with automatically-generated ones from
|
||||
// clang/AST/DeclNodes.inc.
|
||||
Decl *VisitTranslationUnitDecl(TranslationUnitDecl *D);
|
||||
Decl *VisitLabelDecl(LabelDecl *D);
|
||||
Decl *VisitNamespaceDecl(NamespaceDecl *D);
|
||||
Decl *VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
|
||||
Decl *VisitTypedefDecl(TypedefDecl *D);
|
||||
Decl *VisitTypeAliasDecl(TypeAliasDecl *D);
|
||||
Decl *VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D);
|
||||
Decl *VisitVarDecl(VarDecl *D);
|
||||
Decl *VisitAccessSpecDecl(AccessSpecDecl *D);
|
||||
Decl *VisitFieldDecl(FieldDecl *D);
|
||||
Decl *VisitMSPropertyDecl(MSPropertyDecl *D);
|
||||
Decl *VisitIndirectFieldDecl(IndirectFieldDecl *D);
|
||||
Decl *VisitStaticAssertDecl(StaticAssertDecl *D);
|
||||
Decl *VisitEnumDecl(EnumDecl *D);
|
||||
Decl *VisitEnumConstantDecl(EnumConstantDecl *D);
|
||||
Decl *VisitFriendDecl(FriendDecl *D);
|
||||
Decl *VisitFunctionDecl(FunctionDecl *D,
|
||||
TemplateParameterList *TemplateParams = 0);
|
||||
Decl *VisitCXXRecordDecl(CXXRecordDecl *D);
|
||||
Decl *VisitCXXMethodDecl(CXXMethodDecl *D,
|
||||
TemplateParameterList *TemplateParams = 0,
|
||||
bool IsClassScopeSpecialization = false);
|
||||
Decl *VisitCXXConstructorDecl(CXXConstructorDecl *D);
|
||||
Decl *VisitCXXDestructorDecl(CXXDestructorDecl *D);
|
||||
Decl *VisitCXXConversionDecl(CXXConversionDecl *D);
|
||||
ParmVarDecl *VisitParmVarDecl(ParmVarDecl *D);
|
||||
Decl *VisitClassTemplateDecl(ClassTemplateDecl *D);
|
||||
Decl *VisitClassTemplatePartialSpecializationDecl(
|
||||
ClassTemplatePartialSpecializationDecl *D);
|
||||
Decl *VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
|
||||
Decl *VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D);
|
||||
Decl *VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D);
|
||||
Decl *VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D);
|
||||
Decl *VisitUsingDirectiveDecl(UsingDirectiveDecl *D);
|
||||
Decl *VisitUsingDecl(UsingDecl *D);
|
||||
Decl *VisitUsingShadowDecl(UsingShadowDecl *D);
|
||||
Decl *VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
|
||||
Decl *VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
|
||||
Decl *VisitClassScopeFunctionSpecializationDecl(
|
||||
ClassScopeFunctionSpecializationDecl *D);
|
||||
Decl *VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D);
|
||||
// Define all the decl visitors using DeclNodes.inc
|
||||
#define DECL(DERIVED, BASE) \
|
||||
Decl *Visit ## DERIVED ## Decl(DERIVED ## Decl *D);
|
||||
#define ABSTRACT_DECL(DECL)
|
||||
|
||||
// Decls which never appear inside a class or function.
|
||||
#define OBJCCONTAINER(DERIVED, BASE)
|
||||
#define FILESCOPEASM(DERIVED, BASE)
|
||||
#define IMPORT(DERIVED, BASE)
|
||||
#define LINKAGESPEC(DERIVED, BASE)
|
||||
#define OBJCCOMPATIBLEALIAS(DERIVED, BASE)
|
||||
#define OBJCMETHOD(DERIVED, BASE)
|
||||
#define OBJCIVAR(DERIVED, BASE)
|
||||
#define OBJCPROPERTY(DERIVED, BASE)
|
||||
#define OBJCPROPERTYIMPL(DERIVED, BASE)
|
||||
#define EMPTY(DERIVED, BASE)
|
||||
|
||||
// Decls which use special-case instantiation code.
|
||||
#define BLOCK(DERIVED, BASE)
|
||||
#define CAPTURED(DERIVED, BASE)
|
||||
#define IMPLICITPARAM(DERIVED, BASE)
|
||||
|
||||
#include "clang/AST/DeclNodes.inc"
|
||||
|
||||
// A few supplemental visitor functions.
|
||||
Decl *VisitCXXMethodDecl(CXXMethodDecl *D,
|
||||
TemplateParameterList *TemplateParams,
|
||||
bool IsClassScopeSpecialization = false);
|
||||
Decl *VisitFunctionDecl(FunctionDecl *D,
|
||||
TemplateParameterList *TemplateParams);
|
||||
Decl *VisitDecl(Decl *D);
|
||||
|
||||
// Base case. FIXME: Remove once we can instantiate everything.
|
||||
Decl *VisitDecl(Decl *D) {
|
||||
unsigned DiagID = SemaRef.getDiagnostics().getCustomDiagID(
|
||||
DiagnosticsEngine::Error,
|
||||
"cannot instantiate %0 yet");
|
||||
SemaRef.Diag(D->getLocation(), DiagID)
|
||||
<< D->getDeclKindName();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Enable late instantiation of attributes. Late instantiated attributes
|
||||
// will be stored in LA.
|
||||
void enableLateAttributeInstantiation(Sema::LateInstantiatedAttrVec *LA) {
|
||||
|
|
|
@ -1755,7 +1755,7 @@ Decl *TemplateDeclInstantiator::VisitCXXConversionDecl(CXXConversionDecl *D) {
|
|||
return VisitCXXMethodDecl(D);
|
||||
}
|
||||
|
||||
ParmVarDecl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
|
||||
Decl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
|
||||
return SemaRef.SubstParmVarDecl(D, TemplateArgs, /*indexAdjustment*/ 0, None,
|
||||
/*ExpectParameterPack=*/ false);
|
||||
}
|
||||
|
@ -2277,6 +2277,44 @@ Decl *TemplateDeclInstantiator::VisitOMPThreadPrivateDecl(
|
|||
return TD;
|
||||
}
|
||||
|
||||
Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D) {
|
||||
return VisitFunctionDecl(D, 0);
|
||||
}
|
||||
|
||||
Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D) {
|
||||
return VisitCXXMethodDecl(D, 0);
|
||||
}
|
||||
|
||||
Decl *TemplateDeclInstantiator::VisitRecordDecl(RecordDecl *D) {
|
||||
llvm_unreachable("There are only CXXRecordDecls in C++");
|
||||
}
|
||||
|
||||
Decl *
|
||||
TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl(
|
||||
ClassTemplateSpecializationDecl *D) {
|
||||
llvm_unreachable("Only ClassTemplatePartialSpecializationDecls occur"
|
||||
"inside templates");
|
||||
}
|
||||
|
||||
Decl *TemplateDeclInstantiator::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D) {
|
||||
llvm_unreachable("@defs is not supported in Objective-C++");
|
||||
}
|
||||
|
||||
Decl *TemplateDeclInstantiator::VisitFriendTemplateDecl(FriendTemplateDecl *D) {
|
||||
// FIXME: We need to be able to instantiate FriendTemplateDecls.
|
||||
unsigned DiagID = SemaRef.getDiagnostics().getCustomDiagID(
|
||||
DiagnosticsEngine::Error,
|
||||
"cannot instantiate %0 yet");
|
||||
SemaRef.Diag(D->getLocation(), DiagID)
|
||||
<< D->getDeclKindName();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Decl *TemplateDeclInstantiator::VisitDecl(Decl *D) {
|
||||
llvm_unreachable("Unexpected decl");
|
||||
}
|
||||
|
||||
Decl *Sema::SubstDecl(Decl *D, DeclContext *Owner,
|
||||
const MultiLevelTemplateArgumentList &TemplateArgs) {
|
||||
TemplateDeclInstantiator Instantiator(*this, Owner, TemplateArgs);
|
||||
|
@ -2509,7 +2547,8 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D,
|
|||
if (FunctionProtoTypeLoc OldProtoLoc =
|
||||
OldTL.getAs<FunctionProtoTypeLoc>()) {
|
||||
for (unsigned i = 0, i_end = OldProtoLoc.getNumArgs(); i != i_end; ++i) {
|
||||
ParmVarDecl *Parm = VisitParmVarDecl(OldProtoLoc.getArg(i));
|
||||
ParmVarDecl *Parm =
|
||||
cast_or_null<ParmVarDecl>(VisitParmVarDecl(OldProtoLoc.getArg(i)));
|
||||
if (!Parm)
|
||||
return 0;
|
||||
Params.push_back(Parm);
|
||||
|
|
Loading…
Reference in New Issue