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 StringLiteral;
|
||||
class TemplateArgumentList;
|
||||
class FunctionTemplateSpecializationInfo;
|
||||
|
||||
/// TranslationUnitDecl - The top declaration context.
|
||||
class TranslationUnitDecl : public Decl, public DeclContext {
|
||||
|
@ -621,15 +622,8 @@ public:
|
|||
enum StorageClass {
|
||||
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
|
||||
/// parameters of this function. This is null if a prototype or if there are
|
||||
/// no formals.
|
||||
|
@ -684,7 +678,8 @@ private:
|
|||
/// the template being specialized and the template arguments involved in
|
||||
/// that specialization.
|
||||
llvm::PointerUnion3<FunctionTemplateDecl*, FunctionDecl*,
|
||||
TemplateSpecializationInfo*> TemplateOrSpecialization;
|
||||
FunctionTemplateSpecializationInfo*>
|
||||
TemplateOrSpecialization;
|
||||
|
||||
protected:
|
||||
FunctionDecl(Kind DK, DeclContext *DC, SourceLocation L,
|
||||
|
@ -940,27 +935,14 @@ public:
|
|||
///
|
||||
/// If this function declaration is not a function template specialization,
|
||||
/// returns NULL.
|
||||
FunctionTemplateDecl *getPrimaryTemplate() const {
|
||||
if (TemplateSpecializationInfo *Info
|
||||
= TemplateOrSpecialization.dyn_cast<TemplateSpecializationInfo*>()) {
|
||||
return Info->Template;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
FunctionTemplateDecl *getPrimaryTemplate() const;
|
||||
|
||||
/// \brief Retrieve the template arguments used to produce this function
|
||||
/// template specialization from the primary template.
|
||||
///
|
||||
/// If this function declaration is not a function template specialization,
|
||||
/// returns NULL.
|
||||
const TemplateArgumentList *getTemplateSpecializationArgs() const {
|
||||
if (TemplateSpecializationInfo *Info
|
||||
= TemplateOrSpecialization.dyn_cast<TemplateSpecializationInfo*>()) {
|
||||
return Info->TemplateArguments;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const TemplateArgumentList *getTemplateSpecializationArgs() const;
|
||||
|
||||
/// \brief Specify that this function declaration is actually a function
|
||||
/// template specialization.
|
||||
|
|
|
@ -154,9 +154,34 @@ protected:
|
|||
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.
|
||||
class FunctionTemplateDecl : public TemplateDecl {
|
||||
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,
|
||||
TemplateParameterList *Params, NamedDecl *Decl)
|
||||
: TemplateDecl(FunctionTemplate, DC, L, Name, Params, Decl) { }
|
||||
|
|
|
@ -372,8 +372,9 @@ void FunctionDecl::Destroy(ASTContext& C) {
|
|||
|
||||
C.Deallocate(ParamInfo);
|
||||
|
||||
if (TemplateSpecializationInfo *Info
|
||||
= TemplateOrSpecialization.dyn_cast<TemplateSpecializationInfo*>())
|
||||
if (FunctionTemplateSpecializationInfo *Info
|
||||
= TemplateOrSpecialization
|
||||
.dyn_cast<FunctionTemplateSpecializationInfo*>())
|
||||
C.Deallocate(Info);
|
||||
|
||||
Decl::Destroy(C);
|
||||
|
@ -572,14 +573,33 @@ OverloadedOperatorKind FunctionDecl::getOverloadedOperator() const {
|
|||
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
|
||||
FunctionDecl::setFunctionTemplateSpecialization(ASTContext &Context,
|
||||
FunctionTemplateDecl *Template,
|
||||
const TemplateArgumentList *TemplateArgs) {
|
||||
TemplateSpecializationInfo *Info
|
||||
= TemplateOrSpecialization.dyn_cast<TemplateSpecializationInfo*>();
|
||||
FunctionTemplateSpecializationInfo *Info
|
||||
= TemplateOrSpecialization.dyn_cast<FunctionTemplateSpecializationInfo*>();
|
||||
if (!Info)
|
||||
Info = new (Context) TemplateSpecializationInfo;
|
||||
Info = new (Context) FunctionTemplateSpecializationInfo;
|
||||
|
||||
Info->Template = Template;
|
||||
Info->TemplateArguments = TemplateArgs;
|
||||
|
|
|
@ -1477,9 +1477,19 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
|
|||
if (Diags.hasErrorOccurred())
|
||||
return;
|
||||
|
||||
// Ignore dependent declarations.
|
||||
if (D->getDeclContext() && D->getDeclContext()->isDependentContext())
|
||||
return;
|
||||
|
||||
switch (D->getKind()) {
|
||||
case Decl::CXXMethod:
|
||||
case Decl::Function:
|
||||
// Skip function templates
|
||||
if (cast<FunctionDecl>(D)->getDescribedFunctionTemplate())
|
||||
return;
|
||||
|
||||
// Fall through
|
||||
|
||||
case Decl::Var:
|
||||
EmitGlobal(GlobalDecl(cast<ValueDecl>(D)));
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue