2009-03-18 00:15:40 +03:00
|
|
|
//===--- SemaTemplateInstantiateDecl.cpp - C++ Template Decl Instantiation ===/
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//===----------------------------------------------------------------------===/
|
|
|
|
//
|
|
|
|
// This file implements C++ template instantiation for declarations.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===/
|
|
|
|
#include "Sema.h"
|
2009-05-27 00:50:29 +04:00
|
|
|
#include "clang/AST/ASTConsumer.h"
|
2009-03-18 00:15:40 +03:00
|
|
|
#include "clang/AST/ASTContext.h"
|
|
|
|
#include "clang/AST/DeclTemplate.h"
|
|
|
|
#include "clang/AST/DeclVisitor.h"
|
|
|
|
#include "clang/AST/Expr.h"
|
|
|
|
#include "llvm/Support/Compiler.h"
|
|
|
|
|
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
class VISIBILITY_HIDDEN TemplateDeclInstantiator
|
2009-03-28 22:18:32 +03:00
|
|
|
: public DeclVisitor<TemplateDeclInstantiator, Decl *> {
|
2009-03-18 00:15:40 +03:00
|
|
|
Sema &SemaRef;
|
|
|
|
DeclContext *Owner;
|
2009-05-12 03:53:27 +04:00
|
|
|
const TemplateArgumentList &TemplateArgs;
|
2009-03-18 00:15:40 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
typedef Sema::OwningExprResult OwningExprResult;
|
|
|
|
|
|
|
|
TemplateDeclInstantiator(Sema &SemaRef, DeclContext *Owner,
|
2009-05-12 03:53:27 +04:00
|
|
|
const TemplateArgumentList &TemplateArgs)
|
|
|
|
: SemaRef(SemaRef), Owner(Owner), TemplateArgs(TemplateArgs) { }
|
2009-03-18 00:15:40 +03:00
|
|
|
|
2009-05-16 11:39:55 +04:00
|
|
|
// FIXME: Once we get closer to completion, replace these manually-written
|
|
|
|
// declarations with automatically-generated ones from
|
|
|
|
// clang/AST/DeclNodes.def.
|
2009-03-25 18:45:12 +03:00
|
|
|
Decl *VisitTranslationUnitDecl(TranslationUnitDecl *D);
|
|
|
|
Decl *VisitNamespaceDecl(NamespaceDecl *D);
|
2009-03-18 00:15:40 +03:00
|
|
|
Decl *VisitTypedefDecl(TypedefDecl *D);
|
2009-03-26 02:32:15 +03:00
|
|
|
Decl *VisitVarDecl(VarDecl *D);
|
2009-03-18 00:15:40 +03:00
|
|
|
Decl *VisitFieldDecl(FieldDecl *D);
|
|
|
|
Decl *VisitStaticAssertDecl(StaticAssertDecl *D);
|
|
|
|
Decl *VisitEnumDecl(EnumDecl *D);
|
2009-03-25 18:04:13 +03:00
|
|
|
Decl *VisitEnumConstantDecl(EnumConstantDecl *D);
|
2009-03-26 00:17:03 +03:00
|
|
|
Decl *VisitCXXRecordDecl(CXXRecordDecl *D);
|
2009-03-24 02:06:20 +03:00
|
|
|
Decl *VisitCXXMethodDecl(CXXMethodDecl *D);
|
2009-03-24 19:43:20 +03:00
|
|
|
Decl *VisitCXXConstructorDecl(CXXConstructorDecl *D);
|
2009-03-24 03:15:49 +03:00
|
|
|
Decl *VisitCXXDestructorDecl(CXXDestructorDecl *D);
|
2009-03-25 03:34:44 +03:00
|
|
|
Decl *VisitCXXConversionDecl(CXXConversionDecl *D);
|
2009-03-25 18:04:13 +03:00
|
|
|
ParmVarDecl *VisitParmVarDecl(ParmVarDecl *D);
|
2009-03-24 02:06:20 +03:00
|
|
|
Decl *VisitOriginalParmVarDecl(OriginalParmVarDecl *D);
|
2009-03-24 03:38:23 +03:00
|
|
|
|
2009-03-18 00:15:40 +03:00
|
|
|
// Base case. FIXME: Remove once we can instantiate everything.
|
|
|
|
Decl *VisitDecl(Decl *) {
|
2009-03-26 02:32:15 +03:00
|
|
|
assert(false && "Template instantiation of unknown declaration kind!");
|
2009-03-18 00:15:40 +03:00
|
|
|
return 0;
|
|
|
|
}
|
2009-03-24 03:38:23 +03:00
|
|
|
|
|
|
|
// Helper functions for instantiating methods.
|
|
|
|
QualType InstantiateFunctionType(FunctionDecl *D,
|
|
|
|
llvm::SmallVectorImpl<ParmVarDecl *> &Params);
|
|
|
|
bool InitMethodInstantiation(CXXMethodDecl *New, CXXMethodDecl *Tmpl);
|
2009-03-18 00:15:40 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2009-03-25 18:45:12 +03:00
|
|
|
Decl *
|
|
|
|
TemplateDeclInstantiator::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
|
|
|
|
assert(false && "Translation units cannot be instantiated");
|
|
|
|
return D;
|
|
|
|
}
|
|
|
|
|
|
|
|
Decl *
|
|
|
|
TemplateDeclInstantiator::VisitNamespaceDecl(NamespaceDecl *D) {
|
|
|
|
assert(false && "Namespaces cannot be instantiated");
|
|
|
|
return D;
|
|
|
|
}
|
|
|
|
|
2009-03-18 00:15:40 +03:00
|
|
|
Decl *TemplateDeclInstantiator::VisitTypedefDecl(TypedefDecl *D) {
|
|
|
|
bool Invalid = false;
|
|
|
|
QualType T = D->getUnderlyingType();
|
|
|
|
if (T->isDependentType()) {
|
2009-05-15 01:06:31 +04:00
|
|
|
T = SemaRef.InstantiateType(T, TemplateArgs,
|
|
|
|
D->getLocation(), D->getDeclName());
|
2009-03-18 00:15:40 +03:00
|
|
|
if (T.isNull()) {
|
|
|
|
Invalid = true;
|
|
|
|
T = SemaRef.Context.IntTy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the new typedef
|
|
|
|
TypedefDecl *Typedef
|
|
|
|
= TypedefDecl::Create(SemaRef.Context, Owner, D->getLocation(),
|
|
|
|
D->getIdentifier(), T);
|
|
|
|
if (Invalid)
|
|
|
|
Typedef->setInvalidDecl();
|
|
|
|
|
2009-04-10 01:40:53 +04:00
|
|
|
Owner->addDecl(SemaRef.Context, Typedef);
|
2009-03-18 00:15:40 +03:00
|
|
|
return Typedef;
|
|
|
|
}
|
|
|
|
|
2009-03-26 02:32:15 +03:00
|
|
|
Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
|
|
|
|
// Instantiate the type of the declaration
|
|
|
|
QualType T = SemaRef.InstantiateType(D->getType(), TemplateArgs,
|
|
|
|
D->getTypeSpecStartLoc(),
|
|
|
|
D->getDeclName());
|
|
|
|
if (T.isNull())
|
|
|
|
return 0;
|
|
|
|
|
2009-05-15 04:01:03 +04:00
|
|
|
// Build the instantiated declaration
|
2009-03-26 02:32:15 +03:00
|
|
|
VarDecl *Var = VarDecl::Create(SemaRef.Context, Owner,
|
|
|
|
D->getLocation(), D->getIdentifier(),
|
|
|
|
T, D->getStorageClass(),
|
|
|
|
D->getTypeSpecStartLoc());
|
|
|
|
Var->setThreadSpecified(D->isThreadSpecified());
|
|
|
|
Var->setCXXDirectInitializer(D->hasCXXDirectInitializer());
|
|
|
|
Var->setDeclaredInCondition(D->isDeclaredInCondition());
|
|
|
|
|
2009-05-16 11:39:55 +04:00
|
|
|
// FIXME: In theory, we could have a previous declaration for variables that
|
|
|
|
// are not static data members.
|
2009-03-26 02:32:15 +03:00
|
|
|
bool Redeclaration = false;
|
2009-04-25 12:06:05 +04:00
|
|
|
SemaRef.CheckVariableDeclaration(Var, 0, Redeclaration);
|
2009-04-10 01:40:53 +04:00
|
|
|
Owner->addDecl(SemaRef.Context, Var);
|
2009-03-26 02:32:15 +03:00
|
|
|
|
|
|
|
if (D->getInit()) {
|
|
|
|
OwningExprResult Init
|
2009-05-12 03:53:27 +04:00
|
|
|
= SemaRef.InstantiateExpr(D->getInit(), TemplateArgs);
|
2009-03-26 02:32:15 +03:00
|
|
|
if (Init.isInvalid())
|
|
|
|
Var->setInvalidDecl();
|
|
|
|
else
|
2009-03-28 22:18:32 +03:00
|
|
|
SemaRef.AddInitializerToDecl(Sema::DeclPtrTy::make(Var), move(Init),
|
2009-03-26 02:32:15 +03:00
|
|
|
D->hasCXXDirectInitializer());
|
2009-05-19 00:51:54 +04:00
|
|
|
} else {
|
|
|
|
// FIXME: Call ActOnUninitializedDecl? (Not always)
|
2009-03-26 02:32:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return Var;
|
|
|
|
}
|
|
|
|
|
2009-03-18 00:15:40 +03:00
|
|
|
Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) {
|
|
|
|
bool Invalid = false;
|
|
|
|
QualType T = D->getType();
|
|
|
|
if (T->isDependentType()) {
|
2009-05-15 01:06:31 +04:00
|
|
|
T = SemaRef.InstantiateType(T, TemplateArgs,
|
|
|
|
D->getLocation(), D->getDeclName());
|
2009-03-18 00:15:40 +03:00
|
|
|
if (!T.isNull() && T->isFunctionType()) {
|
|
|
|
// C++ [temp.arg.type]p3:
|
|
|
|
// If a declaration acquires a function type through a type
|
|
|
|
// dependent on a template-parameter and this causes a
|
|
|
|
// declaration that does not use the syntactic form of a
|
|
|
|
// function declarator to have function type, the program is
|
|
|
|
// ill-formed.
|
|
|
|
SemaRef.Diag(D->getLocation(), diag::err_field_instantiates_to_function)
|
|
|
|
<< T;
|
|
|
|
T = QualType();
|
|
|
|
Invalid = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Expr *BitWidth = D->getBitWidth();
|
|
|
|
if (Invalid)
|
|
|
|
BitWidth = 0;
|
|
|
|
else if (BitWidth) {
|
|
|
|
OwningExprResult InstantiatedBitWidth
|
2009-05-12 03:53:27 +04:00
|
|
|
= SemaRef.InstantiateExpr(BitWidth, TemplateArgs);
|
2009-03-18 00:15:40 +03:00
|
|
|
if (InstantiatedBitWidth.isInvalid()) {
|
|
|
|
Invalid = true;
|
|
|
|
BitWidth = 0;
|
|
|
|
} else
|
2009-05-01 23:49:17 +04:00
|
|
|
BitWidth = InstantiatedBitWidth.takeAs<Expr>();
|
2009-03-18 00:15:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
FieldDecl *Field = SemaRef.CheckFieldDecl(D->getDeclName(), T,
|
|
|
|
cast<RecordDecl>(Owner),
|
|
|
|
D->getLocation(),
|
|
|
|
D->isMutable(),
|
|
|
|
BitWidth,
|
|
|
|
D->getAccess(),
|
|
|
|
0);
|
|
|
|
if (Field) {
|
|
|
|
if (Invalid)
|
|
|
|
Field->setInvalidDecl();
|
|
|
|
|
2009-04-10 01:40:53 +04:00
|
|
|
Owner->addDecl(SemaRef.Context, Field);
|
2009-03-18 00:15:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return Field;
|
|
|
|
}
|
|
|
|
|
|
|
|
Decl *TemplateDeclInstantiator::VisitStaticAssertDecl(StaticAssertDecl *D) {
|
|
|
|
Expr *AssertExpr = D->getAssertExpr();
|
|
|
|
|
|
|
|
OwningExprResult InstantiatedAssertExpr
|
2009-05-12 03:53:27 +04:00
|
|
|
= SemaRef.InstantiateExpr(AssertExpr, TemplateArgs);
|
2009-03-18 00:15:40 +03:00
|
|
|
if (InstantiatedAssertExpr.isInvalid())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
OwningExprResult Message = SemaRef.Clone(D->getMessage());
|
|
|
|
Decl *StaticAssert
|
2009-03-28 22:18:32 +03:00
|
|
|
= SemaRef.ActOnStaticAssertDeclaration(D->getLocation(),
|
|
|
|
move(InstantiatedAssertExpr),
|
|
|
|
move(Message)).getAs<Decl>();
|
2009-03-18 00:15:40 +03:00
|
|
|
return StaticAssert;
|
|
|
|
}
|
|
|
|
|
|
|
|
Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) {
|
|
|
|
EnumDecl *Enum = EnumDecl::Create(SemaRef.Context, Owner,
|
|
|
|
D->getLocation(), D->getIdentifier(),
|
|
|
|
/*PrevDecl=*/0);
|
2009-03-26 01:00:53 +03:00
|
|
|
Enum->setAccess(D->getAccess());
|
2009-04-10 01:40:53 +04:00
|
|
|
Owner->addDecl(SemaRef.Context, Enum);
|
2009-03-18 00:15:40 +03:00
|
|
|
Enum->startDefinition();
|
|
|
|
|
2009-03-28 22:18:32 +03:00
|
|
|
llvm::SmallVector<Sema::DeclPtrTy, 16> Enumerators;
|
2009-03-18 00:15:40 +03:00
|
|
|
|
|
|
|
EnumConstantDecl *LastEnumConst = 0;
|
2009-04-10 01:40:53 +04:00
|
|
|
for (EnumDecl::enumerator_iterator EC = D->enumerator_begin(SemaRef.Context),
|
|
|
|
ECEnd = D->enumerator_end(SemaRef.Context);
|
2009-03-18 00:15:40 +03:00
|
|
|
EC != ECEnd; ++EC) {
|
|
|
|
// The specified value for the enumerator.
|
|
|
|
OwningExprResult Value = SemaRef.Owned((Expr *)0);
|
|
|
|
if (Expr *UninstValue = EC->getInitExpr())
|
2009-05-12 03:53:27 +04:00
|
|
|
Value = SemaRef.InstantiateExpr(UninstValue, TemplateArgs);
|
2009-03-18 00:15:40 +03:00
|
|
|
|
|
|
|
// Drop the initial value and continue.
|
|
|
|
bool isInvalid = false;
|
|
|
|
if (Value.isInvalid()) {
|
|
|
|
Value = SemaRef.Owned((Expr *)0);
|
|
|
|
isInvalid = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
EnumConstantDecl *EnumConst
|
|
|
|
= SemaRef.CheckEnumConstant(Enum, LastEnumConst,
|
|
|
|
EC->getLocation(), EC->getIdentifier(),
|
|
|
|
move(Value));
|
|
|
|
|
|
|
|
if (isInvalid) {
|
|
|
|
if (EnumConst)
|
|
|
|
EnumConst->setInvalidDecl();
|
|
|
|
Enum->setInvalidDecl();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EnumConst) {
|
2009-04-10 01:40:53 +04:00
|
|
|
Enum->addDecl(SemaRef.Context, EnumConst);
|
2009-03-28 22:18:32 +03:00
|
|
|
Enumerators.push_back(Sema::DeclPtrTy::make(EnumConst));
|
2009-03-18 00:15:40 +03:00
|
|
|
LastEnumConst = EnumConst;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-16 11:06:02 +04:00
|
|
|
// FIXME: Fixup LBraceLoc and RBraceLoc
|
|
|
|
SemaRef.ActOnEnumBody(Enum->getLocation(), SourceLocation(), SourceLocation(),
|
|
|
|
Sema::DeclPtrTy::make(Enum),
|
2009-03-18 00:15:40 +03:00
|
|
|
&Enumerators[0], Enumerators.size());
|
|
|
|
|
|
|
|
return Enum;
|
|
|
|
}
|
|
|
|
|
2009-03-25 18:04:13 +03:00
|
|
|
Decl *TemplateDeclInstantiator::VisitEnumConstantDecl(EnumConstantDecl *D) {
|
|
|
|
assert(false && "EnumConstantDecls can only occur within EnumDecls.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-26 00:17:03 +03:00
|
|
|
Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) {
|
|
|
|
CXXRecordDecl *PrevDecl = 0;
|
|
|
|
if (D->isInjectedClassName())
|
|
|
|
PrevDecl = cast<CXXRecordDecl>(Owner);
|
|
|
|
|
|
|
|
CXXRecordDecl *Record
|
|
|
|
= CXXRecordDecl::Create(SemaRef.Context, D->getTagKind(), Owner,
|
|
|
|
D->getLocation(), D->getIdentifier(), PrevDecl);
|
|
|
|
Record->setImplicit(D->isImplicit());
|
|
|
|
Record->setAccess(D->getAccess());
|
|
|
|
if (!D->isInjectedClassName())
|
|
|
|
Record->setInstantiationOfMemberClass(D);
|
|
|
|
|
2009-04-10 01:40:53 +04:00
|
|
|
Owner->addDecl(SemaRef.Context, Record);
|
2009-03-26 00:17:03 +03:00
|
|
|
return Record;
|
|
|
|
}
|
|
|
|
|
2009-03-24 02:06:20 +03:00
|
|
|
Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D) {
|
|
|
|
// Only handle actual methods; we'll deal with constructors,
|
|
|
|
// destructors, etc. separately.
|
|
|
|
if (D->getKind() != Decl::CXXMethod)
|
|
|
|
return 0;
|
|
|
|
|
2009-05-15 01:44:34 +04:00
|
|
|
Sema::LocalInstantiationScope Scope(SemaRef);
|
|
|
|
|
2009-03-24 03:38:23 +03:00
|
|
|
llvm::SmallVector<ParmVarDecl *, 16> Params;
|
|
|
|
QualType T = InstantiateFunctionType(D, Params);
|
2009-03-24 02:06:20 +03:00
|
|
|
if (T.isNull())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Build the instantiated method declaration.
|
|
|
|
CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner);
|
|
|
|
CXXMethodDecl *Method
|
|
|
|
= CXXMethodDecl::Create(SemaRef.Context, Record, D->getLocation(),
|
|
|
|
D->getDeclName(), T, D->isStatic(),
|
|
|
|
D->isInline());
|
2009-05-15 01:06:31 +04:00
|
|
|
Method->setInstantiationOfMemberFunction(D);
|
2009-03-24 02:06:20 +03:00
|
|
|
|
2009-03-24 03:38:23 +03:00
|
|
|
// Attach the parameters
|
|
|
|
for (unsigned P = 0; P < Params.size(); ++P)
|
|
|
|
Params[P]->setOwningFunction(Method);
|
2009-05-21 13:52:38 +04:00
|
|
|
Method->setParams(SemaRef.Context, Params.data(), Params.size());
|
2009-03-24 03:38:23 +03:00
|
|
|
|
|
|
|
if (InitMethodInstantiation(Method, D))
|
|
|
|
Method->setInvalidDecl();
|
2009-03-24 02:06:20 +03:00
|
|
|
|
|
|
|
NamedDecl *PrevDecl
|
|
|
|
= SemaRef.LookupQualifiedName(Owner, Method->getDeclName(),
|
|
|
|
Sema::LookupOrdinaryName, true);
|
|
|
|
// In C++, the previous declaration we find might be a tag type
|
|
|
|
// (class or enum). In this case, the new declaration will hide the
|
|
|
|
// tag type. Note that this does does not apply if we're declaring a
|
|
|
|
// typedef (C++ [dcl.typedef]p4).
|
|
|
|
if (PrevDecl && PrevDecl->getIdentifierNamespace() == Decl::IDNS_Tag)
|
|
|
|
PrevDecl = 0;
|
|
|
|
bool Redeclaration = false;
|
|
|
|
bool OverloadableAttrRequired = false;
|
2009-04-25 12:06:05 +04:00
|
|
|
SemaRef.CheckFunctionDeclaration(Method, PrevDecl, Redeclaration,
|
|
|
|
/*FIXME:*/OverloadableAttrRequired);
|
2009-03-24 02:06:20 +03:00
|
|
|
|
|
|
|
if (!Method->isInvalidDecl() || !PrevDecl)
|
2009-04-10 01:40:53 +04:00
|
|
|
Owner->addDecl(SemaRef.Context, Method);
|
2009-03-24 02:06:20 +03:00
|
|
|
return Method;
|
|
|
|
}
|
|
|
|
|
2009-03-24 19:43:20 +03:00
|
|
|
Decl *TemplateDeclInstantiator::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
|
2009-05-15 01:44:34 +04:00
|
|
|
Sema::LocalInstantiationScope Scope(SemaRef);
|
|
|
|
|
2009-03-24 19:43:20 +03:00
|
|
|
llvm::SmallVector<ParmVarDecl *, 16> Params;
|
|
|
|
QualType T = InstantiateFunctionType(D, Params);
|
|
|
|
if (T.isNull())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Build the instantiated method declaration.
|
|
|
|
CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner);
|
|
|
|
QualType ClassTy = SemaRef.Context.getTypeDeclType(Record);
|
|
|
|
DeclarationName Name
|
2009-05-16 01:18:27 +04:00
|
|
|
= SemaRef.Context.DeclarationNames.getCXXConstructorName(
|
|
|
|
SemaRef.Context.getCanonicalType(ClassTy));
|
2009-03-24 19:43:20 +03:00
|
|
|
CXXConstructorDecl *Constructor
|
|
|
|
= CXXConstructorDecl::Create(SemaRef.Context, Record, D->getLocation(),
|
|
|
|
Name, T, D->isExplicit(), D->isInline(),
|
|
|
|
false);
|
2009-05-15 01:06:31 +04:00
|
|
|
Constructor->setInstantiationOfMemberFunction(D);
|
2009-03-24 19:43:20 +03:00
|
|
|
|
|
|
|
// Attach the parameters
|
|
|
|
for (unsigned P = 0; P < Params.size(); ++P)
|
|
|
|
Params[P]->setOwningFunction(Constructor);
|
2009-05-21 13:52:38 +04:00
|
|
|
Constructor->setParams(SemaRef.Context, Params.data(), Params.size());
|
2009-03-24 19:43:20 +03:00
|
|
|
|
|
|
|
if (InitMethodInstantiation(Constructor, D))
|
|
|
|
Constructor->setInvalidDecl();
|
|
|
|
|
|
|
|
NamedDecl *PrevDecl
|
|
|
|
= SemaRef.LookupQualifiedName(Owner, Name, Sema::LookupOrdinaryName, true);
|
|
|
|
|
|
|
|
// In C++, the previous declaration we find might be a tag type
|
|
|
|
// (class or enum). In this case, the new declaration will hide the
|
|
|
|
// tag type. Note that this does does not apply if we're declaring a
|
|
|
|
// typedef (C++ [dcl.typedef]p4).
|
|
|
|
if (PrevDecl && PrevDecl->getIdentifierNamespace() == Decl::IDNS_Tag)
|
|
|
|
PrevDecl = 0;
|
|
|
|
bool Redeclaration = false;
|
|
|
|
bool OverloadableAttrRequired = false;
|
2009-04-25 12:06:05 +04:00
|
|
|
SemaRef.CheckFunctionDeclaration(Constructor, PrevDecl, Redeclaration,
|
|
|
|
/*FIXME:*/OverloadableAttrRequired);
|
2009-03-24 19:43:20 +03:00
|
|
|
|
2009-05-16 01:18:27 +04:00
|
|
|
Record->addedConstructor(SemaRef.Context, Constructor);
|
2009-04-25 12:06:05 +04:00
|
|
|
Owner->addDecl(SemaRef.Context, Constructor);
|
2009-03-24 19:43:20 +03:00
|
|
|
return Constructor;
|
|
|
|
}
|
|
|
|
|
2009-03-24 03:15:49 +03:00
|
|
|
Decl *TemplateDeclInstantiator::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
|
2009-05-15 01:44:34 +04:00
|
|
|
Sema::LocalInstantiationScope Scope(SemaRef);
|
|
|
|
|
2009-03-24 03:38:23 +03:00
|
|
|
llvm::SmallVector<ParmVarDecl *, 16> Params;
|
|
|
|
QualType T = InstantiateFunctionType(D, Params);
|
2009-03-24 03:15:49 +03:00
|
|
|
if (T.isNull())
|
|
|
|
return 0;
|
2009-03-24 03:38:23 +03:00
|
|
|
assert(Params.size() == 0 && "Destructor with parameters?");
|
|
|
|
|
2009-03-24 03:15:49 +03:00
|
|
|
// Build the instantiated destructor declaration.
|
|
|
|
CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner);
|
2009-05-16 01:18:27 +04:00
|
|
|
QualType ClassTy =
|
|
|
|
SemaRef.Context.getCanonicalType(SemaRef.Context.getTypeDeclType(Record));
|
2009-03-24 03:15:49 +03:00
|
|
|
CXXDestructorDecl *Destructor
|
|
|
|
= CXXDestructorDecl::Create(SemaRef.Context, Record,
|
|
|
|
D->getLocation(),
|
|
|
|
SemaRef.Context.DeclarationNames.getCXXDestructorName(ClassTy),
|
|
|
|
T, D->isInline(), false);
|
2009-05-15 01:06:31 +04:00
|
|
|
Destructor->setInstantiationOfMemberFunction(D);
|
2009-03-24 03:38:23 +03:00
|
|
|
if (InitMethodInstantiation(Destructor, D))
|
|
|
|
Destructor->setInvalidDecl();
|
2009-03-24 03:15:49 +03:00
|
|
|
|
|
|
|
bool Redeclaration = false;
|
|
|
|
bool OverloadableAttrRequired = false;
|
|
|
|
NamedDecl *PrevDecl = 0;
|
2009-04-25 12:06:05 +04:00
|
|
|
SemaRef.CheckFunctionDeclaration(Destructor, PrevDecl, Redeclaration,
|
|
|
|
/*FIXME:*/OverloadableAttrRequired);
|
2009-04-10 01:40:53 +04:00
|
|
|
Owner->addDecl(SemaRef.Context, Destructor);
|
2009-03-24 03:15:49 +03:00
|
|
|
return Destructor;
|
|
|
|
}
|
|
|
|
|
2009-03-25 03:34:44 +03:00
|
|
|
Decl *TemplateDeclInstantiator::VisitCXXConversionDecl(CXXConversionDecl *D) {
|
2009-05-15 01:44:34 +04:00
|
|
|
Sema::LocalInstantiationScope Scope(SemaRef);
|
|
|
|
|
2009-03-25 03:34:44 +03:00
|
|
|
llvm::SmallVector<ParmVarDecl *, 16> Params;
|
|
|
|
QualType T = InstantiateFunctionType(D, Params);
|
|
|
|
if (T.isNull())
|
|
|
|
return 0;
|
|
|
|
assert(Params.size() == 0 && "Destructor with parameters?");
|
|
|
|
|
|
|
|
// Build the instantiated conversion declaration.
|
|
|
|
CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner);
|
|
|
|
QualType ClassTy = SemaRef.Context.getTypeDeclType(Record);
|
|
|
|
QualType ConvTy
|
|
|
|
= SemaRef.Context.getCanonicalType(T->getAsFunctionType()->getResultType());
|
|
|
|
CXXConversionDecl *Conversion
|
|
|
|
= CXXConversionDecl::Create(SemaRef.Context, Record,
|
|
|
|
D->getLocation(),
|
|
|
|
SemaRef.Context.DeclarationNames.getCXXConversionFunctionName(ConvTy),
|
|
|
|
T, D->isInline(), D->isExplicit());
|
2009-05-15 01:06:31 +04:00
|
|
|
Conversion->setInstantiationOfMemberFunction(D);
|
2009-03-25 03:34:44 +03:00
|
|
|
if (InitMethodInstantiation(Conversion, D))
|
|
|
|
Conversion->setInvalidDecl();
|
|
|
|
|
|
|
|
bool Redeclaration = false;
|
|
|
|
bool OverloadableAttrRequired = false;
|
|
|
|
NamedDecl *PrevDecl = 0;
|
2009-04-25 12:06:05 +04:00
|
|
|
SemaRef.CheckFunctionDeclaration(Conversion, PrevDecl, Redeclaration,
|
|
|
|
/*FIXME:*/OverloadableAttrRequired);
|
2009-04-10 01:40:53 +04:00
|
|
|
Owner->addDecl(SemaRef.Context, Conversion);
|
2009-03-25 03:34:44 +03:00
|
|
|
return Conversion;
|
|
|
|
}
|
|
|
|
|
2009-03-25 18:04:13 +03:00
|
|
|
ParmVarDecl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
|
2009-03-24 02:06:20 +03:00
|
|
|
QualType OrigT = SemaRef.InstantiateType(D->getOriginalType(), TemplateArgs,
|
2009-05-12 03:53:27 +04:00
|
|
|
D->getLocation(), D->getDeclName());
|
2009-03-24 02:06:20 +03:00
|
|
|
if (OrigT.isNull())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
QualType T = SemaRef.adjustParameterType(OrigT);
|
|
|
|
|
|
|
|
if (D->getDefaultArg()) {
|
|
|
|
// FIXME: Leave a marker for "uninstantiated" default
|
|
|
|
// arguments. They only get instantiated on demand at the call
|
|
|
|
// site.
|
|
|
|
unsigned DiagID = SemaRef.Diags.getCustomDiagID(Diagnostic::Warning,
|
|
|
|
"sorry, dropping default argument during template instantiation");
|
|
|
|
SemaRef.Diag(D->getDefaultArg()->getSourceRange().getBegin(), DiagID)
|
|
|
|
<< D->getDefaultArg()->getSourceRange();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Allocate the parameter
|
|
|
|
ParmVarDecl *Param = 0;
|
|
|
|
if (T == OrigT)
|
|
|
|
Param = ParmVarDecl::Create(SemaRef.Context, Owner, D->getLocation(),
|
|
|
|
D->getIdentifier(), T, D->getStorageClass(),
|
|
|
|
0);
|
|
|
|
else
|
|
|
|
Param = OriginalParmVarDecl::Create(SemaRef.Context, Owner,
|
|
|
|
D->getLocation(), D->getIdentifier(),
|
|
|
|
T, OrigT, D->getStorageClass(), 0);
|
|
|
|
|
|
|
|
// Note: we don't try to instantiate function parameters until after
|
|
|
|
// we've instantiated the function's type. Therefore, we don't have
|
|
|
|
// to check for 'void' parameter types here.
|
2009-05-15 01:44:34 +04:00
|
|
|
SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Param);
|
2009-03-24 02:06:20 +03:00
|
|
|
return Param;
|
|
|
|
}
|
|
|
|
|
|
|
|
Decl *
|
|
|
|
TemplateDeclInstantiator::VisitOriginalParmVarDecl(OriginalParmVarDecl *D) {
|
|
|
|
// Since parameter types can decay either before or after
|
|
|
|
// instantiation, we simply treat OriginalParmVarDecls as
|
|
|
|
// ParmVarDecls the same way, and create one or the other depending
|
|
|
|
// on what happens after template instantiation.
|
|
|
|
return VisitParmVarDecl(D);
|
|
|
|
}
|
|
|
|
|
2009-03-18 00:15:40 +03:00
|
|
|
Decl *Sema::InstantiateDecl(Decl *D, DeclContext *Owner,
|
2009-05-12 03:53:27 +04:00
|
|
|
const TemplateArgumentList &TemplateArgs) {
|
|
|
|
TemplateDeclInstantiator Instantiator(*this, Owner, TemplateArgs);
|
2009-03-18 00:15:40 +03:00
|
|
|
return Instantiator.Visit(D);
|
|
|
|
}
|
|
|
|
|
2009-03-24 03:38:23 +03:00
|
|
|
/// \brief Instantiates the type of the given function, including
|
|
|
|
/// instantiating all of the function parameters.
|
|
|
|
///
|
|
|
|
/// \param D The function that we will be instantiated
|
|
|
|
///
|
|
|
|
/// \param Params the instantiated parameter declarations
|
|
|
|
|
|
|
|
/// \returns the instantiated function's type if successfull, a NULL
|
|
|
|
/// type if there was an error.
|
|
|
|
QualType
|
|
|
|
TemplateDeclInstantiator::InstantiateFunctionType(FunctionDecl *D,
|
|
|
|
llvm::SmallVectorImpl<ParmVarDecl *> &Params) {
|
|
|
|
bool InvalidDecl = false;
|
|
|
|
|
|
|
|
// Instantiate the function parameters
|
2009-05-12 03:53:27 +04:00
|
|
|
TemplateDeclInstantiator ParamInstantiator(SemaRef, 0, TemplateArgs);
|
2009-03-24 03:38:23 +03:00
|
|
|
llvm::SmallVector<QualType, 16> ParamTys;
|
|
|
|
for (FunctionDecl::param_iterator P = D->param_begin(),
|
|
|
|
PEnd = D->param_end();
|
|
|
|
P != PEnd; ++P) {
|
2009-03-25 18:04:13 +03:00
|
|
|
if (ParmVarDecl *PInst = ParamInstantiator.VisitParmVarDecl(*P)) {
|
2009-03-24 03:38:23 +03:00
|
|
|
if (PInst->getType()->isVoidType()) {
|
|
|
|
SemaRef.Diag(PInst->getLocation(), diag::err_param_with_void_type);
|
|
|
|
PInst->setInvalidDecl();
|
|
|
|
}
|
|
|
|
else if (SemaRef.RequireNonAbstractType(PInst->getLocation(),
|
|
|
|
PInst->getType(),
|
|
|
|
diag::err_abstract_type_in_decl,
|
2009-03-24 04:19:16 +03:00
|
|
|
Sema::AbstractParamType))
|
2009-03-24 03:38:23 +03:00
|
|
|
PInst->setInvalidDecl();
|
|
|
|
|
|
|
|
Params.push_back(PInst);
|
|
|
|
ParamTys.push_back(PInst->getType());
|
|
|
|
|
|
|
|
if (PInst->isInvalidDecl())
|
|
|
|
InvalidDecl = true;
|
|
|
|
} else
|
|
|
|
InvalidDecl = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: Deallocate dead declarations.
|
|
|
|
if (InvalidDecl)
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
const FunctionProtoType *Proto = D->getType()->getAsFunctionProtoType();
|
|
|
|
assert(Proto && "Missing prototype?");
|
|
|
|
QualType ResultType
|
2009-05-15 01:06:31 +04:00
|
|
|
= SemaRef.InstantiateType(Proto->getResultType(), TemplateArgs,
|
2009-03-24 03:38:23 +03:00
|
|
|
D->getLocation(), D->getDeclName());
|
|
|
|
if (ResultType.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
2009-05-21 13:52:38 +04:00
|
|
|
return SemaRef.BuildFunctionType(ResultType, ParamTys.data(), ParamTys.size(),
|
2009-03-24 03:38:23 +03:00
|
|
|
Proto->isVariadic(), Proto->getTypeQuals(),
|
|
|
|
D->getLocation(), D->getDeclName());
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Initializes common fields of an instantiated method
|
|
|
|
/// declaration (New) from the corresponding fields of its template
|
|
|
|
/// (Tmpl).
|
|
|
|
///
|
|
|
|
/// \returns true if there was an error
|
|
|
|
bool
|
|
|
|
TemplateDeclInstantiator::InitMethodInstantiation(CXXMethodDecl *New,
|
|
|
|
CXXMethodDecl *Tmpl) {
|
|
|
|
CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner);
|
|
|
|
New->setAccess(Tmpl->getAccess());
|
2009-05-15 02:15:41 +04:00
|
|
|
if (Tmpl->isVirtualAsWritten()) {
|
|
|
|
New->setVirtualAsWritten(true);
|
2009-03-24 03:38:23 +03:00
|
|
|
Record->setAggregate(false);
|
|
|
|
Record->setPOD(false);
|
|
|
|
Record->setPolymorphic(true);
|
|
|
|
}
|
|
|
|
if (Tmpl->isDeleted())
|
|
|
|
New->setDeleted();
|
|
|
|
if (Tmpl->isPure()) {
|
|
|
|
New->setPure();
|
|
|
|
Record->setAbstract(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: attributes
|
|
|
|
// FIXME: New needs a pointer to Tmpl
|
|
|
|
return false;
|
|
|
|
}
|
2009-05-14 00:28:22 +04:00
|
|
|
|
|
|
|
/// \brief Instantiate the definition of the given function from its
|
|
|
|
/// template.
|
|
|
|
///
|
|
|
|
/// \param Function the already-instantiated declaration of a
|
|
|
|
/// function.
|
2009-05-18 21:01:57 +04:00
|
|
|
void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
|
|
|
|
FunctionDecl *Function) {
|
2009-05-15 01:06:31 +04:00
|
|
|
// FIXME: make this work for function template specializations, too.
|
|
|
|
|
2009-05-15 03:26:13 +04:00
|
|
|
if (Function->isInvalidDecl())
|
|
|
|
return;
|
|
|
|
|
2009-05-15 01:06:31 +04:00
|
|
|
// Find the function body that we'll be substituting.
|
|
|
|
const FunctionDecl *PatternDecl
|
|
|
|
= Function->getInstantiatedFromMemberFunction();
|
|
|
|
Stmt *Pattern = 0;
|
|
|
|
if (PatternDecl)
|
|
|
|
Pattern = PatternDecl->getBody(Context, PatternDecl);
|
|
|
|
|
|
|
|
if (!Pattern)
|
|
|
|
return;
|
|
|
|
|
2009-05-18 21:01:57 +04:00
|
|
|
InstantiatingTemplate Inst(*this, PointOfInstantiation, Function);
|
|
|
|
if (Inst)
|
|
|
|
return;
|
2009-05-15 04:01:03 +04:00
|
|
|
|
2009-05-15 21:59:04 +04:00
|
|
|
ActOnStartOfFunctionDef(0, DeclPtrTy::make(Function));
|
|
|
|
|
2009-05-15 03:26:13 +04:00
|
|
|
// Introduce a new scope where local variable instantiations will be
|
|
|
|
// recorded.
|
|
|
|
LocalInstantiationScope Scope(*this);
|
|
|
|
|
|
|
|
// Introduce the instantiated function parameters into the local
|
|
|
|
// instantiation scope.
|
|
|
|
for (unsigned I = 0, N = PatternDecl->getNumParams(); I != N; ++I)
|
|
|
|
Scope.InstantiatedLocal(PatternDecl->getParamDecl(I),
|
|
|
|
Function->getParamDecl(I));
|
|
|
|
|
2009-05-15 04:01:03 +04:00
|
|
|
// Enter the scope of this instantiation. We don't use
|
|
|
|
// PushDeclContext because we don't have a scope.
|
|
|
|
DeclContext *PreviousContext = CurContext;
|
|
|
|
CurContext = Function;
|
|
|
|
|
2009-05-15 03:26:13 +04:00
|
|
|
// Instantiate the function body.
|
|
|
|
OwningStmtResult Body
|
|
|
|
= InstantiateStmt(Pattern, getTemplateInstantiationArgs(Function));
|
2009-05-15 21:59:04 +04:00
|
|
|
|
|
|
|
ActOnFinishFunctionBody(DeclPtrTy::make(Function), move(Body),
|
|
|
|
/*IsInstantiation=*/true);
|
2009-05-15 04:01:03 +04:00
|
|
|
|
|
|
|
CurContext = PreviousContext;
|
2009-05-27 00:50:29 +04:00
|
|
|
|
|
|
|
DeclGroupRef DG(Function);
|
|
|
|
Consumer.HandleTopLevelDecl(DG);
|
2009-05-14 00:28:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Instantiate the definition of the given variable from its
|
|
|
|
/// template.
|
|
|
|
///
|
|
|
|
/// \param Var the already-instantiated declaration of a variable.
|
|
|
|
void Sema::InstantiateVariableDefinition(VarDecl *Var) {
|
|
|
|
// FIXME: Implement this!
|
|
|
|
}
|
2009-05-27 09:35:12 +04:00
|
|
|
|
|
|
|
static bool isInstantiationOf(ASTContext &Ctx, NamedDecl *D, Decl *Other) {
|
|
|
|
if (D->getKind() != Other->getKind())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Other))
|
|
|
|
return Ctx.getCanonicalDecl(Record->getInstantiatedFromMemberClass())
|
|
|
|
== Ctx.getCanonicalDecl(D);
|
|
|
|
|
|
|
|
if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Other))
|
|
|
|
return Ctx.getCanonicalDecl(Function->getInstantiatedFromMemberFunction())
|
|
|
|
== Ctx.getCanonicalDecl(D);
|
|
|
|
|
|
|
|
// FIXME: Need something similar to the above for EnumDecls.
|
|
|
|
|
|
|
|
// FIXME: How can we find instantiations of anonymous unions?
|
|
|
|
|
|
|
|
return D->getDeclName() && isa<NamedDecl>(Other) &&
|
|
|
|
D->getDeclName() == cast<NamedDecl>(Other)->getDeclName();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename ForwardIterator>
|
|
|
|
static NamedDecl *findInstantiationOf(ASTContext &Ctx,
|
|
|
|
NamedDecl *D,
|
|
|
|
ForwardIterator first,
|
|
|
|
ForwardIterator last) {
|
|
|
|
for (; first != last; ++first)
|
|
|
|
if (isInstantiationOf(Ctx, D, *first))
|
|
|
|
return cast<NamedDecl>(*first);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Find the instantiation of the given declaration with the
|
|
|
|
/// given template arguments.
|
|
|
|
///
|
|
|
|
/// This routine is intended to be used when \p D is a declaration
|
|
|
|
/// referenced from within a template, that needs to mapped into the
|
|
|
|
/// corresponding declaration within an instantiation. For example,
|
|
|
|
/// given:
|
|
|
|
///
|
|
|
|
/// \code
|
|
|
|
/// template<typename T>
|
|
|
|
/// struct X {
|
|
|
|
/// enum Kind {
|
|
|
|
/// KnownValue = sizeof(T)
|
|
|
|
/// };
|
|
|
|
///
|
|
|
|
/// bool getKind() const { return KnownValue; }
|
|
|
|
/// };
|
|
|
|
///
|
|
|
|
/// template struct X<int>;
|
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// In the instantiation of X<int>::getKind(), we need to map the
|
|
|
|
/// EnumConstantDecl for KnownValue (which refers to
|
|
|
|
/// X<T>::<Kind>::KnownValue) to its instantiation
|
|
|
|
/// (X<int>::<Kind>::KnownValue). InstantiateDeclRef() performs this
|
|
|
|
/// mapping, given the template arguments 'int'.
|
|
|
|
NamedDecl *
|
|
|
|
Sema::InstantiateDeclRef(NamedDecl *D, const TemplateArgumentList &TemplateArgs) {
|
|
|
|
DeclContext *ParentDC = D->getDeclContext();
|
2009-05-27 21:07:49 +04:00
|
|
|
if (isa<ParmVarDecl>(D) || ParentDC->isFunctionOrMethod()) {
|
|
|
|
// D is a local of some kind. Look into the map of local
|
|
|
|
// declarations to their instantiations.
|
|
|
|
return cast<NamedDecl>(CurrentInstantiationScope->getInstantiationOf(D));
|
|
|
|
}
|
2009-05-27 09:35:12 +04:00
|
|
|
|
2009-05-27 21:07:49 +04:00
|
|
|
if (NamedDecl *ParentDecl = dyn_cast<NamedDecl>(ParentDC)) {
|
2009-05-27 09:35:12 +04:00
|
|
|
ParentDecl = InstantiateDeclRef(ParentDecl, TemplateArgs);
|
|
|
|
if (!ParentDecl)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ParentDC = cast<DeclContext>(ParentDecl);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ParentDC != D->getDeclContext()) {
|
|
|
|
// We performed some kind of instantiation in the parent context,
|
|
|
|
// so now we need to look into the instantiated parent context to
|
|
|
|
// find the instantiation of the declaration D.
|
|
|
|
NamedDecl *Result = 0;
|
|
|
|
if (D->getDeclName()) {
|
|
|
|
DeclContext::lookup_result Found
|
|
|
|
= ParentDC->lookup(Context, D->getDeclName());
|
|
|
|
Result = findInstantiationOf(Context, D, Found.first, Found.second);
|
|
|
|
} else {
|
|
|
|
// Since we don't have a name for the entity we're looking for,
|
|
|
|
// our only option is to walk through all of the declarations to
|
|
|
|
// find that name. This will occur in a few cases:
|
|
|
|
//
|
|
|
|
// - anonymous struct/union within a template
|
|
|
|
// - unnamed class/struct/union/enum within a template
|
|
|
|
//
|
|
|
|
// FIXME: Find a better way to find these instantiations!
|
|
|
|
Result = findInstantiationOf(Context, D,
|
|
|
|
ParentDC->decls_begin(Context),
|
|
|
|
ParentDC->decls_end(Context));
|
|
|
|
}
|
|
|
|
assert(Result && "Unable to find instantiation of declaration!");
|
|
|
|
D = Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// D itself might be a class template that we need to instantiate
|
|
|
|
// with the given template arguments.
|
|
|
|
if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(D))
|
|
|
|
if (ClassTemplateDecl *ClassTemplate = Record->getDescribedClassTemplate()) {
|
|
|
|
QualType InjectedClassName
|
|
|
|
= ClassTemplate->getInjectedClassNameType(Context);
|
|
|
|
QualType InstantiatedType = InstantiateType(InjectedClassName,
|
|
|
|
TemplateArgs,
|
|
|
|
Record->getLocation(),
|
|
|
|
Record->getDeclName());
|
|
|
|
if (InstantiatedType.isNull())
|
|
|
|
return 0;
|
|
|
|
if (const RecordType *RT = InstantiatedType->getAsRecordType())
|
|
|
|
D = RT->getDecl();
|
|
|
|
}
|
|
|
|
|
|
|
|
return D;
|
|
|
|
}
|