forked from OSchip/llvm-project
Move FunctionDecl::TemplateSpecializationInfo out into its own class,
FunctionTemplateSpecializationInfo, in DeclTemplate.h. No functionality change. llvm-svn: 74431
This commit is contained in:
parent
1257581438
commit
70d83e27a4
|
@ -26,6 +26,7 @@ class Stmt;
|
||||||
class CompoundStmt;
|
class CompoundStmt;
|
||||||
class StringLiteral;
|
class StringLiteral;
|
||||||
class TemplateArgumentList;
|
class TemplateArgumentList;
|
||||||
|
class FunctionTemplateSpecializationInfo;
|
||||||
|
|
||||||
/// TranslationUnitDecl - The top declaration context.
|
/// TranslationUnitDecl - The top declaration context.
|
||||||
class TranslationUnitDecl : public Decl, public DeclContext {
|
class TranslationUnitDecl : public Decl, public DeclContext {
|
||||||
|
@ -621,15 +622,8 @@ public:
|
||||||
enum StorageClass {
|
enum StorageClass {
|
||||||
None, Extern, Static, PrivateExtern
|
None, Extern, Static, PrivateExtern
|
||||||
};
|
};
|
||||||
private:
|
|
||||||
/// \brief Provides information about a function template specialization,
|
|
||||||
/// which is a FunctionDecl that has been explicitly specialization or
|
|
||||||
/// instantiated from a function template.
|
|
||||||
struct TemplateSpecializationInfo {
|
|
||||||
FunctionTemplateDecl *Template;
|
|
||||||
const TemplateArgumentList *TemplateArguments;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
private:
|
||||||
/// ParamInfo - new[]'d array of pointers to VarDecls for the formal
|
/// ParamInfo - new[]'d array of pointers to VarDecls for the formal
|
||||||
/// parameters of this function. This is null if a prototype or if there are
|
/// parameters of this function. This is null if a prototype or if there are
|
||||||
/// no formals.
|
/// no formals.
|
||||||
|
@ -684,7 +678,8 @@ private:
|
||||||
/// the template being specialized and the template arguments involved in
|
/// the template being specialized and the template arguments involved in
|
||||||
/// that specialization.
|
/// that specialization.
|
||||||
llvm::PointerUnion3<FunctionTemplateDecl*, FunctionDecl*,
|
llvm::PointerUnion3<FunctionTemplateDecl*, FunctionDecl*,
|
||||||
TemplateSpecializationInfo*> TemplateOrSpecialization;
|
FunctionTemplateSpecializationInfo*>
|
||||||
|
TemplateOrSpecialization;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FunctionDecl(Kind DK, DeclContext *DC, SourceLocation L,
|
FunctionDecl(Kind DK, DeclContext *DC, SourceLocation L,
|
||||||
|
@ -940,27 +935,14 @@ public:
|
||||||
///
|
///
|
||||||
/// If this function declaration is not a function template specialization,
|
/// If this function declaration is not a function template specialization,
|
||||||
/// returns NULL.
|
/// returns NULL.
|
||||||
FunctionTemplateDecl *getPrimaryTemplate() const {
|
FunctionTemplateDecl *getPrimaryTemplate() const;
|
||||||
if (TemplateSpecializationInfo *Info
|
|
||||||
= TemplateOrSpecialization.dyn_cast<TemplateSpecializationInfo*>()) {
|
|
||||||
return Info->Template;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \brief Retrieve the template arguments used to produce this function
|
/// \brief Retrieve the template arguments used to produce this function
|
||||||
/// template specialization from the primary template.
|
/// template specialization from the primary template.
|
||||||
///
|
///
|
||||||
/// If this function declaration is not a function template specialization,
|
/// If this function declaration is not a function template specialization,
|
||||||
/// returns NULL.
|
/// returns NULL.
|
||||||
const TemplateArgumentList *getTemplateSpecializationArgs() const {
|
const TemplateArgumentList *getTemplateSpecializationArgs() const;
|
||||||
if (TemplateSpecializationInfo *Info
|
|
||||||
= TemplateOrSpecialization.dyn_cast<TemplateSpecializationInfo*>()) {
|
|
||||||
return Info->TemplateArguments;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// \brief Specify that this function declaration is actually a function
|
/// \brief Specify that this function declaration is actually a function
|
||||||
/// template specialization.
|
/// template specialization.
|
||||||
|
|
|
@ -154,9 +154,34 @@ protected:
|
||||||
TemplateParameterList* TemplateParams;
|
TemplateParameterList* TemplateParams;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// \brief Provides information about a function template specialization,
|
||||||
|
/// which is a FunctionDecl that has been explicitly specialization or
|
||||||
|
/// instantiated from a function template.
|
||||||
|
class FunctionTemplateSpecializationInfo {
|
||||||
|
public:
|
||||||
|
FunctionTemplateDecl *Template;
|
||||||
|
const TemplateArgumentList *TemplateArguments;
|
||||||
|
};
|
||||||
|
|
||||||
/// Declaration of a template function.
|
/// Declaration of a template function.
|
||||||
class FunctionTemplateDecl : public TemplateDecl {
|
class FunctionTemplateDecl : public TemplateDecl {
|
||||||
protected:
|
protected:
|
||||||
|
/// \brief Data that is common to all of the declarations of a given
|
||||||
|
/// class template.
|
||||||
|
struct Common {
|
||||||
|
/// \brief The class template specializations for this class
|
||||||
|
/// template, including explicit specializations and instantiations.
|
||||||
|
llvm::FoldingSet<ClassTemplateSpecializationDecl> Specializations;
|
||||||
|
|
||||||
|
/// \brief The class template partial specializations for this class
|
||||||
|
/// template.
|
||||||
|
llvm::FoldingSet<ClassTemplatePartialSpecializationDecl>
|
||||||
|
PartialSpecializations;
|
||||||
|
|
||||||
|
/// \brief The injected-class-name type for this class template.
|
||||||
|
QualType InjectedClassNameType;
|
||||||
|
};
|
||||||
|
|
||||||
FunctionTemplateDecl(DeclContext *DC, SourceLocation L, DeclarationName Name,
|
FunctionTemplateDecl(DeclContext *DC, SourceLocation L, DeclarationName Name,
|
||||||
TemplateParameterList *Params, NamedDecl *Decl)
|
TemplateParameterList *Params, NamedDecl *Decl)
|
||||||
: TemplateDecl(FunctionTemplate, DC, L, Name, Params, Decl) { }
|
: TemplateDecl(FunctionTemplate, DC, L, Name, Params, Decl) { }
|
||||||
|
|
|
@ -372,8 +372,9 @@ void FunctionDecl::Destroy(ASTContext& C) {
|
||||||
|
|
||||||
C.Deallocate(ParamInfo);
|
C.Deallocate(ParamInfo);
|
||||||
|
|
||||||
if (TemplateSpecializationInfo *Info
|
if (FunctionTemplateSpecializationInfo *Info
|
||||||
= TemplateOrSpecialization.dyn_cast<TemplateSpecializationInfo*>())
|
= TemplateOrSpecialization
|
||||||
|
.dyn_cast<FunctionTemplateSpecializationInfo*>())
|
||||||
C.Deallocate(Info);
|
C.Deallocate(Info);
|
||||||
|
|
||||||
Decl::Destroy(C);
|
Decl::Destroy(C);
|
||||||
|
@ -572,14 +573,33 @@ OverloadedOperatorKind FunctionDecl::getOverloadedOperator() const {
|
||||||
return OO_None;
|
return OO_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FunctionTemplateDecl *FunctionDecl::getPrimaryTemplate() const {
|
||||||
|
if (FunctionTemplateSpecializationInfo *Info
|
||||||
|
= TemplateOrSpecialization
|
||||||
|
.dyn_cast<FunctionTemplateSpecializationInfo*>()) {
|
||||||
|
return Info->Template;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TemplateArgumentList *
|
||||||
|
FunctionDecl::getTemplateSpecializationArgs() const {
|
||||||
|
if (FunctionTemplateSpecializationInfo *Info
|
||||||
|
= TemplateOrSpecialization
|
||||||
|
.dyn_cast<FunctionTemplateSpecializationInfo*>()) {
|
||||||
|
return Info->TemplateArguments;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FunctionDecl::setFunctionTemplateSpecialization(ASTContext &Context,
|
FunctionDecl::setFunctionTemplateSpecialization(ASTContext &Context,
|
||||||
FunctionTemplateDecl *Template,
|
FunctionTemplateDecl *Template,
|
||||||
const TemplateArgumentList *TemplateArgs) {
|
const TemplateArgumentList *TemplateArgs) {
|
||||||
TemplateSpecializationInfo *Info
|
FunctionTemplateSpecializationInfo *Info
|
||||||
= TemplateOrSpecialization.dyn_cast<TemplateSpecializationInfo*>();
|
= TemplateOrSpecialization.dyn_cast<FunctionTemplateSpecializationInfo*>();
|
||||||
if (!Info)
|
if (!Info)
|
||||||
Info = new (Context) TemplateSpecializationInfo;
|
Info = new (Context) FunctionTemplateSpecializationInfo;
|
||||||
|
|
||||||
Info->Template = Template;
|
Info->Template = Template;
|
||||||
Info->TemplateArguments = TemplateArgs;
|
Info->TemplateArguments = TemplateArgs;
|
||||||
|
|
|
@ -1477,9 +1477,19 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
|
||||||
if (Diags.hasErrorOccurred())
|
if (Diags.hasErrorOccurred())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Ignore dependent declarations.
|
||||||
|
if (D->getDeclContext() && D->getDeclContext()->isDependentContext())
|
||||||
|
return;
|
||||||
|
|
||||||
switch (D->getKind()) {
|
switch (D->getKind()) {
|
||||||
case Decl::CXXMethod:
|
case Decl::CXXMethod:
|
||||||
case Decl::Function:
|
case Decl::Function:
|
||||||
|
// Skip function templates
|
||||||
|
if (cast<FunctionDecl>(D)->getDescribedFunctionTemplate())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Fall through
|
||||||
|
|
||||||
case Decl::Var:
|
case Decl::Var:
|
||||||
EmitGlobal(GlobalDecl(cast<ValueDecl>(D)));
|
EmitGlobal(GlobalDecl(cast<ValueDecl>(D)));
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue